R2 Core Shaders

R2DepthShaderDriverSingle.h
Go to the documentation of this file.
1 #ifndef R2_DEPTH_SHADER_DRIVER_SINGLE_H
2 #define R2_DEPTH_SHADER_DRIVER_SINGLE_H
3
4 /// \file R2DepthShaderDriverSingle.h
5 /// \brief A fragment shader driver for single instance depth shaders.
6
7 #include "R2DepthTypes.h"
8 #include "R2LogDepth.h"
9 #include "R2SurfaceTypes.h"
10 #include "R2View.h"
11
12 in R2_vertex_data_t R2_vertex_data;
13 uniform R2_surface_matrices_instance_t R2_surface_matrices_instance;
14 uniform R2_surface_textures_t R2_surface_textures;
15 uniform R2_view_t R2_view;
16
17 layout(location = 0) out vec2 R2_out_depth_variance;
18
19 R2_depth_shader_result_t
20 R2_depth_shader_main_exec()
21 {
22 float depth_log = R2_logDepthEncodePartial(
23 R2_vertex_data.positive_eye_z,
24 R2_view.depth_coefficient);
25
26 bool discarded = R2_depthShaderMain(
27 R2_vertex_data,
28 R2_view,
29 R2_surface_matrices_instance);
30
31 return R2_depth_shader_result_t(discarded, depth_log);
32 }
33
34 void
35 main (void)
36 {
37 R2_depth_shader_result_t o = R2_depth_shader_main_exec();
38
39 R2_out_depth_variance = vec2 (o.depth, o.depth * o.depth);
40 gl_FragDepth = o.depth;
41
42 if (o.discarded) {
43 discard;
44 }
45 }
46
47 #endif // R2_DEPTH_SHADER_DRIVER_SINGLE_H
R2_logDepthEncodePartial
float R2_logDepthEncodePartial(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:33
layout
layout(location=0) in vec3 R2_vertex_world_position
World-space position.
R2DepthTypes.h
Types related to depth/depth-variance rendering.
R2View.h
Types relating to the view.
R2SurfaceTypes.h
Types for deferred surface shading.
R2_depth_shader_result_t::depth
float depth
The calculated logarithmic depth of the surface.
Definition: R2DepthTypes.h:13
R2_vertex_data_t::positive_eye_z
float positive_eye_z
Positive eye-space Z position.
Definition: R2SurfaceTypes.h:17
R2_depthShaderMain
bool R2_depthShaderMain(const R2_vertex_data_t data, const R2_view_t view, const R2_surface_matrices_instance_t matrices_instance)
Definition: R2DepthBasic.h:13
R2_depth_shader_result_t
The type of values produced by depth shader executions.
Definition: R2DepthTypes.h:9
R2_surface_textures_t
Textures that are required by all surfaces.
Definition: R2SurfaceTypes.h:37
R2_vertex_data_t
Interpolated vertex data that all deferred surface shaders will receive.
Definition: R2SurfaceTypes.h:11
R2LogDepth.h
Logarithmic depth functions.
R2_depth_shader_result_t::discarded
bool discarded
true iff the fragment should be discarded
Definition: R2DepthTypes.h:11
R2_view_t::depth_coefficient
float depth_coefficient
The scene&#39;s logarithmic depth coefficient.
Definition: R2View.h:11
R2_surface_matrices_instance_t
Matrices related to the rendered instance that all deferred surface shaders will receive.
Definition: R2SurfaceTypes.h:44
R2_view_t
Matrices and parameters related to the view that all surface shaders will receive.
Definition: R2View.h:9