R2 Core Shaders
R2RefractionMaskedDelta.frag
Go to the documentation of this file.
1 /// \file R2RefractionMaskedDelta.frag
2 /// \brief Apply masked delta refraction
3 
4 #include "R2LogDepth.h"
5 #include "R2Refraction.h"
6 #include "R2SurfaceTypes.h"
7 #include "R2View.h"
8 #include "R2Viewport.h"
9 
10 layout(location = 0) out vec4 R2_out;
11 
12 in R2_vertex_data_t R2_vertex_data;
13 
14 uniform R2_refraction_t R2_refraction;
15 uniform sampler2D R2_refraction_delta;
16 uniform R2_view_t R2_view;
17 uniform R2_viewport_t R2_viewport;
18 
19 void
20 main (void)
21 {
22  float depth_log = R2_logDepthEncodePartial(
23  R2_vertex_data.positive_eye_z, R2_view.depth_coefficient);
24  vec3 delta_unsigned =
25  texture (R2_refraction_delta, R2_vertex_data.uv).xyz;
26  vec3 delta =
27  (delta_unsigned * 2.0) - 1.0;
28 
29  R2_out = R2_refractionMasked(
30  R2_refraction, R2_vertex_data.position_clip, delta);
31  gl_FragDepth = depth_log;
32 }
float R2_logDepthEncodePartial(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:33
layout(location=0) in vec3 R2_vertex_world_position
World-space position.
Viewport types and functions.
Types relating to the view.
Types for deferred surface shading.
The type of viewports.
Definition: R2Viewport.h:9
Interpolated vertex data that all deferred surface shaders will receive.
Logarithmic depth functions.
Functions and types to render generic refraction.
Matrices and parameters related to the view that all surface shaders will receive.
Definition: R2View.h:9
vec4 R2_refractionMasked(const R2_refraction_t refraction, const vec4 position_here_clip, const vec3 delta)
Definition: R2Refraction.h:30