Game Development Reference
In-Depth Information
// Vertex-Shader Stage
flat out vec2 tex_coord;
uniform sampler2D zbuffer;
void main ( void )
tex_coord = gl_Vertex.xy;
float depth = SampleBuf (zbuffer, tex_coord).x;
// screen space --> canonical screen space
vec3 pos_css = MAP_0To1_-1To1 (vec3 (gl_Vertex.xy, depth));
// canonical screen space --> object space
vec3 pos_wcs = PointCSS2WCS (zbuffer_css);
// world space --> clip space
gl_Position = gl_ModelViewProjectionMatrix *
vec4 (pos_wcs, 1.0);
// Geometry-Shader Stage
layout(points) in;
layout(points, max_vertices = 1) out;
uniform int vol_depth;
flat in vec2 tex_coord[];
flat out vec2 gtex_coord;
void main ( void )
gtex_coord = tex_coord[0];
gl_Position = gl_PositionIn[0];
gl_Layer = int (vol_depth * MAP_-1To1_0To1 (gl_Position.z));
Listing 6.2. Injection phase using a geometry shader to select the destination slice of
the volume for the point samples.
injected point samples. The resolution of the grid of 2D points determines how
much detail of the surfaces represented by the depth buffer is transferred into the
volume and whether or not the geometry is sparsely sampled. If too few points
are injected, the resulting volume will have gaps. This may be undesirable for
certain application cases, such as the LPV method [Kaplanyan 09] or algorithms
based on ray marching.
6.2.3 Single-Pass Progressive Algorithm
In order to transfer the geometric detail present in the G-buffers to the volume
representation and ensure a dense population of the resulting volume, a large res-
olution for the grid of injected points must be used. However, the injection stage
Search Nedrilad ::

Custom Search