SLProject 4.0.000
SLLight Class Referenceabstract

Abstract Light class for OpenGL light sources. More...

#include <SLLight.h>

Inheritance diagram for SLLight:
[legend]

Public Member Functions

 SLLight (SLfloat ambiPower=0.1f, SLfloat diffPower=1.0f, SLfloat specPower=1.0f, SLint id=-1)
 
virtual ~SLLight ()=default
 
void id (const SLint id)
 
void isOn (const SLbool on)
 
void powers (SLfloat ambiPow, SLfloat diffPow, SLfloat specPow, const SLCol4f &ambiDiffSpecCol=SLCol4f::WHITE)
 Sets the ambient, diffuse and specular powers all with the same color. More...
 
void ambiDiffPowers (SLfloat ambiPow, SLfloat diffPow, const SLCol4f &ambiDiffCol=SLCol4f::WHITE)
 Sets the ambient and diffuse powers with the same color. More...
 
void ambiDiffColor (const SLCol4f &ambiDiffCol)
 Sets the same color to the ambient and diffuse colors. More...
 
void ambientColor (const SLCol4f &ambi)
 
void ambientPower (const SLfloat ambPow)
 
void diffuseColor (const SLCol4f &diff)
 
void diffusePower (const SLfloat diffPow)
 
void specularColor (const SLCol4f &spec)
 
void specularPower (const SLfloat specPow)
 
void spotExponent (const SLfloat exp)
 
void spotCutOffDEG (SLfloat cutOffAngleDEG)
 
void kc (SLfloat kc)
 
void kl (SLfloat kl)
 
void kq (SLfloat kq)
 
void attenuation (const SLfloat kConstant, const SLfloat kLinear, const SLfloat kQuadratic)
 
void createsShadows (SLbool createsShadows)
 
void shadowMap (SLShadowMap *shadowMap)
 
void doSmoothShadows (SLbool doSS)
 
void smoothShadowLevel (SLuint ssLevel)
 
void shadowMinBias (SLfloat minBias)
 
void shadowMaxBias (SLfloat maxBias)
 
SLint id () const
 
SLbool isOn () const
 
SLCol4f ambientColor ()
 
SLfloat ambientPower () const
 
SLCol4f diffuseColor ()
 
SLfloat diffusePower () const
 
SLCol4f specularColor ()
 
SLfloat specularPower () const
 
SLfloat spotCutOffDEG () const
 
SLfloat spotCosCut () const
 
SLfloat spotExponent () const
 
SLfloat kc () const
 
SLfloat kl () const
 
SLfloat kq () const
 
SLbool isAttenuated () const
 
SLfloat attenuation (SLfloat dist) const
 
SLbool createsShadows () const
 
SLShadowMapshadowMap ()
 
SLbool doSoftShadows () const
 
SLuint softShadowLevel () const
 
SLfloat shadowMinBias () const
 
SLfloat shadowMaxBias () const
 
virtual SLbool doCascadedShadows () const
 
virtual SLCol4f ambient ()=0
 Return normally _ambientColor * _ambientPower. More...
 
virtual SLCol4f diffuse ()=0
 Returns normally _diffuseColor * _diffusePower. More...
 
virtual SLCol4f specular ()=0
 Returns normally _specularColor * _specularPower. More...
 
virtual SLVec4f positionWS () const =0
 
virtual SLVec3f spotDirWS ()=0
 
virtual SLfloat shadowTest (SLRay *ray, const SLVec3f &L, SLfloat lightDist, SLNode *root3D)=0
 
virtual SLfloat shadowTestMC (SLRay *ray, const SLVec3f &L, SLfloat lightDist, SLNode *root3D)=0
 
virtual void createShadowMap (float lightClipNear=0.1f, float lightClipFar=20.0f, SLVec2f size=SLVec2f(8, 8), SLVec2i texSize=SLVec2i(1024, 1024))=0
 
virtual void createShadowMapAutoSize (SLCamera *camera, SLVec2i texSize=SLVec2i(1024, 1024), int numCascades=0)=0
 
virtual void renderShadowMap (SLSceneView *sv, SLNode *root)
 SLLight::renderShadowMap renders the shadow map of the light. More...
 

Static Public Member Functions

static SLfloat oneOverGamma ()
 

