Cleanup: EEVEE: Replace brightness()
by max_v3()
It is more straightforward to understand and is define in common file.
This commit is contained in:
@@ -380,10 +380,11 @@ GPUShader *EEVEE_shaders_probe_grid_fill_sh_get(void)
|
||||
GPUShader *EEVEE_shaders_probe_planar_downsample_sh_get(void)
|
||||
{
|
||||
if (e_data.probe_planar_downsample_sh == NULL) {
|
||||
e_data.probe_planar_downsample_sh = DRW_shader_create(
|
||||
e_data.probe_planar_downsample_sh = DRW_shader_create_with_shaderlib(
|
||||
datatoc_lightprobe_planar_downsample_vert_glsl,
|
||||
datatoc_lightprobe_planar_downsample_geom_glsl,
|
||||
datatoc_lightprobe_planar_downsample_frag_glsl,
|
||||
e_data.lib,
|
||||
NULL);
|
||||
}
|
||||
return e_data.probe_planar_downsample_sh;
|
||||
@@ -478,10 +479,12 @@ GPUShader *EEVEE_shaders_effect_downsample_sh_get(void)
|
||||
GPUShader *EEVEE_shaders_effect_downsample_cube_sh_get(void)
|
||||
{
|
||||
if (e_data.downsample_cube_sh == NULL) {
|
||||
e_data.downsample_cube_sh = DRW_shader_create(datatoc_lightprobe_vert_glsl,
|
||||
datatoc_lightprobe_geom_glsl,
|
||||
datatoc_effect_downsample_cube_frag_glsl,
|
||||
NULL);
|
||||
e_data.downsample_cube_sh = DRW_shader_create_with_shaderlib(
|
||||
datatoc_lightprobe_vert_glsl,
|
||||
datatoc_lightprobe_geom_glsl,
|
||||
datatoc_effect_downsample_cube_frag_glsl,
|
||||
e_data.lib,
|
||||
NULL);
|
||||
}
|
||||
return e_data.downsample_cube_sh;
|
||||
}
|
||||
@@ -963,8 +966,8 @@ GPUShader *EEVEE_shaders_bloom_blit_get(bool high_quality)
|
||||
const char *define = high_quality ? "#define STEP_BLIT\n"
|
||||
"#define HIGH_QUALITY\n" :
|
||||
"#define STEP_BLIT\n";
|
||||
e_data.bloom_blit_sh[index] = DRW_shader_create_fullscreen(datatoc_effect_bloom_frag_glsl,
|
||||
define);
|
||||
e_data.bloom_blit_sh[index] = DRW_shader_create_fullscreen_with_shaderlib(
|
||||
datatoc_effect_bloom_frag_glsl, e_data.lib, define);
|
||||
}
|
||||
return e_data.bloom_blit_sh[index];
|
||||
}
|
||||
@@ -977,8 +980,8 @@ GPUShader *EEVEE_shaders_bloom_downsample_get(bool high_quality)
|
||||
const char *define = high_quality ? "#define STEP_DOWNSAMPLE\n"
|
||||
"#define HIGH_QUALITY\n" :
|
||||
"#define STEP_DOWNSAMPLE\n";
|
||||
e_data.bloom_downsample_sh[index] = DRW_shader_create_fullscreen(
|
||||
datatoc_effect_bloom_frag_glsl, define);
|
||||
e_data.bloom_downsample_sh[index] = DRW_shader_create_fullscreen_with_shaderlib(
|
||||
datatoc_effect_bloom_frag_glsl, e_data.lib, define);
|
||||
}
|
||||
return e_data.bloom_downsample_sh[index];
|
||||
}
|
||||
@@ -991,8 +994,8 @@ GPUShader *EEVEE_shaders_bloom_upsample_get(bool high_quality)
|
||||
const char *define = high_quality ? "#define STEP_UPSAMPLE\n"
|
||||
"#define HIGH_QUALITY\n" :
|
||||
"#define STEP_UPSAMPLE\n";
|
||||
e_data.bloom_upsample_sh[index] = DRW_shader_create_fullscreen(datatoc_effect_bloom_frag_glsl,
|
||||
define);
|
||||
e_data.bloom_upsample_sh[index] = DRW_shader_create_fullscreen_with_shaderlib(
|
||||
datatoc_effect_bloom_frag_glsl, e_data.lib, define);
|
||||
}
|
||||
return e_data.bloom_upsample_sh[index];
|
||||
}
|
||||
@@ -1005,8 +1008,8 @@ GPUShader *EEVEE_shaders_bloom_resolve_get(bool high_quality)
|
||||
const char *define = high_quality ? "#define STEP_RESOLVE\n"
|
||||
"#define HIGH_QUALITY\n" :
|
||||
"#define STEP_RESOLVE\n";
|
||||
e_data.bloom_resolve_sh[index] = DRW_shader_create_fullscreen(datatoc_effect_bloom_frag_glsl,
|
||||
define);
|
||||
e_data.bloom_resolve_sh[index] = DRW_shader_create_fullscreen_with_shaderlib(
|
||||
datatoc_effect_bloom_frag_glsl, e_data.lib, define);
|
||||
}
|
||||
return e_data.bloom_resolve_sh[index];
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
|
||||
|
||||
uniform sampler2D sourceBuffer; /* Buffer to filter */
|
||||
uniform vec2 sourceBufferTexelSize;
|
||||
|
||||
@@ -54,11 +56,6 @@ vec3 safe_color(vec3 c)
|
||||
return clamp(c, vec3(0.0), vec3(1e20)); /* 1e20 arbitrary. */
|
||||
}
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
/* 3-tap median filter */
|
||||
vec3 median(vec3 a, vec3 b, vec3 c)
|
||||
{
|
||||
@@ -78,10 +75,10 @@ vec3 downsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
vec3 s4 = textureLod(tex, uv + d.zw, 0.0).rgb;
|
||||
|
||||
/* Karis's luma weighted average (using brightness instead of luma) */
|
||||
float s1w = 1.0 / (brightness(s1) + 1.0);
|
||||
float s2w = 1.0 / (brightness(s2) + 1.0);
|
||||
float s3w = 1.0 / (brightness(s3) + 1.0);
|
||||
float s4w = 1.0 / (brightness(s4) + 1.0);
|
||||
float s1w = 1.0 / (max_v3(s1) + 1.0);
|
||||
float s2w = 1.0 / (max_v3(s2) + 1.0);
|
||||
float s3w = 1.0 / (max_v3(s3) + 1.0);
|
||||
float s4w = 1.0 / (max_v3(s4) + 1.0);
|
||||
float one_div_wsum = 1.0 / (s1w + s2w + s3w + s4w);
|
||||
|
||||
return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div_wsum;
|
||||
@@ -156,7 +153,7 @@ vec4 step_blit(void)
|
||||
#endif
|
||||
|
||||
/* Pixel brightness */
|
||||
float br = brightness(m);
|
||||
float br = max_v3(m);
|
||||
|
||||
/* Under-threshold part: quadratic curve */
|
||||
float rq = clamp(br - curveThreshold.x, 0, curveThreshold.y);
|
||||
@@ -167,7 +164,7 @@ vec4 step_blit(void)
|
||||
|
||||
/* Clamp pixel intensity if clamping enabled */
|
||||
if (clampIntensity > 0.0) {
|
||||
br = max(1e-5, brightness(m));
|
||||
br = max(1e-5, max_v3(m));
|
||||
m *= 1.0 - max(0.0, br - clampIntensity) / br;
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,8 @@
|
||||
* Simple down-sample shader. Takes the average of the 4 texels of lower mip.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
|
||||
|
||||
uniform samplerCube source;
|
||||
uniform float texelSize;
|
||||
|
||||
@@ -28,11 +30,6 @@ const vec3 y_axis[6] = vec3[6](vec3(0.0, -1.0, 0.0),
|
||||
vec3(0.0, -1.0, 0.0),
|
||||
vec3(0.0, -1.0, 0.0));
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uvs = gl_FragCoord.xy * texelSize;
|
||||
|
@@ -11,11 +11,6 @@ uniform float fireflyFactor;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texel_size = 1.0 / vec2(textureSize(source, 0));
|
||||
@@ -26,7 +21,7 @@ void main()
|
||||
FragColor = safe_color(FragColor);
|
||||
|
||||
/* Clamped brightness. */
|
||||
float luma = max(1e-8, brightness(FragColor.rgb));
|
||||
float luma = max(1e-8, max_v3(FragColor.rgb));
|
||||
FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
|
||||
|
||||
#else
|
||||
|
@@ -30,11 +30,6 @@ in vec4 uvcoordsvar;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
vec4 ssr_get_scene_color_and_mask(vec3 hit_vP, int planar_index, float mip)
|
||||
{
|
||||
vec2 uv;
|
||||
@@ -60,7 +55,7 @@ vec4 ssr_get_scene_color_and_mask(vec3 hit_vP, int planar_index, float mip)
|
||||
}
|
||||
|
||||
/* Clamped brightness. */
|
||||
float luma = brightness(color);
|
||||
float luma = max_v3(color);
|
||||
color *= 1.0 - max(0.0, luma - ssrFireflyFac) * safe_rcp(luma);
|
||||
|
||||
float mask = screen_border_mask(uv);
|
||||
|
@@ -18,11 +18,6 @@ in vec3 worldPosition;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
vec3 octahedral_to_cubemap_proj(vec2 co)
|
||||
{
|
||||
co = co * 2.0 - 1.0;
|
||||
@@ -72,7 +67,7 @@ void main()
|
||||
vec3 l_col = textureLod(probeHdr, L, lod).rgb;
|
||||
|
||||
/* Clamped brightness. */
|
||||
float luma = max(1e-8, brightness(l_col));
|
||||
float luma = max(1e-8, max_v3(l_col));
|
||||
l_col *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
|
||||
|
||||
out_radiance += l_col * NL;
|
||||
|
@@ -2,6 +2,8 @@
|
||||
* Simple down-sample shader. Takes the average of the 4 texels of lower mip.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
|
||||
|
||||
uniform sampler2DArray source;
|
||||
uniform float fireflyFactor;
|
||||
|
||||
@@ -10,11 +12,6 @@ flat in float layer;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
#if 0
|
||||
@@ -34,7 +31,7 @@ void main()
|
||||
FragColor *= 0.25;
|
||||
|
||||
/* Clamped brightness. */
|
||||
float luma = max(1e-8, brightness(FragColor.rgb));
|
||||
float luma = max(1e-8, max_v3(FragColor.rgb));
|
||||
FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma;
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user