Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::ForwardRenderTechnique Class Reference

Graphics class that represents the technique used in forward rendering. More...

Inheritance diagram for Nz::ForwardRenderTechnique:
Nz::AbstractRenderTechnique

Public Member Functions

 ForwardRenderTechnique ()
 Constructs a ForwardRenderTechnique object by default.
 
void Clear (const SceneData &sceneData) const override
 Clears the data. More...
 
bool Draw (const SceneData &sceneData) const override
 Draws the data of the scene. More...
 
unsigned int GetMaxLightPassPerObject () const
 Gets the maximum number of lights available per pass per object. More...
 
AbstractRenderQueueGetRenderQueue () override
 Gets the render queue. More...
 
RenderTechniqueType GetType () const override
 Gets the type of the current technique. More...
 
void SetMaxLightPassPerObject (unsigned int maxLightPassPerObject)
 Sets the maximum number of lights available per pass per object. More...
 
- Public Member Functions inherited from Nz::AbstractRenderTechnique
 AbstractRenderTechnique ()
 Constructs a AbstractRenderTechnique object.
 
 AbstractRenderTechnique (const AbstractRenderTechnique &)=delete
 
 AbstractRenderTechnique (AbstractRenderTechnique &&)=default
 
virtual void EnableInstancing (bool instancing)
 Enables the instancing. More...
 
virtual String GetName () const
 Gets the name of the actual technique. More...
 
virtual bool IsInstancingEnabled () const
 Checks whether the instancing is enabled. More...
 
AbstractRenderTechniqueoperator= (const AbstractRenderTechnique &)=delete
 
AbstractRenderTechniqueoperator= (AbstractRenderTechnique &&)=default
 

Static Public Member Functions

static bool Initialize ()
 Initializes the forward render technique. More...
 
static void Uninitialize ()
 Uninitializes the forward render technique.
 

Protected Member Functions

void ChooseLights (const Spheref &object, bool includeDirectionalLights=true) const
 Chooses the nearest lights for one object. More...
 
void DrawBasicSprites (const SceneData &sceneData, ForwardRenderQueue::Layer &layer) const
 Draws basic sprites. More...
 
void DrawBillboards (const SceneData &sceneData, ForwardRenderQueue::Layer &layer) const
 Draws billboards. More...
 
void DrawOpaqueModels (const SceneData &sceneData, ForwardRenderQueue::Layer &layer) const
 Draws opaques models. More...
 
void DrawOrderedSprites (const SceneData &sceneData, ForwardRenderQueue::Layer &layer) const
 
void DrawTransparentModels (const SceneData &sceneData, ForwardRenderQueue::Layer &layer) const
 Draws transparent models. More...
 
const ShaderUniforms * GetShaderUniforms (const Shader *shader) const
 Gets the shader uniforms. More...
 
void OnShaderInvalidated (const Shader *shader) const
 Handle the invalidation of a shader. More...
 
void SendLightUniforms (const Shader *shader, const LightUniforms &uniforms, unsigned int index, unsigned int lightIndex, unsigned int uniformOffset) const
 Sends the uniforms for light. More...
 

Static Protected Member Functions

static float ComputeDirectionalLightScore (const Spheref &object, const AbstractRenderQueue::DirectionalLight &light)
 Computes the score for directional light. More...
 
static float ComputePointLightScore (const Spheref &object, const AbstractRenderQueue::PointLight &light)
 Computes the score for point light. More...
 
static float ComputeSpotLightScore (const Spheref &object, const AbstractRenderQueue::SpotLight &light)
 Computes the score for spot light. More...
 
static bool IsDirectionalLightSuitable (const Spheref &object, const AbstractRenderQueue::DirectionalLight &light)
 Checks whether the directional light is suitable for the computations. More...
 
static bool IsPointLightSuitable (const Spheref &object, const AbstractRenderQueue::PointLight &light)
 Checks whether the point light is suitable for the computations. More...
 
