Graphics/Light: Change the way lights are queued
Former-commit-id: 18cf919c3b221425624a4db15c59699abfba6fc7
This commit is contained in:
parent
a92a58301a
commit
367ec18217
|
|
@ -25,6 +25,10 @@ struct NzMeshData;
|
||||||
class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct DirectionalLight;
|
||||||
|
struct PointLight;
|
||||||
|
struct SpotLight;
|
||||||
|
|
||||||
NzAbstractRenderQueue() = default;
|
NzAbstractRenderQueue() = default;
|
||||||
virtual ~NzAbstractRenderQueue();
|
virtual ~NzAbstractRenderQueue();
|
||||||
|
|
||||||
|
|
@ -40,14 +44,15 @@ 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 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 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 AddDrawable(const NzDrawable* drawable) = 0;
|
||||||
virtual void AddDirectionalLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& direction);
|
virtual void AddDirectionalLight(const DirectionalLight& light);
|
||||||
virtual void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) = 0;
|
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 AddPointLight(const PointLight& light);
|
||||||
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 AddSpotLight(const SpotLight& light);
|
||||||
virtual void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) = 0;
|
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);
|
virtual void Clear(bool fully);
|
||||||
|
|
||||||
|
|
||||||
struct DirectionalLight
|
struct DirectionalLight
|
||||||
{
|
{
|
||||||
NzColor color;
|
NzColor color;
|
||||||
|
|
@ -63,6 +68,7 @@ class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||||
float ambientFactor;
|
float ambientFactor;
|
||||||
float attenuation;
|
float attenuation;
|
||||||
float diffuseFactor;
|
float diffuseFactor;
|
||||||
|
float invRadius;
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -74,8 +80,10 @@ class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||||
float ambientFactor;
|
float ambientFactor;
|
||||||
float attenuation;
|
float attenuation;
|
||||||
float diffuseFactor;
|
float diffuseFactor;
|
||||||
float innerAngle;
|
float innerAngleCosine;
|
||||||
float outerAngle;
|
float invRadius;
|
||||||
|
float outerAngleCosine;
|
||||||
|
float outerAngleTangent;
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,19 @@
|
||||||
|
|
||||||
NzAbstractRenderQueue::~NzAbstractRenderQueue() = default;
|
NzAbstractRenderQueue::~NzAbstractRenderQueue() = default;
|
||||||
|
|
||||||
void NzAbstractRenderQueue::AddDirectionalLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& direction)
|
void NzAbstractRenderQueue::AddDirectionalLight(const DirectionalLight& light)
|
||||||
{
|
{
|
||||||
directionalLights.push_back(DirectionalLight{color, direction, ambientFactor, diffuseFactor});
|
directionalLights.push_back(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzAbstractRenderQueue::AddPointLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& position, float radius, float attenuation)
|
void NzAbstractRenderQueue::AddPointLight(const PointLight& light)
|
||||||
{
|
{
|
||||||
pointLights.push_back(PointLight{color, position, ambientFactor, attenuation, diffuseFactor, radius});
|
pointLights.push_back(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzAbstractRenderQueue::AddSpotLight(const NzColor& color, float ambientFactor, float diffuseFactor, const NzVector3f& position, const NzVector3f& direction, float radius, float attenuation, float innerAngle, float outerAngle)
|
void NzAbstractRenderQueue::AddSpotLight(const SpotLight& light)
|
||||||
{
|
{
|
||||||
spotLights.push_back(SpotLight{color, direction, position, ambientFactor, attenuation, diffuseFactor, innerAngle, outerAngle, radius});
|
spotLights.push_back(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzAbstractRenderQueue::Clear(bool fully)
|
void NzAbstractRenderQueue::Clear(bool fully)
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,50 @@ void NzLight::AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatri
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case nzLightType_Directional:
|
case nzLightType_Directional:
|
||||||
renderQueue->AddDirectionalLight(m_color, m_ambientFactor, m_diffuseFactor, transformMatrix.Transform(NzVector3f::Forward(), 0.f));
|
{
|
||||||
|
NzAbstractRenderQueue::DirectionalLight light;
|
||||||
|
light.ambientFactor = m_ambientFactor;
|
||||||
|
light.color = m_color;
|
||||||
|
light.diffuseFactor = m_diffuseFactor;
|
||||||
|
light.direction = transformMatrix.Transform(NzVector3f::Forward(), 0.f);
|
||||||
|
|
||||||
|
renderQueue->AddDirectionalLight(light);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case nzLightType_Point:
|
case nzLightType_Point:
|
||||||
renderQueue->AddPointLight(m_color, m_ambientFactor, m_diffuseFactor, transformMatrix.GetTranslation(), m_radius, m_attenuation);
|
{
|
||||||
|
NzAbstractRenderQueue::PointLight light;
|
||||||
|
light.ambientFactor = m_ambientFactor;
|
||||||
|
light.attenuation = m_attenuation;
|
||||||
|
light.color = m_color;
|
||||||
|
light.diffuseFactor = m_diffuseFactor;
|
||||||
|
light.invRadius = m_invRadius;
|
||||||
|
light.position = transformMatrix.GetTranslation();
|
||||||
|
light.radius = m_radius;
|
||||||
|
|
||||||
|
renderQueue->AddPointLight(light);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case nzLightType_Spot:
|
case nzLightType_Spot:
|
||||||
renderQueue->AddSpotLight(m_color, m_ambientFactor, m_diffuseFactor, transformMatrix.GetTranslation(), transformMatrix.Transform(NzVector3f::Forward(), 0.f), m_radius, m_attenuation, m_innerAngle, m_outerAngle);
|
{
|
||||||
|
NzAbstractRenderQueue::SpotLight light;
|
||||||
|
light.ambientFactor = m_ambientFactor;
|
||||||
|
light.attenuation = m_attenuation;
|
||||||
|
light.color = m_color;
|
||||||
|
light.diffuseFactor = m_diffuseFactor;
|
||||||
|
light.direction = transformMatrix.Transform(NzVector3f::Forward(), 0.f);
|
||||||
|
light.innerAngleCosine = m_innerAngleCosine;
|
||||||
|
light.invRadius = m_invRadius;
|
||||||
|
light.outerAngleCosine = m_outerAngleCosine;
|
||||||
|
light.outerAngleTangent = m_outerAngleTangent;
|
||||||
|
light.position = transformMatrix.GetTranslation();
|
||||||
|
light.radius = m_radius;
|
||||||
|
|
||||||
|
renderQueue->AddSpotLight(light);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NazaraError("Invalid light type (0x" + NzString::Number(m_type, 16) + ')');
|
NazaraError("Invalid light type (0x" + NzString::Number(m_type, 16) + ')');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue