R2 Shaders
R2DepthShaderDriverBatched.h
Go to the documentation of this file.
1 #ifndef R2_DEPTH_SHADER_DRIVER_BATCHED_H
2 #define R2_DEPTH_SHADER_DRIVER_BATCHED_H
3 
4 /// \file R2DepthShaderDriverBatched.h
5 /// \brief A fragment depth shader driver for batched instances.
6 
7 #include "R2DepthTypes.h"
8 #include "R2LogDepth.h"
9 #include "R2Normals.h"
10 #include "R2SurfaceTypes.h"
11 #include "R2GBufferOutput.h"
12 #include "R2View.h"
13 
14 in R2_vertex_data_t R2_vertex_data;
15 in R2_surface_matrices_instance_t R2_surface_matrices_instance;
16 uniform R2_view_t R2_view;
17 
18 layout(location = 0) out vec2 R2_out_depth_variance;
19 
21 R2_depth_shader_main_exec()
22 {
23  float depth_log = R2_logDepthEncodePartial (
24  R2_vertex_data.positive_eye_z,
25  R2_view.depth_coefficient);
26 
27  bool discarded = R2_depthShaderMain(
28  R2_vertex_data,
29  R2_view,
30  R2_surface_matrices_instance);
31 
32  return R2_depth_shader_result_t(discarded, depth_log);
33 }
34 
35 void
36 main (void)
37 {
38  R2_depth_shader_result_t o = R2_depth_shader_main_exec();
39 
40  R2_out_depth_variance = vec2 (o.depth, o.depth * o.depth);
41  gl_FragDepth = o.depth;
42 
43  if (o.discarded) {
44  discard;
45  }
46 }
47 
48 #endif // R2_DEPTH_SHADER_DRIVER_BATCHED_H
float R2_logDepthEncodePartial(const float z, const float depth_coefficient)
Definition: R2LogDepth.h:33
Functions for transforming normal vectors.
Types related to depth/depth-variance rendering.
Types relating to the view.
Types for deferred surface shading.
The G-Buffer format.
float depth
The calculated logarithmic depth of the surface.
Definition: R2DepthTypes.h:13
float positive_eye_z
Positive eye-space Z position.
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
The type of values produced by depth shader executions.
Definition: R2DepthTypes.h:9
Interpolated vertex data that all deferred surface shaders will receive.
Logarithmic depth functions.
bool discarded
true iff the fragment should be discarded
Definition: R2DepthTypes.h:11
float depth_coefficient
The scene's logarithmic depth coefficient.
Definition: R2View.h:11
layout(location=0) out vec4 R2_out
RGBA color.
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