R2 Shaders
R2LogDepthOnlySingle.vert
Go to the documentation of this file.
1 /// \file R2LogDepthOnlySingle.vert
2 /// \brief Single-instance logarithmic depth only vertex shader.
3 
4 #include "R2LogDepth.h"
5 #include "R2Normals.h"
6 #include "R2SurfaceTypes.h"
7 #include "R2View.h"
8 
9 layout(location = 0) in vec3 R2_vertex_position; // Object-space position
10 
11 out R2_vertex_data_t R2_vertex_data;
12 uniform mat4x4 R2_transform_modelview;
13 uniform R2_view_t R2_view;
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  float positive_eye_z =
31  R2_logDepthPrepareEyeZ (position_eye.z);
32 
33  R2_vertex_data = R2_vertex_data_t (
34  position_eye,
35  position_clip,
36  positive_eye_z,
37  vec2 (0.0),
38  vec3 (0.0),
39  vec3 (0.0),
40  vec3 (0.0)
41  );
42 
43  gl_Position = position_clip_log;
44 }
float R2_logDepthEncodeFull(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:51
Functions for transforming normal vectors.
Types relating to the view.
Types for deferred surface shading.
Interpolated vertex data that all deferred surface shaders will receive.
float R2_logDepthPrepareEyeZ(const float z)
Definition: R2LogDepth.h:15
Logarithmic depth functions.
layout(location=0) out vec4 R2_out
RGBA color.
Matrices and parameters related to the view that all surface shaders will receive.
Definition: R2View.h:9