Graphics/RenderQueue: Replace AddLight method by variations
Former-commit-id: 79ad49d60bd8d397aa606cded7c0dd2d20a078dc
This commit is contained in:
parent
3f501ec06f
commit
b075d05d82
|
|
@ -15,11 +15,10 @@
|
|||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NzDrawable;
|
||||
class NzLight;
|
||||
class NzMaterial;
|
||||
class NzSprite;
|
||||
class NzTexture;
|
||||
struct NzMeshData;
|
||||
|
||||
|
|
@ -41,11 +40,49 @@ class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
|||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddDrawable(const NzDrawable* drawable) = 0;
|
||||
virtual void AddLight(const NzLight* light) = 0;
|
||||
virtual void AddDirectionalLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& direction);
|
||||
virtual void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) = 0;
|
||||
virtual void AddPointLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& position, float radius, float attenuation);
|
||||
virtual void AddSpotLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& position, const NzVector3f& direction, float radius, float attenuation, float innerAngle, float outerAngle);
|
||||
virtual void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) = 0;
|
||||
|
||||
virtual void Clear(bool fully) = 0;
|
||||
virtual void Clear(bool fully);
|
||||
|
||||
protected:
|
||||
struct DirectionalLight
|
||||
{
|
||||
NzColor color;
|
||||
NzVector3f direction;
|
||||
float ambientFactor;
|
||||
float diffuseFactor;
|
||||
};
|
||||
|
||||
struct PointLight
|
||||
{
|
||||
NzColor color;
|
||||
NzVector3f position;
|
||||
float ambientFactor;
|
||||
float attenuation;
|
||||
float diffuseFactor;
|
||||
float radius;
|
||||
};
|
||||
|
||||
struct SpotLight
|
||||
{
|
||||
NzColor color;
|
||||
NzVector3f direction;
|
||||
NzVector3f position;
|
||||
float ambientFactor;
|
||||
float attenuation;
|
||||
float diffuseFactor;
|
||||
float innerAngle;
|
||||
float outerAngle;
|
||||
float radius;
|
||||
};
|
||||
|
||||
std::vector<DirectionalLight> m_directionalLights;
|
||||
std::vector<PointLight> m_pointLights;
|
||||
std::vector<SpotLight> m_spotLights;
|
||||
};
|
||||
|
||||
#endif // NAZARA_ABSTRACTRENDERQUEUE_HPP
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ class NAZARA_API NzDeferredRenderQueue : public NzAbstractRenderQueue, NzObjectL
|
|||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) override;
|
||||
|
||||
|
|
@ -83,12 +82,8 @@ class NAZARA_API NzDeferredRenderQueue : public NzAbstractRenderQueue, NzObjectL
|
|||
};
|
||||
|
||||
typedef std::map<const NzMaterial*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
|
||||
typedef std::vector<const NzLight*> LightContainer;
|
||||
|
||||
ModelBatches opaqueModels;
|
||||
LightContainer directionalLights;
|
||||
LightContainer pointLights;
|
||||
LightContainer spotLights;
|
||||
NzForwardRenderQueue* m_forwardQueue;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzObjectLi
|
|||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) override;
|
||||
|
||||
|
|
@ -168,7 +167,6 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzObjectLi
|
|||
const NzMaterial* material;
|
||||
};
|
||||
|
||||
typedef std::vector<const NzLight*> LightContainer;
|
||||
typedef std::vector<unsigned int> TransparentModelContainer;
|
||||
|
||||
BatchedBillboardContainer billboards;
|
||||
|
|
@ -177,8 +175,6 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzObjectLi
|
|||
TransparentModelContainer transparentModels;
|
||||
std::vector<TransparentModelData> transparentModelData;
|
||||
std::vector<const NzDrawable*> otherDrawables;
|
||||
LightContainer directionalLights;
|
||||
LightContainer lights;
|
||||
};
|
||||
|
||||
#endif // NAZARA_FORWARDRENDERQUEUE_HPP
|
||||
|
|
|
|||
|
|
@ -6,3 +6,25 @@
|
|||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
NzAbstractRenderQueue::~NzAbstractRenderQueue() = default;
|
||||
|
||||
void NzAbstractRenderQueue::AddDirectionalLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& direction)
|
||||
{
|
||||
m_directionalLights.push_back(DirectionalLight{color, direction, ambientFactor, diffuseFactor});
|
||||
}
|
||||
|
||||
void NzAbstractRenderQueue::AddPointLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& position, float radius, float attenuation)
|
||||
{
|
||||
m_pointLights.push_back(PointLight{color, position, ambientFactor, attenuation, diffuseFactor, radius});
|
||||
}
|
||||
|
||||
void NzAbstractRenderQueue::AddSpotLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& position, const NzVector3f& direction, float radius, float attenuation, float innerAngle, float outerAngle)
|
||||
{
|
||||
m_spotLights.push_back(SpotLight{color, direction, position, ambientFactor, attenuation, diffuseFactor, innerAngle, outerAngle, radius});
|
||||
}
|
||||
|
||||
void NzAbstractRenderQueue::Clear(bool fully)
|
||||
{
|
||||
m_directionalLights.clear();
|
||||
m_pointLights.clear();
|
||||
m_spotLights.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,37 +75,6 @@ void NzDeferredRenderQueue::AddDrawable(const NzDrawable* drawable)
|
|||
m_forwardQueue->AddDrawable(drawable);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddLight(const NzLight* light)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!light)
|
||||
{
|
||||
NazaraError("Invalid light");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// On trie la lumière (elles sont traitées différement selon leur type)
|
||||
switch (light->GetLightType())
|
||||
{
|
||||
case nzLightType_Directional:
|
||||
directionalLights.push_back(light);
|
||||
break;
|
||||
|
||||
case nzLightType_Point:
|
||||
pointLights.push_back(light);
|
||||
break;
|
||||
|
||||
case nzLightType_Spot:
|
||||
spotLights.push_back(light);
|
||||
break;
|
||||
}
|
||||
|
||||
// On envoie également la lumière au forward-shading
|
||||
///TODO: Possibilité pour une lumière de se réserver au Deferred Shading
|
||||
m_forwardQueue->AddLight(light);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix)
|
||||
{
|
||||
if (material->IsEnabled(nzRendererParameter_Blend))
|
||||
|
|
@ -154,9 +123,7 @@ void NzDeferredRenderQueue::AddSprites(const NzMaterial* material, const NzVerte
|
|||
|
||||
void NzDeferredRenderQueue::Clear(bool fully)
|
||||
{
|
||||
directionalLights.clear();
|
||||
pointLights.clear();
|
||||
spotLights.clear();
|
||||
NzAbstractRenderQueue::Clear(fully);
|
||||
|
||||
if (fully)
|
||||
opaqueModels.clear();
|
||||
|
|
|
|||
|
|
@ -370,34 +370,6 @@ void NzForwardRenderQueue::AddDrawable(const NzDrawable* drawable)
|
|||
otherDrawables.push_back(drawable);
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddLight(const NzLight* light)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!light)
|
||||
{
|
||||
NazaraError("Invalid light");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (light->GetLightType())
|
||||
{
|
||||
case nzLightType_Directional:
|
||||
directionalLights.push_back(light);
|
||||
break;
|
||||
|
||||
case nzLightType_Point:
|
||||
case nzLightType_Spot:
|
||||
lights.push_back(light);
|
||||
break;
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
default:
|
||||
NazaraError("Light type not handled (0x" + NzString::Number(light->GetLightType(), 16) + ')');
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix)
|
||||
{
|
||||
if (material->IsEnabled(nzRendererParameter_Blend))
|
||||
|
|
@ -481,8 +453,8 @@ void NzForwardRenderQueue::AddSprites(const NzMaterial* material, const NzVertex
|
|||
|
||||
void NzForwardRenderQueue::Clear(bool fully)
|
||||
{
|
||||
directionalLights.clear();
|
||||
lights.clear();
|
||||
NzAbstractRenderQueue::Clear(fully);
|
||||
|
||||
otherDrawables.clear();
|
||||
transparentModels.clear();
|
||||
transparentModelData.clear();
|
||||
|
|
|
|||
Loading…
Reference in New Issue