mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-13 09:20:47 +00:00
Bloom Tweaks
This commit is contained in:
parent
6832086ecb
commit
ce1a542d69
6 changed files with 52 additions and 56 deletions
|
|
@ -35,7 +35,7 @@ uniform float2 oneOverTargetSize;
|
|||
|
||||
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||
{
|
||||
#if defined(USE_DIRT)
|
||||
#ifdef USE_DIRT
|
||||
float edge = distance(IN.uv0, float2(0.5f, 0.5f));
|
||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||
float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||
|
|
@ -43,7 +43,7 @@ float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
|||
|
||||
float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0) * strength;
|
||||
|
||||
#if defined(USE_DIRT)
|
||||
#ifdef USE_DIRT
|
||||
upSample.rgb += upSample.rgb * dirt;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
|
|
@ -28,27 +27,27 @@ uniform sampler2D dirtTex;
|
|||
uniform float strength;
|
||||
// XY: Dirt Texture Size/Scale
|
||||
// Z: Dirt Effect Strength
|
||||
uniform float3 dirtParams;
|
||||
uniform vec3 dirtParams;
|
||||
// XY: Edge Min & Max Distance
|
||||
// Z: Edge Min Value
|
||||
uniform float3 edgeParams;
|
||||
uniform float2 oneOverTargetSize;
|
||||
uniform vec3 edgeParams;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
|
||||
in float2 uv0;
|
||||
in vec2 uv0;
|
||||
|
||||
out float4 OUT_col;
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if defined(USE_DIRT)
|
||||
float edge = distance(uv0, float2(0.5f, 0.5f));
|
||||
#ifdef USE_DIRT
|
||||
float edge = distance(uv0, vec2(0.5, 0.5));
|
||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||
float3 dirt = tex2D(dirtTex, uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||
vec3 dirt = texture(dirtTex, uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||
#endif
|
||||
|
||||
float4 upSample = tex2D(inputTex, uv0) * strength;
|
||||
vec4 upSample = texture(inputTex, uv0) * strength;
|
||||
|
||||
#if defined(USE_DIRT)
|
||||
#ifdef USE_DIRT
|
||||
upSample.rgb += upSample.rgb * dirt;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -20,20 +20,19 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform float threshold;
|
||||
|
||||
in float2 uv0;
|
||||
in vec2 uv0;
|
||||
|
||||
out float4 OUT_col;
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float4 screenColor = tex2D(inputTex, uv0);
|
||||
vec4 screenColor = texture(inputTex, uv0);
|
||||
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
||||
float contribution = saturate(brightness - threshold) / max(brightness, 0.0001);
|
||||
float contribution = clamp(brightness - threshold) / max(brightness, 0.0001, 0.0, 1.0);
|
||||
OUT_col = screenColor * contribution;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,41 +20,40 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
#define KERNEL_SAMPLES 9
|
||||
const float3 KERNEL[9] = float3[](
|
||||
float3( 0.0000, 0.0000, 0.2500),
|
||||
float3( 1.0000, 0.0000, 0.1250),
|
||||
float3( 0.0000, 1.0000, 0.1250),
|
||||
float3(-1.0000, 0.0000, 0.1250),
|
||||
float3( 0.0000,-1.0000, 0.1250),
|
||||
float3( 1.0000, 1.0000, 0.0625),
|
||||
float3( 1.0000,-1.0000, 0.0625),
|
||||
float3(-1.0000,-1.0000, 0.0625),
|
||||
float3(-1.0000, 1.0000, 0.0625)
|
||||
const vec3 KERNEL[9] = vec3[](
|
||||
vec3( 0.0000, 0.0000, 0.2500),
|
||||
vec3( 1.0000, 0.0000, 0.1250),
|
||||
vec3( 0.0000, 1.0000, 0.1250),
|
||||
vec3(-1.0000, 0.0000, 0.1250),
|
||||
vec3( 0.0000,-1.0000, 0.1250),
|
||||
vec3( 1.0000, 1.0000, 0.0625),
|
||||
vec3( 1.0000,-1.0000, 0.0625),
|
||||
vec3(-1.0000,-1.0000, 0.0625),
|
||||
vec3(-1.0000, 1.0000, 0.0625)
|
||||
);
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
uniform float2 oneOverTargetSize;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
|
||||
in float2 uv0;
|
||||
in vec2 uv0;
|
||||
|
||||
out float4 OUT_col;
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float4 downSample = float4(0, 0, 0, 0);
|
||||
vec4 downSample = vec4(0, 0, 0, 0);
|
||||
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
// XY: Sample Offset
|
||||
// Z: Sample Weight
|
||||
float3 offsetWeight = KERNEL[i];
|
||||
float2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
||||
vec3 offsetWeight = KERNEL[i];
|
||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
||||
float weight = offsetWeight.z;
|
||||
float4 sampleCol = tex2D(inputTex, uv0 + offsetXY);
|
||||
vec4 sampleCol = texture(inputTex, uv0 + offsetXY);
|
||||
downSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,47 +20,46 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
#define KERNEL_SAMPLES 9
|
||||
const float3 KERNEL[9] = float3[](
|
||||
float3( 0.0000, 0.0000, 0.5000),
|
||||
float3( 1.0000, 0.0000, 0.0625),
|
||||
float3( 0.0000, 1.0000, 0.0625),
|
||||
float3(-1.0000, 0.0000, 0.0625),
|
||||
float3( 0.0000,-1.0000, 0.0625),
|
||||
float3( 0.7070, 0.7070, 0.0625),
|
||||
float3( 0.7070,-0.7070, 0.0625),
|
||||
float3(-0.7070,-0.7070, 0.0625),
|
||||
float3(-0.7070, 0.7070, 0.0625)
|
||||
const vec3 KERNEL[9] = vec3[](
|
||||
vec3( 0.0000, 0.0000, 0.5000),
|
||||
vec3( 1.0000, 0.0000, 0.0625),
|
||||
vec3( 0.0000, 1.0000, 0.0625),
|
||||
vec3(-1.0000, 0.0000, 0.0625),
|
||||
vec3( 0.0000,-1.0000, 0.0625),
|
||||
vec3( 0.7070, 0.7070, 0.0625),
|
||||
vec3( 0.7070,-0.7070, 0.0625),
|
||||
vec3(-0.7070,-0.7070, 0.0625),
|
||||
vec3(-0.7070, 0.7070, 0.0625)
|
||||
);
|
||||
|
||||
uniform sampler2D nxtTex;
|
||||
uniform sampler2D mipTex;
|
||||
uniform float filterRadius;
|
||||
uniform float2 oneOverTargetSize;
|
||||
uniform vec2 oneOverTargetSize;
|
||||
|
||||
in float2 uv0;
|
||||
in vec2 uv0;
|
||||
|
||||
out float4 OUT_col;
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float4 upSample = float4(0, 0, 0, 0);
|
||||
vec4 upSample = vec4(0, 0, 0, 0);
|
||||
|
||||
for (int i=0; i<KERNEL_SAMPLES; i++)
|
||||
{
|
||||
// XY: Sample Offset
|
||||
// Z: Sample Weight
|
||||
float3 offsetWeight = KERNEL[i];
|
||||
float2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||
vec3 offsetWeight = KERNEL[i];
|
||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||
float weight = offsetWeight.z;
|
||||
float4 sampleCol = tex2D(mipTex, uv0 + offsetXY);
|
||||
vec4 sampleCol = texture(mipTex, uv0 + offsetXY);
|
||||
upSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
upSample = (tex2D(nxtTex, uv0) + upSample);
|
||||
upSample = texture(nxtTex, uv0) + upSample;
|
||||
|
||||
OUT_col = upSample;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
|||
upSample += sampleCol * weight;
|
||||
}
|
||||
|
||||
upSample = (TORQUE_TEX2D(nxtTex, IN.uv0) + upSample);
|
||||
upSample = TORQUE_TEX2D(nxtTex, IN.uv0) + upSample;
|
||||
|
||||
return upSample;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue