Nebula
Loading...
Searching...
No Matches
Lighting::LightContext Class Reference

#include <lightcontext.h>

Inherits Graphics::GraphicsContext.

Classes

struct  ConstantBufferSet
 

Public Types

enum class  LightType { DirectionalLightType , PointLightType , SpotLightType , AreaLightType }
 
enum class  AreaLightShape { Disk , Rectangle , Tube }
 

Public Member Functions

 LightContext ()
 constructor
 
virtual ~LightContext ()
 destructor
 
- Public Member Functions inherited from Graphics::GraphicsContext
 GraphicsContext ()
 constructor
 
virtual ~GraphicsContext ()
 destructor
 

Static Public Member Functions

static void Create ()
 setup light context
 
static void Discard ()
 discard light context
 
static void SetupGlobalLight (const Graphics::GraphicsEntityId id, const Math::vec3 &color, const float intensity, const Math::vec3 &ambient, const Math::vec3 &backlight, const float backlightFactor, const float zenith, const float azimuth, bool castShadows=false)
 setup entity as global light
 
static void SetupPointLight (const Graphics::GraphicsEntityId id, const Math::vec3 &color, const float intensity, const float range, bool castShadows=false, const CoreGraphics::TextureId projection=CoreGraphics::InvalidTextureId)
 Setup entity as point light source.
 
static void SetupSpotLight (const Graphics::GraphicsEntityId id, const Math::vec3 &color, const float intensity, const float innerConeAngle, const float outerConeAngle, const float range, bool castShadows=false, const CoreGraphics::TextureId projection=CoreGraphics::InvalidTextureId)
 Setup entity as spot light.
 
static void SetupAreaLight (const Graphics::GraphicsEntityId id, const AreaLightShape shape, const Math::vec3 &color, const float intensity, const float range, bool twoSided=false, bool castShadows=false)
 Setup entity as area light.
 
static void SetColor (const Graphics::GraphicsEntityId id, const Math::vec3 &color)
 set color of light
 
static Math::vec3 GetColor (const Graphics::GraphicsEntityId id)
 
static void SetRange (const Graphics::GraphicsEntityId id, const float range)
 set range of light
 
static void SetIntensity (const Graphics::GraphicsEntityId id, const float intensity)
 set intensity of light
 
static float GetIntensity (const Graphics::GraphicsEntityId id)
 
static void SetTransform (const Graphics::GraphicsEntityId id, const float azimuth, const float zenith)
 Set transform as angles.
 
static const Math::mat4 GetTransform (const Graphics::GraphicsEntityId id)
 get transform
 
static const Math::mat4 GetObserverTransform (const Graphics::GraphicsEntityId id)
 get the view transform including projections
 
static const void SetPosition (const Graphics::GraphicsEntityId id, const Math::point &position)
 Set light position.
 
static const Math::point GetPosition (const Graphics::GraphicsEntityId id)
 Get light position.
 
static const void SetRotation (const Graphics::GraphicsEntityId id, const Math::quat &rotation)
 Set light rotation.
 
static const Math::quat GetRotation (const Graphics::GraphicsEntityId id)
 Get light rotation.
 
static const void SetScale (const Graphics::GraphicsEntityId id, const Math::vec3 &scale)
 Set light scale.
 
static const Math::vec3 GetScale (const Graphics::GraphicsEntityId id)
 Get light scale.
 
static Math::vec3 GetAmbient (const Graphics::GraphicsEntityId id)
 
static void SetAmbient (const Graphics::GraphicsEntityId id, Math::vec3 &ambient)
 
static LightType GetType (const Graphics::GraphicsEntityId id)
 get the light type
 
static void GetInnerOuterAngle (const Graphics::GraphicsEntityId id, float &inner, float &outer)
 get inner and outer angle for spotlights
 
static void SetInnerOuterAngle (const Graphics::GraphicsEntityId id, float inner, float outer)
 set inner and outer angle for spotlights
 
static void OnPrepareView (const Ptr< Graphics::View > &view, const Graphics::FrameContext &ctx)
 prepare light visibility
 
static void UpdateViewDependentResources (const Ptr< Graphics::View > &view, const Graphics::FrameContext &ctx)
 prepare light lists
 
static void RunFrameScriptJobs (const Graphics::FrameContext &ctx)
 run framescript when visibility is done
 
static void WindowResized (const CoreGraphics::WindowId windowId, SizeT width, SizeT height)
 React to window resize event.
 
static void OnRenderDebug (uint32_t flags)
 render debug
 
static void SetupTerrainShadows (const CoreGraphics::TextureId terrainShadowMap, const uint worldSize)
 Setup terrain shadows.
 
static const CoreGraphics::BufferId GetLightIndexBuffer ()
 get light index lists buffer
 
