R2 Shaders
R2LightSphericalLambertPhong.h
Go to the documentation of this file.
1 #ifndef R2_LIGHT_SPHERICAL_LAMBERT_PHONG_H
2 #define R2_LIGHT_SPHERICAL_LAMBERT_PHONG_H
3 
4 /// \file R2LightSphericalLambertPhong.h
5 /// \brief A spherical light with Phong specular highlights
6 
7 #include "R2LightShaderMain.h"
8 #include "R2LightPositional.h"
9 #include "R2LightSpherical.h"
10 
11 uniform R2_light_positional_t R2_light_spherical;
12 
15  const R2_reconstructed_surface_t surface)
16 {
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 =
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 }
34 
35 #endif // R2_LIGHT_SPHERICAL_LAMBERT_PHONG_H
R2_light_output_t R2_deferredLightMain(const R2_reconstructed_surface_t surface)
float R2_lightPositionalAttenuation(const R2_light_positional_t light, const float distance)
Vectors used when calculating positional lighting.
vec4 position
The eye-space position of the surface.
float specular_exponent
The sampled surface specular exponent in the range [0, 256]
vec3 R2_lightSphericalDiffuseLambertTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v)
Reconstructed surface data, taken from the G-Buffer.
float distance
The distance between the surface and light source.
A positional light type.
vec3 normal
The eye-space normal vector of the surface.
R2_light_positional_vectors_t R2_lightPositionalVectors(const R2_light_positional_t light, const vec3 p, const vec3 n)
The main function that all deferred light shaders must implement.
vec3 specular
The sampled surface specular color.
Functions and types related to spherical lighting.
vec3 R2_lightSphericalSpecularPhongTerm(const R2_light_positional_t light, const R2_light_positional_vectors_t v, const vec3 specular_color, const float specular_exponent)
Functions and types related to positional lighting.
The type of light values that all deferred light shaders calculate.
Definition: R2LightOutput.h:9