R2 Core Shaders
R2MaskSingle.vert
Go to the documentation of this file.
1 /// \file R2MaskSingle.vert
2 /// \brief A vertex shader for masking single instances.
3 
4 #include "R2LogDepth.h"
5 #include "R2SurfaceTypes.h"
6 #include "R2SurfaceVertex.h"
7 #include "R2View.h"
8 #include "R2Viewport.h"
9 
10 uniform R2_view_t R2_view;
11 uniform mat4x4 R2_transform_modelview;
12 
13 out float R2_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_transform_modelview * position_hom;
22  vec4 position_clip =
23  ((R2_view.transform_projection * R2_transform_modelview) * position_hom);
24  vec4 position_clip_log =
25  vec4 (
26  position_clip.xy,
27  R2_logDepthEncodeFull (position_clip.w, R2_view.depth_coefficient),
28  position_clip.w);
29 
30  R2_positive_eye_z = R2_logDepthPrepareEyeZ (position_eye.z);
31  gl_Position = position_clip_log;
32 }
Data required by each vertex in deferred rendering, provided as vertex attributes.
float R2_logDepthEncodeFull(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:51
mat4x4 transform_projection
Eye-space to Clip-space matrix.
Definition: R2View.h:15
Viewport types and functions.
Types relating to the view.
Types for deferred surface shading.
float R2_logDepthPrepareEyeZ(const float z)
Definition: R2LogDepth.h:15
Logarithmic depth functions.
float depth_coefficient
The scene's logarithmic depth coefficient.
Definition: R2View.h:11
Matrices and parameters related to the view that all surface shaders will receive.
Definition: R2View.h:9