R2 Shaders
src
main
glsl
com
io7m
r2
shaders
sources
R2LightAmbient.h
Go to the documentation of this file.
1
#ifndef R2_LIGHT_AMBIENT_H
2
#define R2_LIGHT_AMBIENT_H
3
4
/// \file R2LightAmbient.h
5
/// \brief Functions and types related to ambient lighting
6
7
/// A ambient light type
8
9
struct
R2_light_ambient_t
{
10
/// The light color. The components are assumed to be in the range `[0, 1]`.
11
vec3
color
;
12
/// The light intensity.
13
float
intensity
;
14
/// The occlusion map.
15
sampler2D
occlusion
;
16
};
17
18
/// Calculate the "diffuse" term for a ambient light. "Diffuse" in this case
19
/// appears to be slight misnomer, because the light is supposed to be providing an
20
/// ambient term. However, the `R2` package treats ambient light as simply low
21
/// intensity non-directional diffuse light.
22
///
23
/// @param light The light parameters
24
/// @param uv The screen position in UV coordinates (used for sampling from the occlusion map)
25
///
26
/// @return The diffuse term
27
28
vec3
29
R2_lightAmbientTerm
(
30
const
R2_light_ambient_t
light,
31
const
vec2 uv)
32
{
33
float
occ = texture (light.
occlusion
, uv).x;
34
return
light.
color
* (light.
intensity
* occ);
35
}
36
37
#endif
R2_light_ambient_t::color
vec3 color
The light color. The components are assumed to be in the range [0, 1].
Definition:
R2LightAmbient.h:11
R2_light_ambient_t
A ambient light type.
Definition:
R2LightAmbient.h:9
R2_light_ambient_t::occlusion
sampler2D occlusion
The occlusion map.
Definition:
R2LightAmbient.h:15
R2_lightAmbientTerm
vec3 R2_lightAmbientTerm(const R2_light_ambient_t light, const vec2 uv)
Definition:
R2LightAmbient.h:29
R2_light_ambient_t::intensity
float intensity
The light intensity.
Definition:
R2LightAmbient.h:13
Generated by
1.8.12