Static Public Attributes

static SLCol4f globalAmbient = SLCol4f(0.1f, 0.1f, 0.1f, 1.0f)
 static global ambient light intensity More...
 
static SLfloat gamma = 1.0f
 final output gamma value More...
 
static SLbool doColoredShadows = false
 flag if shadows should be displayed with colors for debugging More...
 

Protected Attributes

SLint _id
 OpenGL light number (0-7) More...
 
SLbool _isOn
 Flag if light is on or off. More...
 
SLCol4f _ambientColor
 Ambient light color (RGB 0-1) More...
 
SLfloat _ambientPower
 Ambient light power (0-N) More...
 
SLCol4f _diffuseColor
 Diffuse light color (RGB 0-1) More...
 
SLfloat _diffusePower
 Diffuse light power (0-N) More...
 
SLCol4f _specularColor
 Specular light color (RGB 0-1) More...
 
SLfloat _specularPower
 Specular light power (0-N) More...
 
SLfloat _spotCutOffDEG
 Half the spot cone angle. More...
 
SLfloat _spotCosCutOffRAD
 cosine of spotCutoff angle More...
 
SLfloat _spotExponent
 Spot attenuation from center to edge of cone. More...
 
SLfloat _kc
 Constant light attenuation. More...
 
SLfloat _kl
 Linear light attenuation. More...
 
SLfloat _kq
 Quadratic light attenuation. More...
 
SLbool _isAttenuated
 fast attenuation flag for ray tracing More...
 
SLbool _createsShadows
 flag if light creates shadows or not More...
 
SLShadowMap_shadowMap
 Used for shadow mapping. More...
 
SLbool _doSoftShadows
 flag if percentage-closer filtering for smooth shadows is enabled More...
 
SLuint _softShadowLevel
 Radius to smoothing (1 = 3 * 3; 2 = 5 * 5; ...) More...
 
SLfloat _shadowMinBias
 Min. bias at 0 deg. to use to prevent shadow acne. More...
 
SLfloat _shadowMaxBias
 Max. bias at 90 deg. to use to prevent shadow acne. More...
 

Detailed Description

Abstract Light class for OpenGL light sources.

The abstract SLLight class encapsulates an invisible light source according to the OpenGL specification. The derivatives SLLightSpot and SLLightRect will also derive from SLNode and can therefore be freely placed in space.

Constructor & Destructor Documentation

◆ SLLight()

SLLight::SLLight ( SLfloat  ambiPower = 0.1f,
SLfloat  diffPower = 1.0f,
SLfloat  specPower = 1.0f,
SLint  id = -1 
)
explicit

◆ ~SLLight()

virtual SLLight::~SLLight ( )
virtualdefault

Member Function Documentation

◆ ambiDiffColor()

void SLLight::ambiDiffColor ( const SLCol4f ambiDiffCol)
inline

Sets the same color to the ambient and diffuse colors.

◆ ambiDiffPowers()

void SLLight::ambiDiffPowers ( SLfloat  ambiPow,
SLfloat  diffPow,
const SLCol4f ambiDiffCol = SLCol4f::WHITE 
)
inline

Sets the ambient and diffuse powers with the same color.

◆ ambient()

virtual SLCol4f SLLight::ambient ( )
pure virtual

Return normally _ambientColor * _ambientPower.

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ ambientColor() [1/2]

SLCol4f SLLight::ambientColor ( )
inline

◆ ambientColor() [2/2]

void SLLight::ambientColor ( const SLCol4f ambi)
inline

◆ ambientPower() [1/2]

SLfloat SLLight::ambientPower ( ) const
inline

◆ ambientPower() [2/2]

void SLLight::ambientPower ( const SLfloat  ambPow)
inline

◆ attenuation() [1/2]

void SLLight::attenuation ( const SLfloat  kConstant,
const SLfloat  kLinear,
const SLfloat  kQuadratic 
)
inline

◆ attenuation() [2/2]

SLfloat SLLight::attenuation ( SLfloat  dist) const
inline

◆ createShadowMap()

virtual void SLLight::createShadowMap ( float  lightClipNear = 0.1f,
float  lightClipFar = 20.0f,
SLVec2f  size = SLVec2f(8, 8),
SLVec2i  texSize = SLVec2i(1024, 1024) 
)
pure virtual

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ createShadowMapAutoSize()

