diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/environment/sky.cpp | 1 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shaders/environment/sky.glsl | 13 | ||||
-rw-r--r-- | servers/rendering/shader_types.cpp | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/servers/rendering/renderer_rd/environment/sky.cpp b/servers/rendering/renderer_rd/environment/sky.cpp index 65d1d9e705..ceba43ae8f 100644 --- a/servers/rendering/renderer_rd/environment/sky.cpp +++ b/servers/rendering/renderer_rd/environment/sky.cpp @@ -907,6 +907,7 @@ void SkyRD::init() { actions.usage_defines["HALF_RES_COLOR"] = "\n#define USES_HALF_RES_COLOR\n"; actions.usage_defines["QUARTER_RES_COLOR"] = "\n#define USES_QUARTER_RES_COLOR\n"; actions.render_mode_defines["disable_fog"] = "#define DISABLE_FOG\n"; + actions.render_mode_defines["use_debanding"] = "#define USE_DEBANDING\n"; actions.sampler_array_name = "material_samplers"; actions.base_texture_binding_index = 1; diff --git a/servers/rendering/renderer_rd/shaders/environment/sky.glsl b/servers/rendering/renderer_rd/shaders/environment/sky.glsl index 0eb0f5f8fd..d523461600 100644 --- a/servers/rendering/renderer_rd/shaders/environment/sky.glsl +++ b/servers/rendering/renderer_rd/shaders/environment/sky.glsl @@ -153,6 +153,15 @@ layout(set = 3, binding = 0) uniform texture3D volumetric_fog_texture; layout(location = 0) out vec4 frag_color; +#ifdef USE_DEBANDING +// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare +vec3 interleaved_gradient_noise(vec2 pos) { + const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f); + float res = fract(magic.z * fract(dot(pos, magic.xy))) * 2.0 - 1.0; + return vec3(res, -res, res) / 255.0; +} +#endif + vec4 volumetric_fog_process(vec2 screen_uv) { vec3 fog_pos = vec3(screen_uv, 1.0); @@ -252,4 +261,8 @@ void main() { // For mobile renderer we're multiplying by 0.5 as we're using a UNORM buffer. // For both mobile and clustered, we also bake in the exposure value for the environment and camera. frag_color.rgb = frag_color.rgb * params.luminance_multiplier; + +#ifdef USE_DEBANDING + frag_color.rgb += interleaved_gradient_noise(gl_FragCoord.xy); +#endif } diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp index 43c483a00d..47cb38f268 100644 --- a/servers/rendering/shader_types.cpp +++ b/servers/rendering/shader_types.cpp @@ -444,6 +444,7 @@ ShaderTypes::ShaderTypes() { shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_half_res_pass") }); shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_quarter_res_pass") }); shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("disable_fog") }); + shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_debanding") }); } /************ FOG **************************/ |