R2 Shaders
Functions | Variables
R2LightProjectiveLambertShadowVariance.h File Reference

A projective light with no specular highlights and a variance shadow. More...

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

Go to the source code of this file.

Functions

R2_light_output_t R2_deferredLightMain (const R2_reconstructed_surface_t surface)
 

Variables

uniform R2_light_positional_t R2_light_projective
 
uniform R2_shadow_variance_t R2_shadow_variance
 
uniform sampler2D R2_light_projective_image
 
uniform mat4x4 R2_transform_eye_to_light_eye
 
uniform mat4x4 R2_transform_light_projection
 

Detailed Description

A projective light with no specular highlights and a variance shadow.

Definition in file R2LightProjectiveLambertShadowVariance.h.

Function Documentation

§ R2_deferredLightMain()

R2_light_output_t R2_deferredLightMain ( const R2_reconstructed_surface_t  surface)

Calculate light values for the current light, based on the current contents of the G-buffer.

Parameters
surfaceReconstructed surface data taken from the G-Buffer
Returns
Calculated light values

Definition at line 20 of file R2LightProjectiveLambertShadowVariance.h.

22 {
24  R2_light_projective,
25  surface.position.xyz,
26  surface.normal,
27  R2_transform_eye_to_light_eye,
28  R2_transform_light_projection);
29 
30  float shadow =
31  R2_varianceShadowFactor (R2_shadow_variance, vectors);
32 
33  float attenuation =
35  R2_light_projective,
36  vectors.positional.distance) * vectors.back_projected * shadow;
37 
38  vec3 image_sample =
39  texture (R2_light_projective_image, vectors.surface_light_uv).rgb;
40 
41  vec3 diffuse =
42  R2_lightSphericalDiffuseLambertTerm (R2_light_projective, vectors.positional);
43 
44  return R2_light_output_t(
45  diffuse * image_sample * attenuation,
46  vec3 (0.0));
47 }
Vectors used when calculating projective lighting.
float R2_lightPositionalAttenuation(const R2_light_positional_t light, const float distance)
vec4 position
The eye-space position of the surface.
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)
vec3 R2_lightSphericalDiffuseLambertTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v)
vec2 surface_light_uv
The surface position as UV coordinates from the perspective of the light.
float distance
The distance between the surface and light source.
vec3 normal
The eye-space normal vector of the surface.
float R2_varianceShadowFactor(const R2_shadow_variance_t s, const R2_light_projective_vectors_t v)
The type of light values that all deferred light shaders calculate.
Definition: R2LightOutput.h:9
R2_light_positional_vectors_t positional
The vectors for positional lighting.
float back_projected
A value that indicates whether or not the light fragment is back projected (0.0 means back projected...