static const CoreGraphics::BufferId GetLightsBuffer ()
 get light lists buffer
 

Private Types

enum  {
  Type , Color , Intensity , ShadowCaster ,
  Range , TypedLightId
}
 
enum  {
  PointLight_Transform , PointLight_ConstantBufferSet , PointLight_ShadowConstantBufferSet , PointLight_DynamicOffsets ,
  PointLight_ProjectionTexture , PointLight_Observer
}
 
enum  {
  SpotLight_Transform , SpotLight_ConstantBufferSet , SpotLight_ShadowConstantBufferSet , SpotLight_DynamicOffsets ,
  SpotLight_ConeAngles , SpotLight_ProjectionTexture , SpotLight_ProjectionTransform , SpotLight_Observer
}
 
enum  {
  AreaLight_Transform , AreaLight_Shape , AreaLight_ConstantBufferSet , AreaLight_ShadowConstantBufferSet ,
  AreaLight_DynamicOffsets , AreaLight_TwoSided , AreaLight_Observer
}
 
enum  {
  DirectionalLight_Direction , DirectionalLight_Backlight , DirectionalLight_BacklightOffset , DirectionalLight_Ambient ,
  DirectionalLight_Transform , DirectionalLight_ViewProjTransform , DirectionalLight_CascadeObservers
}
 
enum  { ShadowCaster_Transform }
 
typedef Ids::IdAllocator< LightType, Math::vec3, float, bool, float, Ids::Id32GenericLightAllocator
 
typedef Ids::IdAllocator< Math::transform44, ConstantBufferSet, ConstantBufferSet, Util::FixedArray< uint >, CoreGraphics::TextureId, Graphics::GraphicsEntityIdPointLightAllocator
 
typedef Ids::IdAllocator< Math::transform44, ConstantBufferSet, ConstantBufferSet, Util::FixedArray< uint >, std::array< float, 2 >, CoreGraphics::TextureId, Math::mat4, Graphics::GraphicsEntityIdSpotLightAllocator
 
typedef Ids::IdAllocator< Math::transform44, AreaLightShape, ConstantBufferSet, ConstantBufferSet, Util::FixedArray< uint >, bool, Graphics::GraphicsEntityIdAreaLightAllocator
 
typedef Ids::IdAllocator< Math::vector, Math::vec3, float, Math::vec3, Math::mat4, Math::mat4, Util::Array< Graphics::GraphicsEntityId > > DirectionalLightAllocator
 
typedef Ids::IdAllocator< Math::mat4ShadowCasterAllocator
 

Private Member Functions

 __DeclareContext ()
 

Static Private Member Functions

static void SetGlobalLightTransform (const Graphics::ContextEntityId id, const Math::mat4 &transform, const Math::vector &direction)
 Set global light transform.
 
static void SetGlobalLightViewProjTransform (const Graphics::ContextEntityId id, const Math::mat4 &transform)
 Set global light shadow transform.
 
static Graphics::ContextEntityId Alloc ()
 allocate a new slice for this context
 
static void Dealloc (Graphics::ContextEntityId id)
 deallocate a slice
 

Static Private Attributes

static GenericLightAllocator genericLightAllocator
 
static PointLightAllocator pointLightAllocator
 
static SpotLightAllocator spotLightAllocator
 
static AreaLightAllocator areaLightAllocator
 
static DirectionalLightAllocator directionalLightAllocator
 
static ShadowCasterAllocator shadowCasterAllocator
 
static Util::HashTable< Graphics::GraphicsEntityId, uint, 16, 1 > shadowCasterSliceMap
 

Additional Inherited Members

- Static Protected Member Functions inherited from Graphics::GraphicsContext
static void InternalRegisterEntity (const Graphics::GraphicsEntityId id, Graphics::GraphicsContextState &&state)
 
static void InternalDeregisterEntity (const Graphics::GraphicsEntityId id, Graphics::GraphicsContextState &&state)
 
template<class ID_ALLOCATOR >
static void InternalDefragment (ID_ALLOCATOR &allocator, Graphics::GraphicsContextState &&state)
 

Member Typedef Documentation

◆ AreaLightAllocator

◆ DirectionalLightAllocator

◆ GenericLightAllocator

◆ PointLightAllocator

◆ ShadowCasterAllocator

◆ SpotLightAllocator

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
Type 
Color 
Intensity 
ShadowCaster 
Range 
TypedLightId 

◆ anonymous enum

anonymous enum
private
Enumerator
PointLight_Transform 
PointLight_ConstantBufferSet 
PointLight_ShadowConstantBufferSet 
PointLight_DynamicOffsets 
PointLight_ProjectionTexture 
PointLight_Observer 

◆ anonymous enum

anonymous enum
private
Enumerator
SpotLight_Transform 
SpotLight_ConstantBufferSet 
SpotLight_ShadowConstantBufferSet 
SpotLight_DynamicOffsets 
SpotLight_ConeAngles 
SpotLight_ProjectionTexture 
SpotLight_ProjectionTransform 
SpotLight_Observer 

◆ anonymous enum

anonymous enum
private
Enumerator
AreaLight_Transform 
AreaLight_Shape 
AreaLight_ConstantBufferSet 
AreaLight_ShadowConstantBufferSet 
AreaLight_DynamicOffsets 
AreaLight_TwoSided 
AreaLight_Observer 

◆ anonymous enum

anonymous enum
private
Enumerator
DirectionalLight_Direction 
DirectionalLight_Backlight 
DirectionalLight_BacklightOffset 
DirectionalLight_Ambient 
DirectionalLight_Transform 
DirectionalLight_ViewProjTransform 
DirectionalLight_CascadeObservers 

◆ anonymous enum

anonymous enum
private
Enumerator
ShadowCaster_Transform 

◆ AreaLightShape

Enumerator
Disk 
Rectangle 
Tube 

◆ LightType

Enumerator
DirectionalLightType 
PointLightType 
SpotLightType 
AreaLightType 

Constructor & Destructor Documentation

◆ LightContext()

Lighting::LightContext::LightContext ( )

constructor

◆ ~LightContext()

Lighting::LightContext::~LightContext ( )
virtual

destructor

Member Function Documentation

◆ __DeclareContext()

Lighting::LightContext::__DeclareContext ( )
private

◆ Alloc()

Graphics::ContextEntityId Lighting::LightContext::Alloc ( )
staticprivate

allocate a new slice for this context

◆ Create()

void Lighting::LightContext::Create ( )
static

setup light context

◆ Dealloc()

void Lighting::LightContext::Dealloc ( Graphics::ContextEntityId id)
staticprivate

deallocate a slice

◆ Discard()

void Lighting::LightContext::Discard ( )
static

discard light context

◆ GetAmbient()

Math::vec3 Lighting::LightContext::GetAmbient ( const Graphics::GraphicsEntityId id)
static

◆ GetColor()

Math::vec3 Lighting::LightContext::GetColor ( const Graphics::GraphicsEntityId id)
static

◆ GetInnerOuterAngle()

void Lighting::LightContext::GetInnerOuterAngle ( const Graphics::GraphicsEntityId id,
float & inner,
float & outer )
static

get inner and outer angle for spotlights

◆ GetIntensity()

float Lighting::LightContext::GetIntensity ( const Graphics::GraphicsEntityId id)
static

◆ GetLightIndexBuffer()

const CoreGraphics::BufferId Lighting::LightContext::GetLightIndexBuffer ( )
static

get light index lists buffer

◆ GetLightsBuffer()

const CoreGraphics::BufferId Lighting::LightContext::GetLightsBuffer ( )
static

get light lists buffer

◆ GetObserverTransform()

const Math::mat4 Lighting::LightContext::GetObserverTransform ( const Graphics::GraphicsEntityId id)
static

get the view transform including projections

◆ GetPosition()

const Math::point Lighting::LightContext::GetPosition ( const Graphics::GraphicsEntityId id)
static

Get light position.

◆ GetRotation()

const Math::quat Lighting::LightContext::GetRotation ( const Graphics::GraphicsEntityId id)
static

Get light rotation.

◆ GetScale()

const Math::vec3 Lighting::LightContext::GetScale ( const Graphics::GraphicsEntityId id)
static

Get light scale.

◆ GetTransform()

const Math::mat4 Lighting::LightContext::GetTransform ( const Graphics::GraphicsEntityId id)
static

get transform

◆ GetType()

LightContext::LightType Lighting::LightContext::GetType ( const Graphics::GraphicsEntityId id)
static

get the light type

◆ OnPrepareView()

void Lighting::LightContext::OnPrepareView ( const Ptr< Graphics::View > & view,
const Graphics::FrameContext & ctx )
static

prepare light visibility

◆ OnRenderDebug()

void Lighting::LightContext::OnRenderDebug ( uint32_t flags)
static

render debug

◆ RunFrameScriptJobs()

static void Lighting::LightContext::RunFrameScriptJobs ( const Graphics::FrameContext & ctx)
static

run framescript when visibility is done

◆ SetAmbient()

void Lighting::LightContext::SetAmbient ( const Graphics::GraphicsEntityId id,
Math::vec3 & ambient )
static

◆ SetColor()

void Lighting::LightContext::SetColor ( const Graphics::GraphicsEntityId id,
const Math::vec3 & color )
static

