R2 Core Shaders

Functions | Variables
R2LightSphericalLambertPhong.h File Reference

A spherical light with Phong specular highlights. More...

`#include "R2LightShaderMain.h"`
`#include "R2LightPositional.h"`
`#include "R2LightSpherical.h"`
Include dependency graph for R2LightSphericalLambertPhong.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_spherical

## Detailed Description

A spherical light with Phong specular highlights.

Definition in file R2LightSphericalLambertPhong.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 14 of file R2LightSphericalLambertPhong.h.

16 {
17 R2_light_positional_vectors_t vectors = R2_lightPositionalVectors(
18 R2_light_spherical, surface.position.xyz, surface.normal);
19 float attenuation = R2_lightPositionalAttenuation(
20 R2_light_spherical, vectors.distance);
21
22 vec3 diffuse =
23 R2_lightSphericalDiffuseLambertTerm(R2_light_spherical, vectors);
24 vec3 specular =
25 R2_lightSphericalSpecularPhongTerm(
26 R2_light_spherical,
27 vectors,
28 surface.specular,
29 surface.specular_exponent);
30
31 return R2_light_output_t(
32 diffuse * attenuation, specular * attenuation);
33 }
R2_lightPositionalAttenuation
float R2_lightPositionalAttenuation(const R2_light_positional_t light, const float distance)
Definition: R2LightPositional.h:78
R2_light_positional_vectors_t
Vectors used when calculating positional lighting.
Definition: R2LightPositional.h:9
R2_reconstructed_surface_t::position
vec4 position
The eye-space position of the surface.
Definition: R2ReconstructedSurface.h:30
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_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_lightPositionalVectors
R2_light_positional_vectors_t R2_lightPositionalVectors(const R2_light_positional_t light, const vec3 p, const vec3 n)
Definition: R2LightPositional.h:46
R2_reconstructed_surface_t::specular
vec3 specular
The sampled surface specular color.
Definition: R2ReconstructedSurface.h:23
R2_lightSphericalSpecularPhongTerm
vec3 R2_lightSphericalSpecularPhongTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v, const vec3 specular_color, const float specular_exponent)
Definition: R2LightSpherical.h:35
R2_light_output_t
The type of light values that all deferred light shaders calculate.
Definition: R2LightOutput.h:9