virtual void SLLight::createShadowMapAutoSize ( SLCamera camera,
SLVec2i  texSize = SLVec2i(1024, 1024),
int  numCascades = 0 
)
pure virtual

Implemented in SLLightRect, SLLightSpot, and SLLightDirect.

◆ createsShadows() [1/2]

SLbool SLLight::createsShadows ( ) const
inline

◆ createsShadows() [2/2]

void SLLight::createsShadows ( SLbool  createsShadows)

◆ diffuse()

virtual SLCol4f SLLight::diffuse ( )
pure virtual

Returns normally _diffuseColor * _diffusePower.

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ diffuseColor() [1/2]

SLCol4f SLLight::diffuseColor ( )
inline

◆ diffuseColor() [2/2]

void SLLight::diffuseColor ( const SLCol4f diff)
inline

◆ diffusePower() [1/2]

SLfloat SLLight::diffusePower ( ) const
inline

◆ diffusePower() [2/2]

void SLLight::diffusePower ( const SLfloat  diffPow)
inline

◆ doCascadedShadows()

virtual SLbool SLLight::doCascadedShadows ( ) const
inlinevirtual

Reimplemented in SLLightDirect.

◆ doSmoothShadows()

void SLLight::doSmoothShadows ( SLbool  doSS)
inline

◆ doSoftShadows()

SLbool SLLight::doSoftShadows ( ) const
inline

◆ id() [1/2]

SLint SLLight::id ( ) const
inline

◆ id() [2/2]

void SLLight::id ( const SLint  id)
inline

◆ isAttenuated()

SLbool SLLight::isAttenuated ( ) const
inline

◆ isOn() [1/2]

SLbool SLLight::isOn ( ) const
inline

◆ isOn() [2/2]

void SLLight::isOn ( const SLbool  on)
inline

◆ kc() [1/2]

SLfloat SLLight::kc ( ) const
inline

◆ kc() [2/2]

void SLLight::kc ( SLfloat  kc)

◆ kl() [1/2]

SLfloat SLLight::kl ( ) const
inline

◆ kl() [2/2]

void SLLight::kl ( SLfloat  kl)

◆ kq() [1/2]

SLfloat SLLight::kq ( ) const
inline

◆ kq() [2/2]

void SLLight::kq ( SLfloat  kq)

◆ oneOverGamma()

static SLfloat SLLight::oneOverGamma ( )
inlinestatic

◆ positionWS()

virtual SLVec4f SLLight::positionWS ( ) const
pure virtual

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ powers()

void SLLight::powers ( SLfloat  ambiPow,
SLfloat  diffPow,
SLfloat  specPow,
const SLCol4f ambiDiffSpecCol = SLCol4f::WHITE 
)
inline

Sets the ambient, diffuse and specular powers all with the same color.

◆ renderShadowMap()

void SLLight::renderShadowMap ( SLSceneView sv,
SLNode root 
)
virtual

SLLight::renderShadowMap renders the shadow map of the light.

Reimplemented in SLLightDirect.

◆ shadowMap() [1/2]

SLShadowMap * SLLight::shadowMap ( )
inline

◆ shadowMap() [2/2]

void SLLight::shadowMap ( SLShadowMap shadowMap)
inline

◆ shadowMaxBias() [1/2]

SLfloat SLLight::shadowMaxBias ( ) const
inline

◆ shadowMaxBias() [2/2]

void SLLight::shadowMaxBias ( SLfloat  maxBias)
inline

◆ shadowMinBias() [1/2]

SLfloat SLLight::shadowMinBias ( ) const
inline

◆ shadowMinBias() [2/2]

void SLLight::shadowMinBias ( SLfloat  minBias)
inline

◆ shadowTest()

virtual SLfloat SLLight::shadowTest ( SLRay ray,
const SLVec3f L,
SLfloat  lightDist,
SLNode root3D 
)
pure virtual

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ shadowTestMC()

virtual SLfloat SLLight::shadowTestMC ( SLRay ray,
const SLVec3f L,
SLfloat  lightDist,
SLNode root3D 
)
pure virtual

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ smoothShadowLevel()

void SLLight::smoothShadowLevel ( SLuint  ssLevel)
inline

