8 #ifndef META_OCEAN_RENDERING_GI_LIGHTING_H
9 #define META_OCEAN_RENDERING_GI_LIGHTING_H
26 namespace GlobalIllumination
51 LM_SHADING_LAMBERT = (1 << 0),
53 LM_SHADING_SPECULAR = (1 << 1) | LM_SHADING_LAMBERT,
55 LM_TRANSPARENCY = (1 << 2),
57 LM_REFLECTION_SPECULAR = (1 << 3),
59 LM_REFRACTION_SPECULAR = (1 << 4) | LM_TRANSPARENCY,
61 LM_SHADOWS = (1 << 5),
63 LM_SHADOWS_SUPERSAMPLE = (1 << 6) | LM_SHADOWS,
65 LM_SHADOWS_TRANSLUCENT_LIGHT = (1 << 7) | LM_SHADOWS,
67 LM_SHADING_FULL = LM_SHADING_LAMBERT | LM_SHADING_SPECULAR,
69 LM_REFLECTION_REFRACTION_FULL = LM_REFLECTION_SPECULAR | LM_REFRACTION_SPECULAR,
71 LM_SHADOWS_FULL = LM_SHADOWS | LM_SHADOWS_SUPERSAMPLE | LM_SHADOWS_TRANSLUCENT_LIGHT,
73 LM_LIGHTING_FULL = LM_SHADING_FULL | LM_REFLECTION_REFRACTION_FULL | LM_SHADOWS_FULL
93 static bool dampedLight(
const Vector3& viewPosition,
const Vector3& viewObjectDirection,
const Vector3& objectPosition,
const Vector3& objectNormal,
const Vector2& textureCoordinate,
const GIMaterial* material,
const GITextures* textures,
const LightSources& lightSources,
const TracingObject&
object,
const TracingGroup& root,
const unsigned int bounces,
const LightingModes lightingModes,
RGBAColor& color);
134 static inline Scalar pointLightAttenuationFactor(
const Vector3& lightAttenuation,
const Scalar lightObjectDistance,
const Scalar intensity);
143 static inline Scalar pointLightAttenuationFactorSqr(
const Vector3& lightAttenuation,
const Scalar lightObjectDistanceSqr,
const Scalar intensity);
156 static inline Scalar spotLightAttenuationFactor(
const Vector3& lightAttenuation,
const Scalar lightObjectDistance,
const Scalar intensity,
const Vector3& lightDirection,
const Vector3& lightObjectDirection,
const Scalar coneAngleCos,
const Scalar spotExponent);
161 ocean_assert(intensity >= 0 && intensity <= 1);
163 if (lightAttenuation.
isNull())
166 ocean_assert(lightAttenuation[0] >= 0);
167 ocean_assert(lightAttenuation[1] >= 0);
168 ocean_assert(lightAttenuation[2] >= 0);
170 ocean_assert(intensity >= 0 && intensity <= 1);
173 if (lightAttenuation[1] == 0 && lightAttenuation[2] == 0)
176 const Scalar factor = lightAttenuation[0] + lightAttenuation[1] * lightObjectDistance + lightAttenuation[2] *
Numeric::sqr(lightObjectDistance);
185 return intensity / factor;
190 ocean_assert(intensity >= 0 && intensity <= 1);
192 if (lightAttenuation.
isNull())
195 ocean_assert(lightAttenuation[0] >= 0);
196 ocean_assert(lightAttenuation[1] >= 0);
197 ocean_assert(lightAttenuation[2] >= 0);
199 ocean_assert(lightObjectDistanceSqr >= 0);
201 ocean_assert(intensity >= 0 && intensity <= 1);
204 if (lightAttenuation[1] == 0 && lightAttenuation[2] == 0)
207 const Scalar factor = lightAttenuation[0] + lightAttenuation[1] *
Numeric::sqrt(lightObjectDistanceSqr) + lightAttenuation[2] * lightObjectDistanceSqr;
216 return intensity / factor;
224 ocean_assert(intensity >= 0 && intensity <= 1);
226 const Scalar factor = lightDirection * lightObjectDirection;
228 if (factor < coneAngleCos)
231 if (spotExponent == 0)
static MessageObject warning()
Returns the message for warning messages.
Definition: Messenger.h:1069
static T pow(const T x, const T y)
Returns x raised to the power of y.
Definition: Numeric.h:1860
static T sqrt(const T value)
Returns the square root of a given value.
Definition: Numeric.h:1533
static constexpr T eps()
Returns a small epsilon.
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition: Numeric.h:1495
This class implements a color defined by red, green, blue and alpha parameters.
Definition: RGBAColor.h:41
This class implements a Global Illumination material object.
Definition: GIMaterial.h:33
This class implements a Global Illumination texture attributes object.
Definition: GITextures.h:34
This class implements object lighting functions.
Definition: Lighting.h:40
LightingModes
Definition of individual lighting modes.
Definition: Lighting.h:47
static bool directLight(const Vector3 &viewObjectDirection, const Vector3 &objectPosition, const Vector3 &objectNormal, const Vector3 &lightObjectDirection, const RGBAColor &materialLightDiffuse, const RGBAColor &materialLightSpecular, const Scalar materialSpecularExponent, const LightingModes lightingModes, RGBAColor &diffuse, RGBAColor &specular)
Determines the direct lighting for a specific location and light source using the Lambert shading wit...
static Scalar spotLightAttenuationFactor(const Vector3 &lightAttenuation, const Scalar lightObjectDistance, const Scalar intensity, const Vector3 &lightDirection, const Vector3 &lightObjectDirection, const Scalar coneAngleCos, const Scalar spotExponent)
Returns the attenuation factor for a given spot light.
Definition: Lighting.h:219
static bool dampedLight(const Vector3 &viewPosition, const Vector3 &viewObjectDirection, const Vector3 &objectPosition, const Vector3 &objectNormal, const Vector2 &textureCoordinate, const GIMaterial *material, const GITextures *textures, const LightSources &lightSources, const TracingObject &object, const TracingGroup &root, const unsigned int bounces, const LightingModes lightingModes, RGBAColor &color)
Determines the light (the color) for a specified viewing ray, intersection point, appearance informat...
static Scalar pointLightAttenuationFactor(const Vector3 &lightAttenuation, const Scalar lightObjectDistance, const Scalar intensity)
Returns the attenuation factor for a given point light.
Definition: Lighting.h:159
static Scalar pointLightAttenuationFactorSqr(const Vector3 &lightAttenuation, const Scalar lightObjectDistanceSqr, const Scalar intensity)
Returns the attenuation factor for a given point light.
Definition: Lighting.h:188
static RGBAColor lightDampingFactors(const Vector3 &lightPosition, const Vector3 &lightObjectDirection, const Scalar lightObjectDistance, const RGBAColor &lightColor, const TracingGroup &root, const LightingModes lightingModes)
Determines the light damping factors for a specific position and light source.
This class implements a group of tracing objects.
Definition: TracingGroup.h:28
This class is the abstract base class for all tracing objects.
Definition: TracingObject.h:39
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition: Vector3.h:854
T length() const
Returns the length of the vector.
Definition: Vector3.h:664
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< LightPair > LightSources
Definition of a vector holding light pairs.
Definition: GILightSource.h:40
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15