R2 Shaders
Functions
R2PositionReconstruction.h File Reference

Functions for performing position reconstruction during deferred rendering. More...

#include "R2Bilinear.h"
#include "R2ViewRays.h"
Include dependency graph for R2PositionReconstruction.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

vec4 R2_positionReconstructFromEyeZ (const float eye_z, const vec2 uv, const R2_view_rays_t view_rays)
 

Detailed Description

Functions for performing position reconstruction during deferred rendering.

Definition in file R2PositionReconstruction.h.

Function Documentation

§ R2_positionReconstructFromEyeZ()

vec4 R2_positionReconstructFromEyeZ ( const float  eye_z,
const vec2  uv,
const R2_view_rays_t  view_rays 
)

Reconstruct an eye-space position from the given parameters.

Parameters
eye_zThe eye-space Z value of the position
uvThe current position on the screen in UV coordinates
view_raysThe current set of view rays

Definition at line 19 of file R2PositionReconstruction.h.

23 {
24  vec3 origin =
26  view_rays.origin_x0y0,
27  view_rays.origin_x1y0,
28  view_rays.origin_x0y1,
29  view_rays.origin_x1y1,
30  uv
31  );
32 
33  vec3 ray_normal =
35  view_rays.ray_x0y0,
36  view_rays.ray_x1y0,
37  view_rays.ray_x0y1,
38  view_rays.ray_x1y1,
39  uv
40  );
41 
42  vec3 ray =
43  (ray_normal * eye_z) + origin;
44 
45  return vec4 (ray, 1.0);
46 }
vec3 ray_x0y1
The view ray pointing out of the top left origin.
Definition: R2ViewRays.h:23
vec3 ray_x1y1
The view ray pointing out of the top right origin.
Definition: R2ViewRays.h:25
vec3 ray_x0y0
The view ray pointing out of the bottom left origin.
Definition: R2ViewRays.h:19
vec3 origin_x1y1
The top right origin.
Definition: R2ViewRays.h:17
vec3 ray_x1y0
The view ray pointing out of the bottom right origin.
Definition: R2ViewRays.h:21
vec3 origin_x0y0
The bottom left origin.
Definition: R2ViewRays.h:11
vec3 origin_x0y1
The top left origin.
Definition: R2ViewRays.h:15
vec3 origin_x1y0
The bottom right origin.
Definition: R2ViewRays.h:13
vec3 R2_bilinearInterpolate3(const vec3 x0y0, const vec3 x1y0, const vec3 x0y1, const vec3 x1y1, const vec2 p)
Definition: R2Bilinear.h:23