mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Bloom GL Fix
This commit is contained in:
parent
ce1a542d69
commit
e4999a3351
4 changed files with 24 additions and 16 deletions
|
|
@ -20,8 +20,12 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||||
|
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
|
#line 27
|
||||||
|
|
||||||
uniform sampler2D inputTex;
|
uniform sampler2D inputTex;
|
||||||
uniform sampler2D dirtTex;
|
uniform sampler2D dirtTex;
|
||||||
uniform float strength;
|
uniform float strength;
|
||||||
|
|
@ -33,19 +37,17 @@ uniform vec3 dirtParams;
|
||||||
uniform vec3 edgeParams;
|
uniform vec3 edgeParams;
|
||||||
uniform vec2 oneOverTargetSize;
|
uniform vec2 oneOverTargetSize;
|
||||||
|
|
||||||
in vec2 uv0;
|
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
#ifdef USE_DIRT
|
#ifdef USE_DIRT
|
||||||
float edge = distance(uv0, vec2(0.5, 0.5));
|
float edge = distance(IN_uv0, vec2(0.5, 0.5));
|
||||||
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z);
|
||||||
vec3 dirt = texture(dirtTex, uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
vec3 dirt = texture(dirtTex, IN_uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec4 upSample = texture(inputTex, uv0) * strength;
|
vec4 upSample = texture(inputTex, IN_uv0) * strength;
|
||||||
|
|
||||||
#ifdef USE_DIRT
|
#ifdef USE_DIRT
|
||||||
upSample.rgb += upSample.rgb * dirt;
|
upSample.rgb += upSample.rgb * dirt;
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,21 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||||
|
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
|
#line 27
|
||||||
|
|
||||||
uniform sampler2D inputTex;
|
uniform sampler2D inputTex;
|
||||||
uniform float threshold;
|
uniform float threshold;
|
||||||
|
|
||||||
in vec2 uv0;
|
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 screenColor = texture(inputTex, uv0);
|
vec4 screenColor = texture(inputTex, IN_uv0);
|
||||||
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
|
||||||
float contribution = clamp(brightness - threshold) / max(brightness, 0.0001, 0.0, 1.0);
|
float contribution = clamp(brightness - threshold, 0.0, 1.0) / max(brightness, 0.0001);
|
||||||
OUT_col = screenColor * contribution;
|
OUT_col = screenColor * contribution;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,12 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||||
|
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
|
#line 27
|
||||||
|
|
||||||
#define KERNEL_SAMPLES 9
|
#define KERNEL_SAMPLES 9
|
||||||
const vec3 KERNEL[9] = vec3[](
|
const vec3 KERNEL[9] = vec3[](
|
||||||
vec3( 0.0000, 0.0000, 0.2500),
|
vec3( 0.0000, 0.0000, 0.2500),
|
||||||
|
|
@ -38,8 +42,6 @@ const vec3 KERNEL[9] = vec3[](
|
||||||
uniform sampler2D inputTex;
|
uniform sampler2D inputTex;
|
||||||
uniform vec2 oneOverTargetSize;
|
uniform vec2 oneOverTargetSize;
|
||||||
|
|
||||||
in vec2 uv0;
|
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -53,7 +55,7 @@ void main()
|
||||||
vec3 offsetWeight = KERNEL[i];
|
vec3 offsetWeight = KERNEL[i];
|
||||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize;
|
||||||
float weight = offsetWeight.z;
|
float weight = offsetWeight.z;
|
||||||
vec4 sampleCol = texture(inputTex, uv0 + offsetXY);
|
vec4 sampleCol = texture(inputTex, IN_uv0 + offsetXY);
|
||||||
downSample += sampleCol * weight;
|
downSample += sampleCol * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,12 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||||
|
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
|
#line 27
|
||||||
|
|
||||||
#define KERNEL_SAMPLES 9
|
#define KERNEL_SAMPLES 9
|
||||||
const vec3 KERNEL[9] = vec3[](
|
const vec3 KERNEL[9] = vec3[](
|
||||||
vec3( 0.0000, 0.0000, 0.5000),
|
vec3( 0.0000, 0.0000, 0.5000),
|
||||||
|
|
@ -40,8 +44,6 @@ uniform sampler2D mipTex;
|
||||||
uniform float filterRadius;
|
uniform float filterRadius;
|
||||||
uniform vec2 oneOverTargetSize;
|
uniform vec2 oneOverTargetSize;
|
||||||
|
|
||||||
in vec2 uv0;
|
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -55,11 +57,11 @@ void main()
|
||||||
vec3 offsetWeight = KERNEL[i];
|
vec3 offsetWeight = KERNEL[i];
|
||||||
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
vec2 offsetXY = offsetWeight.xy * oneOverTargetSize * filterRadius;
|
||||||
float weight = offsetWeight.z;
|
float weight = offsetWeight.z;
|
||||||
vec4 sampleCol = texture(mipTex, uv0 + offsetXY);
|
vec4 sampleCol = texture(mipTex, IN_uv0 + offsetXY);
|
||||||
upSample += sampleCol * weight;
|
upSample += sampleCol * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
upSample = texture(nxtTex, uv0) + upSample;
|
upSample = texture(nxtTex, IN_uv0) + upSample;
|
||||||
|
|
||||||
OUT_col = upSample;
|
OUT_col = upSample;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue