R2 Shaders
R2DepthSingle.vert
Go to the documentation of this file.
1 /// \file R2DepthSingle.vert
2 /// \brief A vertex shader for single (depth-only) instances.
3 
4 #include "R2LogDepth.h"
5 #include "R2Normals.h"
6 #include "R2SurfaceTypes.h"
7 #include "R2SurfaceVertex.h"
8 #include "R2View.h"
9 
10 out R2_vertex_data_t R2_vertex_data;
11 uniform R2_view_t R2_view;
12 uniform R2_surface_matrices_instance_t R2_surface_matrices_instance;
13 
14 void
15 main (void)
16 {
17  vec4 position_hom =
18  vec4 (R2_vertex_position, 1.0);
19  vec4 position_eye =
20  (R2_surface_matrices_instance.transform_modelview * position_hom);
21  vec4 position_clip =
22  ((R2_view.transform_projection * R2_surface_matrices_instance.transform_modelview) * position_hom);
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  float positive_eye_z = R2_logDepthPrepareEyeZ (position_eye.z);
30 
31  vec2 uv = (R2_surface_matrices_instance.transform_uv * vec3 (R2_vertex_uv, 1.0)).xy;
32  vec4 tangent4 = R2_vertex_tangent4;
33  vec3 tangent = tangent4.xyz;
34  vec3 normal = R2_vertex_normal;
35  vec3 bitangent = R2_normalsBitangent (normal, tangent4);
36 
37  R2_vertex_data = R2_vertex_data_t (
38  position_eye,
39  position_clip,
40  positive_eye_z,
41  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
mat4x4 transform_projection
Eye-space to Clip-space matrix.
Definition: R2View.h:15
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.
mat4x4 transform_modelview
Object-space to Eye-space matrix.
mat3x3 transform_uv
UV matrix.
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 related to the rendered instance that all deferred surface shaders will receive.
Matrices and parameters related to the view that all surface shaders will receive.
Definition: R2View.h:9