R2 Core Shaders
R2RefractionMaskedDeltaBatched.vert
1 /// \file R2RefractionMaskedDeltaSingle.vert
2 /// \brief A vertex shader for refracting single instances.
3 
4 #include "R2LogDepth.h"
5 #include "R2Normals.h"
6 #include "R2SurfaceTypes.h"
8 #include "R2View.h"
9 
10 uniform R2_view_t R2_view;
11 
12 out R2_vertex_data_t R2_vertex_data;
13 
14 void
15 main (void)
16 {
17  mat4x4 m_modelview =
18  (R2_view.transform_view * R2_vertex_transform_model);
19  // Batched transforms are guaranteed to be orthogonal
20  mat3x3 m_normal =
21  mat3x3 (m_modelview);
22  mat3x3 m_uv =
23  mat3x3 (1.0); // Identity matrix
24 
25  vec4 position_hom =
26  vec4 (R2_vertex_position, 1.0);
27  vec4 position_eye =
28  (m_modelview * position_hom);
29  vec4 position_clip =
30  ((R2_view.transform_projection * m_modelview) * position_hom);
31  vec4 position_clip_log =
32  vec4 (
33  position_clip.xy,
34  R2_logDepthEncodeFull (position_clip.w, R2_view.depth_coefficient),
35  position_clip.w);
36 
37  float positive_eye_z = R2_logDepthPrepareEyeZ (position_eye.z);
38 
39  vec2 uv = R2_vertex_uv;
40  vec3 normal = R2_vertex_normal;
41 
42  R2_vertex_data = R2_vertex_data_t (
43  position_eye,
44  position_clip,
45  positive_eye_z,
46  uv,
47  normal,
48  vec3(1.0, 0.0, 0.0),
49  vec3(0.0, 1.0, 0.0));
50 
51  gl_Position = position_clip_log;
52 }
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
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.
Data delivered via vertex attributes to batched instances in deferred rendering.
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
mat4x4 transform_view
World-space to Eye-space matrix.
Definition: R2View.h:13