R2 Shaders
R2DebugVisualConstantScreen.vert
Go to the documentation of this file.
1 /// \file R2DebugVisualConstantScreen.vert
2 /// \brief A vertex shader for full-screen debug geometry
3 
4 #include "R2LogDepth.h"
5 #include "R2Normals.h"
6 #include "R2SurfaceTypes.h"
7 #include "R2SurfaceVertex.h"
8 #include "R2View.h"
9 
10 uniform R2_view_t R2_view;
11 uniform mat4x4 R2_transform_projection_inverse;
12 
13 out R2_vertex_data_t R2_vertex_data;
14 
15 void
16 main (void)
17 {
18  // The input vertices are assumed to be in clip-space already.
19  vec4 position_clip =
20  vec4 (R2_vertex_position, 1.0);
21  vec4 position_eye =
22  R2_transform_projection_inverse * position_clip;
23  vec4 position_clip_log =
24  vec4 (
25  position_clip.xy,
26  R2_logDepthEncodeFull (position_clip.w, R2_view.depth_coefficient),
27  position_clip.w);
28 
29  vec4 tangent4 = R2_vertex_tangent4;
30  vec3 tangent = tangent4.xyz;
31  vec3 normal = R2_vertex_normal;
32  vec3 bitangent = R2_normalsBitangent (normal, tangent4);
33 
34  float positive_eye_z =
35  R2_logDepthPrepareEyeZ (position_eye.z);
36 
37  R2_vertex_data = R2_vertex_data_t (
38  position_eye,
39  position_clip,
40  positive_eye_z,
41  R2_vertex_uv,
42  normal,
43  tangent,
44  bitangent
45  );
46 
47  gl_Position = position_clip_log;
48 }
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
vec3 R2_normalsBitangent(const vec3 n, const vec4 t)
Definition: R2Normals.h:58
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.
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