static bool IsSpotLightSuitable (const Spheref &object, const AbstractRenderQueue::SpotLight &light)
 Checks whether the spot light is suitable for the computations. More...
 

Protected Attributes

std::unordered_map< const Shader *, ShaderUniforms > m_shaderUniforms
 
std::vector< LightIndex > m_lights
 
Buffer m_vertexBuffer
 
ForwardRenderQueue m_renderQueue
 
Texture m_whiteTexture
 
VertexBuffer m_billboardPointBuffer
 
VertexBuffer m_spriteBuffer
 
unsigned int m_maxLightPassPerObject
 
- Protected Attributes inherited from Nz::AbstractRenderTechnique
bool m_instancingEnabled
 

Static Protected Attributes

static IndexBuffer s_quadIndexBuffer
 
static Texture s_dummyReflection
 
static TextureSampler s_reflectionSampler
 
static TextureSampler s_shadowSampler
 
static VertexBuffer s_quadVertexBuffer
 
static VertexDeclaration s_billboardInstanceDeclaration
 
static VertexDeclaration s_billboardVertexDeclaration
 

Detailed Description

Graphics class that represents the technique used in forward rendering.

Member Function Documentation

◆ ChooseLights()

void Nz::ForwardRenderTechnique::ChooseLights ( const Spheref object,
bool  includeDirectionalLights = true 
) const
protected

Chooses the nearest lights for one object.

Parameters
objectSphere symbolising the object
includeDirectionalLightsShould directional lights be included in the computation

◆ Clear()

void Nz::ForwardRenderTechnique::Clear ( const SceneData &  sceneData) const
overridevirtual

Clears the data.

Parameters
sceneDataData of the scene

Implements Nz::AbstractRenderTechnique.

◆ ComputeDirectionalLightScore()

float Nz::ForwardRenderTechnique::ComputeDirectionalLightScore ( const Spheref object,
const AbstractRenderQueue::DirectionalLight &  light 
)
inlinestaticprotected

Computes the score for directional light.

Returns
0.f
Parameters
objectSphere symbolising the object
lightLight to compute

TODO: Compute a score depending on the light luminosity

◆ ComputePointLightScore()

float Nz::ForwardRenderTechnique::ComputePointLightScore ( const Spheref object,
const AbstractRenderQueue::PointLight &  light 
)
inlinestaticprotected

Computes the score for point light.

Returns
Distance to the light
Parameters
objectSphere symbolising the object
lightLight to compute

TODO: Compute a score depending on the light luminosity

◆ ComputeSpotLightScore()

float Nz::ForwardRenderTechnique::ComputeSpotLightScore ( const Spheref object,
const AbstractRenderQueue::SpotLight &  light 
)
inlinestaticprotected

Computes the score for spot light.

Returns
Distance to the light
Parameters
objectSphere symbolising the object
lightLight to compute

TODO: Compute a score depending on the light luminosity and spot direction

◆ Draw()

bool Nz::ForwardRenderTechnique::Draw ( const SceneData &  sceneData) const
overridevirtual

Draws the data of the scene.

Returns
true If successful
Parameters
sceneDataData of the scene
Remarks
Produces a NazaraAssert if viewer of the scene is invalid

Implements Nz::AbstractRenderTechnique.

◆ DrawBasicSprites()

void Nz::ForwardRenderTechnique::DrawBasicSprites ( const SceneData &  sceneData,
ForwardRenderQueue::Layer &  layer 
) const
protected

Draws basic sprites.

Parameters
sceneDataData of the scene
layerLayer of the rendering
Remarks
Produces a NazaraAssert is viewer is invalid

◆ DrawBillboards()

void Nz::ForwardRenderTechnique::DrawBillboards ( const SceneData &  sceneData,
ForwardRenderQueue::Layer &  layer 
) const
protected

Draws billboards.

Parameters
sceneDataData of the scene
layerLayer of the rendering
Remarks
Produces a NazaraAssert is viewer is invalid

◆ DrawOpaqueModels()

