R2 Core Shaders

R2LightProjectiveLambert.h
Go to the documentation of this file.
1 #ifndef R2_LIGHT_PROJECTIVE_LAMBERT_H
2 #define R2_LIGHT_PROJECTIVE_LAMBERT_H
3
4 /// \file R2LightProjectiveLambert.h
5 /// \brief A projective light with no specular highlights
6
7 #include "R2LightShaderMain.h"
8 #include "R2LightPositional.h"
9 #include "R2LightProjective.h"
10 #include "R2LightSpherical.h"
11
12 uniform R2_light_positional_t R2_light_projective;
13 uniform sampler2D R2_light_projective_image;
14 uniform mat4x4 R2_transform_eye_to_light_eye;
15 uniform mat4x4 R2_transform_light_projection;
16
17 R2_light_output_t
18 R2_deferredLightMain(
19 const R2_reconstructed_surface_t surface)
20 {
21 R2_light_projective_vectors_t vectors = R2_lightProjectiveVectors(
22 R2_light_projective,
23 surface.position.xyz,
24 surface.normal,
25 R2_transform_eye_to_light_eye,
26 R2_transform_light_projection);
27
28 float attenuation = R2_lightPositionalAttenuation(
29 R2_light_projective,
30 vectors.positional.distance) * vectors.back_projected;
31
32 vec3 image_sample =
33 texture (R2_light_projective_image, vectors.surface_light_uv).rgb;
34
35 vec3 diffuse =
36 R2_lightSphericalDiffuseLambertTerm (R2_light_projective, vectors.positional);
37
38 return R2_light_output_t(
39 diffuse * image_sample * attenuation,
40 vec3 (0.0));
41 }
42
43 #endif // R2_LIGHT_PROJECTIVE_LAMBERT_H
R2_light_projective_vectors_t
Vectors used when calculating projective lighting.
Definition: R2LightProjective.h:11
R2_lightPositionalAttenuation
float R2_lightPositionalAttenuation(const R2_light_positional_t light, const float distance)
Definition: R2LightPositional.h:78
R2_reconstructed_surface_t::position
vec4 position
The eye-space position of the surface.
Definition: R2ReconstructedSurface.h:30
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)
Definition: R2LightProjective.h:42
R2_lightSphericalDiffuseLambertTerm
vec3 R2_lightSphericalDiffuseLambertTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v)
Definition: R2LightSpherical.h:17
R2_reconstructed_surface_t
Reconstructed surface data, taken from the G-Buffer.
Definition: R2ReconstructedSurface.h:16
R2_deferredLightMain
R2_light_output_t R2_deferredLightMain(const R2_reconstructed_surface_t surface)
Definition: R2LightProjectiveLambert.h:18
R2_light_projective_vectors_t::surface_light_uv
vec2 surface_light_uv
The surface position as UV coordinates from the perspective of the light.
Definition: R2LightProjective.h:25
R2_light_positional_vectors_t::distance
float distance
The distance between the surface and light source.
Definition: R2LightPositional.h:19
R2_light_positional_t
A positional light type.
Definition: R2LightPositional.h:24
R2_reconstructed_surface_t::normal
vec3 normal
The eye-space normal vector of the surface.
Definition: R2ReconstructedSurface.h:28
R2LightShaderMain.h
The main function that all deferred light shaders must implement.
R2LightSpherical.h
Functions and types related to spherical lighting.
R2LightPositional.h
Functions and types related to positional lighting.
R2_light_output_t
The type of light values that all deferred light shaders calculate.
Definition: R2LightOutput.h:9
R2LightProjective.h
Functions and types related to projective lighting.
R2_light_projective_vectors_t::positional
R2_light_positional_vectors_t positional
The vectors for positional lighting.
Definition: R2LightProjective.h:13
R2_light_projective_vectors_t::back_projected
float back_projected
A value that indicates whether or not the light fragment is back projected (0.0 means back projected...
Definition: R2LightProjective.h:28