R2 Shaders
Data Structures | Functions
R2LightProjective.h File Reference

Functions and types related to projective lighting. More...

#include "R2LightPositional.h"
Include dependency graph for R2LightProjective.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  R2_light_projective_vectors_t
 Vectors used when calculating projective lighting. More...
 

Functions

R2_light_projective_vectors_t R2_lightProjectiveVectors (const R2_light_positional_t light, const vec3 p, const vec3 n, const mat4x4 m_eye_to_light_eye, const mat4x4 m_light_projection)
 

Detailed Description

Functions and types related to projective lighting.

Definition in file R2LightProjective.h.

Function Documentation

§ R2_lightProjectiveVectors()

R2_light_projective_vectors_t R2_lightProjectiveVectors ( const R2_light_positional_t  light,
const vec3  p,
const vec3  n,
const mat4x4  m_eye_to_light_eye,
const mat4x4  m_light_projection 
)

Calculate the vectors required to calculate projective lighting.

Parameters
lightThe light parameters
pThe surface position (eye-space)
nThe surface normal (eye-space)
m_eye_to_light_eyeA matrix to transform eye-space positions to light-eye-space
m_light_projectionThe light's projection matrix
Returns
A set of lighting vectors

Definition at line 42 of file R2LightProjective.h.

48 {
50  R2_lightPositionalVectors (light, p, n);
51 
52  vec4 surface_hom =
53  vec4 (p, 1.0);
54  vec4 surface_light_eye =
55  m_eye_to_light_eye * surface_hom;
56  vec4 surface_light_clip =
57  m_light_projection * surface_light_eye;
58  vec3 surface_light_ndc =
59  surface_light_clip.xyz / surface_light_clip.w;
60  vec2 surface_light_uv =
61  (surface_light_ndc.xy + 1.0) * 0.5;
62 
63  // Back-projection test.
64  float back_projected =
65  (surface_light_clip.w < 0.0) ? 0.0 : 1.0;
66 
68  positional,
69  surface_light_eye,
70  surface_light_clip,
71  surface_light_ndc,
72  surface_light_uv,
73  back_projected
74  );
75 }
Vectors used when calculating projective lighting.
Vectors used when calculating positional lighting.
R2_light_positional_vectors_t R2_lightPositionalVectors(const R2_light_positional_t light, const vec3 p, const vec3 n)