R2 Core Shaders
R2FilterFogDepthQuadratic.frag
Go to the documentation of this file.
1 /// \file R2FilterFogDepthQuadratic.frag
2 /// \brief Quadratic fog filter based on depth
3 
4 #include "R2Fog.h"
5 #include "R2LogDepth.h"
6 #include "R2Viewport.h"
7 #include "R2ViewRays.h"
8 
9 in vec2 R2_uv;
10 
11 uniform R2_fog_t R2_fog;
12 uniform sampler2D R2_image_depth;
13 uniform sampler2D R2_image;
14 uniform float R2_depth_coefficient;
15 
16 layout(location = 0) out vec4 out_rgba;
17 
18 void
19 main (void)
20 {
21  // Reconstruct the eye-space Z from the depth texture
22  float log_depth =
23  texture (R2_image_depth, R2_uv).x;
24  float eye_z_positive =
25  R2_logDepthDecode (log_depth, R2_depth_coefficient);
26 
27  vec4 surface =
28  texture (R2_image, R2_uv);
29 
30  out_rgba = vec4(R2_fogQuadratic(R2_fog, surface.xyz, eye_z_positive), surface.w);
31 }
View ray types.
vec3 R2_fogQuadratic(const R2_fog_t fog, const vec3 surface, const float z)
Definition: R2Fog.h:92
Types related to fog rendering.
layout(location=0) in vec3 R2_vertex_world_position
World-space position.
Viewport types and functions.
float R2_logDepthDecode(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:72
Logarithmic depth functions.
The type of fog parameters.
Definition: R2Fog.h:9