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

#include <lightcontext.h>

Inherits Graphics::GraphicsContext.

Classes

struct  DirectionalLightSetupInfo
struct  PointLightSetupInfo
struct  SpotLightSetupInfo
struct  AreaLightSetupInfo
struct  ConstantBufferSet
struct  ShadowData

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 SetupDirectionalLight (const Graphics::GraphicsEntityId id, const DirectionalLightSetupInfo &info)
 setup entity as global light
static void SetupPointLight (const Graphics::GraphicsEntityId id, const PointLightSetupInfo &info)
 Setup entity as point light source.
static void SetupSpotLight (const Graphics::GraphicsEntityId id, const SpotLightSetupInfo &info)
 Setup entity as spot light.
static void SetupAreaLight (const Graphics::GraphicsEntityId id, const AreaLightSetupInfo &info)
 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 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 Graphics::ViewId view, const Graphics::FrameContext &ctx)
 prepare light visibility
static void UpdateLights (const Graphics::FrameContext &ctx)
 prepare light lists
static void RunFrameScriptJobs (const Graphics::FrameContext &ctx)
 run framescript when visibility is done
static void Resize (const uint framescriptHash, 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
static const LightsCluster::LightUniforms::STRUCT & GetLightUniforms ()
 get light uniforms

Private Types

enum  {
  Light_Entity , Light_Type , Light_Color , Light_Intensity ,
  Light_ShadowCaster , Light_Range , Light_TypedLightId , Light_StageMask
}
enum  {
  PointLight_Transform , PointLight_ProjectionTexture , PointLight_Observers , PointLight_ShadowTiles ,
  PointLight_ShadowProjectionTransforms
}
enum  {
  SpotLight_Transform , SpotLight_ConeAngles , SpotLight_ProjectionTexture , SpotLight_ProjectionTransform ,
  SpotLight_ShadowProjectionTransform , SpotLight_ShadowTile , SpotLight_Observer
}
enum  {
  AreaLight_Transform , AreaLight_Shape , AreaLight_TwoSided , AreaLight_Observers ,
  AreaLight_ShadowProjectionTransforms , AreaLight_ShadowTiles , AreaLight_RenderMesh
}
enum  {
  DirectionalLight_View , DirectionalLight_Direction , DirectionalLight_Transform , DirectionalLight_CascadeObservers ,
  DirectionalLight_CascadeTiles , DirectionalLight_CascadeDistances , DirectionalLight_CascadeTransforms
}
enum  { ShadowCaster_Transform }
typedef Ids::IdAllocator< Graphics::GraphicsEntityId, LightType, Math::vec3, float, bool, float, Ids::Id32, Graphics::StageMaskGenericLightAllocator
typedef Ids::IdAllocator< Math::transform44, CoreGraphics::TextureId, std::array< Graphics::GraphicsEntityId, 6 >, std::array< Math::rectangle< int >, 6 >, std::array< Math::mat4, 6 > > PointLightAllocator
typedef Ids::IdAllocator< Math::transform44, std::array< float, 2 >, CoreGraphics::TextureId, Math::mat4, Math::mat4, Math::rectangle< int >, Graphics::GraphicsEntityIdSpotLightAllocator
typedef Ids::IdAllocator< Math::transform44, AreaLightShape, bool, std::array< Graphics::GraphicsEntityId, 2 >, std::array< Math::mat4, 2 >, std::array< Math::rectangle< int >, 2 >, bool > AreaLightAllocator
typedef Ids::IdAllocator< Graphics::ViewId, Math::vector, Math::mat4, Util::FixedArray< Graphics::GraphicsEntityId >, Util::FixedArray< Math::rectangle< int > >, Util::FixedArray< float >, Util::FixedArray< Math::mat4 > > DirectionalLightAllocator
typedef Ids::IdAllocator< Math::mat4ShadowCasterAllocator

Private Member Functions

 __DeclareContext ()

Static Private Member Functions

static void SetDirectionalLightTransform (const Graphics::ContextEntityId id, const Math::mat4 &transform, const Math::vector &direction)
 Set global light 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 > shadowCasterIndexMap

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
SpotLight_Transform 
SpotLight_ConeAngles 
SpotLight_ProjectionTexture 
SpotLight_ProjectionTransform 
SpotLight_ShadowProjectionTransform 
SpotLight_ShadowTile 
SpotLight_Observer 

◆ anonymous enum

anonymous enum
private
Enumerator
DirectionalLight_View 
DirectionalLight_Direction 
DirectionalLight_Transform 
DirectionalLight_CascadeObservers 
DirectionalLight_CascadeTiles 
DirectionalLight_CascadeDistances 
DirectionalLight_CascadeTransforms 

◆ anonymous enum

anonymous enum
private
Enumerator
AreaLight_Transform 
AreaLight_Shape 
AreaLight_TwoSided 
AreaLight_Observers 
AreaLight_ShadowProjectionTransforms 
AreaLight_ShadowTiles 
AreaLight_RenderMesh 

◆ anonymous enum

anonymous enum
private
Enumerator
ShadowCaster_Transform 

◆ anonymous enum

anonymous enum
private
Enumerator
PointLight_Transform 
PointLight_ProjectionTexture 
PointLight_Observers 
PointLight_ShadowTiles 
PointLight_ShadowProjectionTransforms 

◆ anonymous enum

anonymous enum
private
Enumerator
Light_Entity 
Light_Type 
Light_Color 
Light_Intensity 
Light_ShadowCaster 
Light_Range 
Light_TypedLightId 
Light_StageMask 

◆ 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

◆ 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

◆ GetLightUniforms()

const LightsCluster::LightUniforms::STRUCT & Lighting::LightContext::GetLightUniforms ( )
static

get light uniforms

◆ 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 Graphics::ViewId view,
const Graphics::FrameContext & ctx )
static

prepare light visibility

◆ OnRenderDebug()

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

render debug

◆ Resize()

void Lighting::LightContext::Resize ( const uint framescriptHash,
SizeT width,
SizeT height )
static

React to window resize event.

◆ RunFrameScriptJobs()

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

run framescript when visibility is done

◆ SetColor()

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

set color of light

◆ SetDirectionalLightTransform()

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

Set global light 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 AreaLightSetupInfo & info )
static

Setup entity as area light.

◆ SetupDirectionalLight()

void Lighting::LightContext::SetupDirectionalLight ( const Graphics::GraphicsEntityId id,
const DirectionalLightSetupInfo & info )
static

setup entity as global light

◆ SetupPointLight()

void Lighting::LightContext::SetupPointLight ( const Graphics::GraphicsEntityId id,
const PointLightSetupInfo & info )
static

Setup entity as point light source.

◆ SetupSpotLight()

void Lighting::LightContext::SetupSpotLight ( const Graphics::GraphicsEntityId id,
const SpotLightSetupInfo & info )
static

Setup entity as spot light.

◆ SetupTerrainShadows()

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

Setup terrain shadows.

◆ UpdateLights()

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

prepare light lists

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

◆ shadowCasterIndexMap

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

◆ spotLightAllocator

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

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