R2 Core Shaders

R2FilterFogDepthQuadraticInverse.frag
Go to the documentation of this file.
1 /// \file R2FilterFogDepthQuadraticInverse.frag
2 /// \brief Inverse 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_fogQuadraticInverse(R2_fog, surface.xyz, eye_z_positive), surface.w);
31 }
R2ViewRays.h
View ray types.
R2Fog.h
Types related to fog rendering.
layout
layout(location=0) in vec3 R2_vertex_world_position
World-space position.
R2Viewport.h
Viewport types and functions.
R2_logDepthDecode
float R2_logDepthDecode(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:72
R2LogDepth.h
Logarithmic depth functions.
R2_fog_t
The type of fog parameters.
Definition: R2Fog.h:9
R2_fogQuadraticInverse
vec3 R2_fogQuadraticInverse(const R2_fog_t fog, const vec3 surface, const float z)
Definition: R2Fog.h:109