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"
7 #include "R2SurfaceVertexBatched.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 }
R2_logDepthEncodeFull
float R2_logDepthEncodeFull(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:51
R2_view_t::transform_projection
mat4x4 transform_projection
Eye-space to Clip-space matrix.
Definition: R2View.h:15
R2Normals.h
Functions for transforming normal vectors.
R2View.h
Types relating to the view.
R2SurfaceTypes.h
Types for deferred surface shading.
R2_vertex_data_t
Interpolated vertex data that all deferred surface shaders will receive.
Definition: R2SurfaceTypes.h:11
R2_logDepthPrepareEyeZ
float R2_logDepthPrepareEyeZ(const float z)
Definition: R2LogDepth.h:15
R2LogDepth.h
Logarithmic depth functions.
R2SurfaceVertexBatched.h
Data delivered via vertex attributes to batched instances in deferred rendering.
R2_view_t::depth_coefficient
float depth_coefficient
The scene&#39;s logarithmic depth coefficient.
Definition: R2View.h:11
R2_view_t
Matrices and parameters related to the view that all surface shaders will receive.
Definition: R2View.h:9
R2_view_t::transform_view
mat4x4 transform_view
World-space to Eye-space matrix.
Definition: R2View.h:13