R2 Shaders
R2LightPositionalSingle.vert
Go to the documentation of this file.
1 /// \file R2LightPositionalSingle.vert
2 /// \brief Single-instance positional light vertex shader.
3 
4 #include "R2LogDepth.h"
5 #include "R2LightMatrices.h"
6 
7 layout(location = 0) in vec3 R2_vertex_position; // Object-space position
8 
9 uniform float R2_light_depth_coefficient;
10 uniform R2_light_matrices_t R2_light_matrices;
11 
12 out vec4 R2_light_volume_position_eye;
13 out float R2_light_volume_positive_eye_z;
14 
15 void
16 main (void)
17 {
18  vec4 position_hom =
19  vec4 (R2_vertex_position, 1.0);
20  vec4 position_eye =
21  (R2_light_matrices.transform_volume_modelview * position_hom);
22  vec4 position_clip =
23  ((R2_light_matrices.transform_projection * R2_light_matrices.transform_volume_modelview) * position_hom);
24  vec4 position_clip_log =
25  vec4 (
26  position_clip.xy,
27  R2_logDepthEncodeFull (position_clip.w, R2_light_depth_coefficient),
28  position_clip.w);
29 
30  R2_light_volume_position_eye = position_eye;
31  R2_light_volume_positive_eye_z = R2_logDepthPrepareEyeZ (position_eye.z);
32  gl_Position = position_clip_log;
33 }
float R2_logDepthEncodeFull(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:51
Matrices required by standard light types.
Input matrices for light volumes.
float R2_logDepthPrepareEyeZ(const float z)
Definition: R2LogDepth.h:15
Logarithmic depth functions.
layout(location=0) out vec4 R2_out
RGBA color.