void Nz::ForwardRenderTechnique::DrawOpaqueModels ( const SceneData &  sceneData,
ForwardRenderQueue::Layer &  layer 
) const
protected

Draws opaques models.

Parameters
sceneDataData of the scene
layerLayer of the rendering
Remarks
Produces a NazaraAssert is viewer is invalid

◆ DrawTransparentModels()

void Nz::ForwardRenderTechnique::DrawTransparentModels ( const SceneData &  sceneData,
ForwardRenderQueue::Layer &  layer 
) const
protected

Draws transparent models.

Parameters
sceneDataData of the scene
layerLayer of the rendering
Remarks
Produces a NazaraAssert is viewer is invalid

◆ GetMaxLightPassPerObject()

unsigned int Nz::ForwardRenderTechnique::GetMaxLightPassPerObject ( ) const

Gets the maximum number of lights available per pass per object.

Returns
Maximum number of light simulatenously per object

◆ GetRenderQueue()

AbstractRenderQueue * Nz::ForwardRenderTechnique::GetRenderQueue ( )
overridevirtual

Gets the render queue.

Returns
Pointer to the render queue

Implements Nz::AbstractRenderTechnique.

◆ GetShaderUniforms()

const ForwardRenderTechnique::ShaderUniforms * Nz::ForwardRenderTechnique::GetShaderUniforms ( const Shader *  shader) const
protected

Gets the shader uniforms.

Returns
Uniforms of the shader
Parameters
shaderShader to get uniforms from

◆ GetType()

RenderTechniqueType Nz::ForwardRenderTechnique::GetType ( ) const
overridevirtual

Gets the type of the current technique.

Returns
Type of the render technique

Implements Nz::AbstractRenderTechnique.

◆ Initialize()

bool Nz::ForwardRenderTechnique::Initialize ( )
static

Initializes the forward render technique.

Returns
true If successful
Remarks
Produces a NazaraError if one shader creation failed

◆ IsDirectionalLightSuitable()

bool Nz::ForwardRenderTechnique::IsDirectionalLightSuitable ( const Spheref object,
const AbstractRenderQueue::DirectionalLight &  light 
)
inlinestaticprotected

Checks whether the directional light is suitable for the computations.

Returns
true if light is enoughly close
Parameters
objectSphere symbolising the object
lightLight to compute

◆ IsPointLightSuitable()

bool Nz::ForwardRenderTechnique::IsPointLightSuitable ( const Spheref object,
const AbstractRenderQueue::PointLight &  light 
)
inlinestaticprotected

Checks whether the point light is suitable for the computations.

Returns
true if light is close enough
Parameters
objectSphere symbolizing the object
lightLight to compute

◆ IsSpotLightSuitable()

bool Nz::ForwardRenderTechnique::IsSpotLightSuitable ( const Spheref object,
const AbstractRenderQueue::SpotLight &  light 
)
inlinestaticprotected

Checks whether the spot light is suitable for the computations.

Returns
true if light is close enough
Parameters
objectSphere symbolizing the object
lightLight to compute

TODO: Exclude spot lights based on their direction and outer angle?

◆ OnShaderInvalidated()

void Nz::ForwardRenderTechnique::OnShaderInvalidated ( const Shader *  shader) const
protected

Handle the invalidation of a shader.

Parameters
shaderShader being invalidated

◆ SendLightUniforms()

void Nz::ForwardRenderTechnique::SendLightUniforms ( const Shader *  shader,
const LightUniforms &  uniforms,
unsigned int  index,
unsigned int  lightIndex,
unsigned int  uniformOffset 
) const
protected

Sends the uniforms for light.

Parameters
shaderShader to send uniforms to
uniformsUniforms to send
indexIndex of the light
uniformOffsetOffset for the uniform
availableTextureUnitUnit texture available

◆ SetMaxLightPassPerObject()

void Nz::ForwardRenderTechnique::SetMaxLightPassPerObject ( unsigned int  maxLightPassPerObject)

Sets the maximum number of lights available per pass per object.

Parameters
passCountMaximum number of light simulatenously per object

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