Make bloom shaders compatible with GLES2 (#12834)

Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
This commit is contained in:
x2048 2022-10-04 14:52:56 +02:00 committed by GitHub
parent 7632af3c73
commit 579fc93c24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 13 deletions

@ -2,7 +2,7 @@
uniform sampler2D rendered; uniform sampler2D rendered;
uniform vec2 texelSize0; uniform vec2 texelSize0;
uniform mediump float bloomRadius = 3.0; uniform mediump float bloomRadius;
#ifdef GL_ES #ifdef GL_ES
varying mediump vec2 varTexCoord; varying mediump vec2 varTexCoord;

@ -2,7 +2,7 @@
uniform sampler2D rendered; uniform sampler2D rendered;
uniform vec2 texelSize0; uniform vec2 texelSize0;
uniform mediump float bloomRadius = 3.0; uniform mediump float bloomRadius;
#ifdef GL_ES #ifdef GL_ES
varying mediump vec2 varTexCoord; varying mediump vec2 varTexCoord;

@ -1,8 +1,8 @@
#define rendered texture0 #define rendered texture0
uniform sampler2D rendered; uniform sampler2D rendered;
uniform mediump float exposureFactor = 2.5; uniform mediump float exposureFactor;
uniform float bloomLuminanceThreshold = 1.0; uniform float bloomLuminanceThreshold;
#ifdef GL_ES #ifdef GL_ES
varying mediump vec2 varTexCoord; varying mediump vec2 varTexCoord;

@ -3,8 +3,8 @@
uniform sampler2D rendered; uniform sampler2D rendered;
uniform sampler2D bloom; uniform sampler2D bloom;
uniform mediump float exposureFactor = 2.5; uniform mediump float exposureFactor;
uniform lowp float bloomIntensity = 1.0; uniform lowp float bloomIntensity;
#ifdef GL_ES #ifdef GL_ES
varying mediump vec2 varTexCoord; varying mediump vec2 varTexCoord;
@ -12,13 +12,13 @@ varying mediump vec2 varTexCoord;
centroid varying vec2 varTexCoord; centroid varying vec2 varTexCoord;
#endif #endif
#if ENABLE_BLOOM #ifdef ENABLE_BLOOM
vec4 applyBloom(vec4 color, vec2 uv) vec4 applyBloom(vec4 color, vec2 uv)
{ {
float bias = bloomIntensity; float bias = bloomIntensity;
vec4 bloom = texture2D(bloom, uv); vec4 bloom = texture2D(bloom, uv);
#if ENABLE_BLOOM_DEBUG #ifdef ENABLE_BLOOM_DEBUG
if (uv.x > 0.5 && uv.y < 0.5) if (uv.x > 0.5 && uv.y < 0.5)
return vec4(bloom.rgb, color.a); return vec4(bloom.rgb, color.a);
if (uv.x < 0.5) if (uv.x < 0.5)
@ -30,7 +30,7 @@ vec4 applyBloom(vec4 color, vec2 uv)
#endif #endif
#if ENABLE_TONE_MAPPING #ifdef ENABLE_TONE_MAPPING
/* Hable's UC2 Tone mapping parameters /* Hable's UC2 Tone mapping parameters
A = 0.22; A = 0.22;
@ -68,7 +68,7 @@ void main(void)
// translate to linear colorspace (approximate) // translate to linear colorspace (approximate)
color.rgb = pow(color.rgb, vec3(2.2)); color.rgb = pow(color.rgb, vec3(2.2));
#if ENABLE_BLOOM_DEBUG #ifdef ENABLE_BLOOM_DEBUG
if (uv.x > 0.5 || uv.y > 0.5) if (uv.x > 0.5 || uv.y > 0.5)
#endif #endif
{ {
@ -76,15 +76,15 @@ void main(void)
} }
#if ENABLE_BLOOM #ifdef ENABLE_BLOOM
color = applyBloom(color, uv); color = applyBloom(color, uv);
#endif #endif
#if ENABLE_BLOOM_DEBUG #ifdef ENABLE_BLOOM_DEBUG
if (uv.x > 0.5 || uv.y > 0.5) if (uv.x > 0.5 || uv.y > 0.5)
#endif #endif
{ {
#if ENABLE_TONE_MAPPING #ifdef ENABLE_TONE_MAPPING
color = applyToneMapping(color); color = applyToneMapping(color);
#else #else
color.rgb /= 2.5; // default exposure factor, see also RenderingEngine::DEFAULT_EXPOSURE_FACTOR; color.rgb /= 2.5; // default exposure factor, see also RenderingEngine::DEFAULT_EXPOSURE_FACTOR;