R2 Core Shaders

Functions | Variables
R2LightProjectiveLambertBlinnPhong.h File Reference

A projective light with Blinn-Phong specular highlights. More...

`#include "R2LightShaderMain.h"`
`#include "R2LightPositional.h"`
`#include "R2LightProjective.h"`
`#include "R2LightSpherical.h"`
Include dependency graph for R2LightProjectiveLambertBlinnPhong.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 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 Blinn-Phong specular highlights.

Definition in file R2LightProjectiveLambertBlinnPhong.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

  surface | Reconstructed surface data taken from the G-Buffer

Returns
  Calculated light values

Definition at line 18 of file R2LightProjectiveLambertBlinnPhong.h.

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 vec3 specular =
38 R2_lightSphericalSpecularBlinnPhongTerm(
39 R2_light_projective,
40 vectors.positional,
41 surface.specular,
42 surface.specular_exponent);
43
44 return R2_light_output_t(
45 diffuse * image_sample * attenuation,
46 specular * image_sample * attenuation);
47 }
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_lightSphericalSpecularBlinnPhongTerm
vec3 R2_lightSphericalSpecularBlinnPhongTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v, const vec3 specular_color, const float specular_exponent)
Definition: R2LightSpherical.h:62
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_reconstructed_surface_t::specular_exponent
float specular_exponent
The sampled surface specular exponent in the range [0, 256]
Definition: R2ReconstructedSurface.h:25
R2_lightSphericalDiffuseLambertTerm
vec3 R2_lightSphericalDiffuseLambertTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v)
Definition: R2LightSpherical.h:17
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_reconstructed_surface_t::normal
vec3 normal
The eye-space normal vector of the surface.
Definition: R2ReconstructedSurface.h:28
R2_reconstructed_surface_t::specular
vec3 specular
The sampled surface specular color.
Definition: R2ReconstructedSurface.h:23
R2_light_output_t
The type of light values that all deferred light shaders calculate.
Definition: R2LightOutput.h:9
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