set color of light

◆ SetGlobalLightTransform()

void Lighting::LightContext::SetGlobalLightTransform ( const Graphics::ContextEntityId id,
const Math::mat4 & transform,
const Math::vector & direction )
staticprivate

Set global light transform.

◆ SetGlobalLightViewProjTransform()

void Lighting::LightContext::SetGlobalLightViewProjTransform ( const Graphics::ContextEntityId id,
const Math::mat4 & transform )
staticprivate

Set global light shadow transform.

◆ SetInnerOuterAngle()

void Lighting::LightContext::SetInnerOuterAngle ( const Graphics::GraphicsEntityId id,
float inner,
float outer )
static

set inner and outer angle for spotlights

◆ SetIntensity()

void Lighting::LightContext::SetIntensity ( const Graphics::GraphicsEntityId id,
const float intensity )
static

set intensity of light

◆ SetPosition()

const void Lighting::LightContext::SetPosition ( const Graphics::GraphicsEntityId id,
const Math::point & position )
static

Set light position.

◆ SetRange()

void Lighting::LightContext::SetRange ( const Graphics::GraphicsEntityId id,
const float range )
static

set range of light

◆ SetRotation()

const void Lighting::LightContext::SetRotation ( const Graphics::GraphicsEntityId id,
const Math::quat & rotation )
static

Set light rotation.

◆ SetScale()

const void Lighting::LightContext::SetScale ( const Graphics::GraphicsEntityId id,
const Math::vec3 & scale )
static

Set light scale.

◆ SetTransform()

void Lighting::LightContext::SetTransform ( const Graphics::GraphicsEntityId id,
const float azimuth,
const float zenith )
static

Set transform as angles.

◆ SetupAreaLight()

void Lighting::LightContext::SetupAreaLight ( const Graphics::GraphicsEntityId id,
const AreaLightShape shape,
const Math::vec3 & color,
const float intensity,
const float range,
bool twoSided = false,
bool castShadows = false )
static

Setup entity as area light.

◆ SetupGlobalLight()

void Lighting::LightContext::SetupGlobalLight ( const Graphics::GraphicsEntityId id,
const Math::vec3 & color,
const float intensity,
const Math::vec3 & ambient,
const Math::vec3 & backlight,
const float backlightFactor,
const float zenith,
const float azimuth,
bool castShadows = false )
static

setup entity as global light

◆ SetupPointLight()

void Lighting::LightContext::SetupPointLight ( const Graphics::GraphicsEntityId id,
const Math::vec3 & color,
const float intensity,
const float range,
bool castShadows = false,
const CoreGraphics::TextureId projection = CoreGraphics::InvalidTextureId )
static

Setup entity as point light source.

◆ SetupSpotLight()

void Lighting::LightContext::SetupSpotLight ( const Graphics::GraphicsEntityId id,
const Math::vec3 & color,
const float intensity,
const float innerConeAngle,
const float outerConeAngle,
const float range,
bool castShadows = false,
const CoreGraphics::TextureId projection = CoreGraphics::InvalidTextureId )
static

Setup entity as spot light.

◆ SetupTerrainShadows()

void Lighting::LightContext::SetupTerrainShadows ( const CoreGraphics::TextureId terrainShadowMap,
const uint worldSize )
static

Setup terrain shadows.

◆ UpdateViewDependentResources()

void Lighting::LightContext::UpdateViewDependentResources ( const Ptr< Graphics::View > & view,
const Graphics::FrameContext & ctx )
static

prepare light lists

◆ WindowResized()

void Lighting::LightContext::WindowResized ( const CoreGraphics::WindowId windowId,
SizeT width,
SizeT height )
static

React to window resize event.

Member Data Documentation

◆ areaLightAllocator

LightContext::AreaLightAllocator Lighting::LightContext::areaLightAllocator
staticprivate

◆ directionalLightAllocator

LightContext::DirectionalLightAllocator Lighting::LightContext::directionalLightAllocator
staticprivate

◆ genericLightAllocator

LightContext::GenericLightAllocator Lighting::LightContext::genericLightAllocator
staticprivate

◆ pointLightAllocator

LightContext::PointLightAllocator Lighting::LightContext::pointLightAllocator
staticprivate

◆ shadowCasterAllocator

LightContext::ShadowCasterAllocator Lighting::LightContext::shadowCasterAllocator
staticprivate

◆ shadowCasterSliceMap

Util::HashTable< Graphics::GraphicsEntityId, uint, 16, 1 > Lighting::LightContext::shadowCasterSliceMap
staticprivate

◆ spotLightAllocator

LightContext::SpotLightAllocator Lighting::LightContext::spotLightAllocator
staticprivate

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