◆ softShadowLevel()

SLuint SLLight::softShadowLevel ( ) const
inline

◆ specular()

virtual SLCol4f SLLight::specular ( )
pure virtual

Returns normally _specularColor * _specularPower.

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ specularColor() [1/2]

SLCol4f SLLight::specularColor ( )
inline

◆ specularColor() [2/2]

void SLLight::specularColor ( const SLCol4f spec)
inline

◆ specularPower() [1/2]

SLfloat SLLight::specularPower ( ) const
inline

◆ specularPower() [2/2]

void SLLight::specularPower ( const SLfloat  specPow)
inline

◆ spotCosCut()

SLfloat SLLight::spotCosCut ( ) const
inline

◆ spotCutOffDEG() [1/2]

SLfloat SLLight::spotCutOffDEG ( ) const
inline

◆ spotCutOffDEG() [2/2]

void SLLight::spotCutOffDEG ( SLfloat  cutOffAngleDEG)

◆ spotDirWS()

virtual SLVec3f SLLight::spotDirWS ( )
pure virtual

Implemented in SLLightDirect, SLLightRect, and SLLightSpot.

◆ spotExponent() [1/2]

SLfloat SLLight::spotExponent ( ) const
inline

◆ spotExponent() [2/2]

void SLLight::spotExponent ( const SLfloat  exp)
inline

Member Data Documentation

◆ _ambientColor

SLCol4f SLLight::_ambientColor
protected

Ambient light color (RGB 0-1)

◆ _ambientPower

SLfloat SLLight::_ambientPower
protected

Ambient light power (0-N)

◆ _createsShadows

SLbool SLLight::_createsShadows
protected

flag if light creates shadows or not

◆ _diffuseColor

SLCol4f SLLight::_diffuseColor
protected

Diffuse light color (RGB 0-1)

◆ _diffusePower

SLfloat SLLight::_diffusePower
protected

Diffuse light power (0-N)

◆ _doSoftShadows

SLbool SLLight::_doSoftShadows
protected

flag if percentage-closer filtering for smooth shadows is enabled

◆ _id

SLint SLLight::_id
protected

OpenGL light number (0-7)

◆ _isAttenuated

SLbool SLLight::_isAttenuated
protected

fast attenuation flag for ray tracing

◆ _isOn

SLbool SLLight::_isOn
protected

Flag if light is on or off.

◆ _kc

SLfloat SLLight::_kc
protected

Constant light attenuation.

◆ _kl

SLfloat SLLight::_kl
protected

Linear light attenuation.

◆ _kq

SLfloat SLLight::_kq
protected

Quadratic light attenuation.

◆ _shadowMap

SLShadowMap* SLLight::_shadowMap
protected

Used for shadow mapping.

◆ _shadowMaxBias

SLfloat SLLight::_shadowMaxBias
protected

Max. bias at 90 deg. to use to prevent shadow acne.

◆ _shadowMinBias

SLfloat SLLight::_shadowMinBias
protected

Min. bias at 0 deg. to use to prevent shadow acne.

◆ _softShadowLevel

SLuint SLLight::_softShadowLevel
protected

Radius to smoothing (1 = 3 * 3; 2 = 5 * 5; ...)

◆ _specularColor

SLCol4f SLLight::_specularColor
protected

Specular light color (RGB 0-1)

◆ _specularPower

SLfloat SLLight::_specularPower
protected

Specular light power (0-N)

◆ _spotCosCutOffRAD

SLfloat SLLight::_spotCosCutOffRAD
protected

cosine of spotCutoff angle

◆ _spotCutOffDEG

SLfloat SLLight::_spotCutOffDEG
protected

Half the spot cone angle.

◆ _spotExponent

SLfloat SLLight::_spotExponent
protected

Spot attenuation from center to edge of cone.

◆ doColoredShadows

SLbool SLLight::doColoredShadows = false
static

flag if shadows should be displayed with colors for debugging

◆ gamma

SLfloat SLLight::gamma = 1.0f
static

final output gamma value

◆ globalAmbient

SLCol4f SLLight::globalAmbient = SLCol4f(0.1f, 0.1f, 0.1f, 1.0f)
static

static global ambient light intensity


The documentation for this class was generated from the following files: