Merge remote-tracking branch 'origin/Particle-Update'
Former-commit-id: 272203af1d740dc32e9714e00e4f889db6b13350
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
///TODO: Rendre les billboards via Deferred Shading si possible
|
||||
|
||||
namespace
|
||||
{
|
||||
enum ResourceType
|
||||
@@ -25,16 +27,49 @@ m_forwardQueue(forwardQueue)
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboard(const NzMaterial* material, const NzVector3f& position, const NzVector2f& size, const NzVector2f& sinCos, const NzColor& color)
|
||||
{
|
||||
///TODO: Rendre les billboards via Deferred Shading si possible
|
||||
m_forwardQueue->AddBillboard(material, position, size, sinCos, color);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
///TODO: Rendre les billboards via Deferred Shading si possible
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, colorPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, colorPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, alphaPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, colorPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, colorPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, alphaPtr);
|
||||
}
|
||||
|
||||
void NzDeferredRenderQueue::AddDrawable(const NzDrawable* drawable)
|
||||
{
|
||||
m_forwardQueue->AddDrawable(drawable);
|
||||
|
||||
@@ -72,6 +72,212 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
NzVector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||
|
||||
if (!sinCosPtr)
|
||||
sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
float defaultAlpha = 1.f;
|
||||
|
||||
if (!alphaPtr)
|
||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = NzColor(255, 255, 255, static_cast<nzUInt8>(255.f * (*alphaPtr++)));
|
||||
billboardData->sinCos = *sinCosPtr++;
|
||||
billboardData->size = *sizePtr++;
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
float defaultRotation = 0.f;
|
||||
|
||||
if (!anglePtr)
|
||||
anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
if (!colorPtr)
|
||||
colorPtr.Reset(&NzColor::White, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
float sin = std::sin(NzToRadians(*anglePtr));
|
||||
float cos = std::cos(NzToRadians(*anglePtr));
|
||||
anglePtr++;
|
||||
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = *colorPtr++;
|
||||
billboardData->sinCos.Set(sin, cos);
|
||||
billboardData->size = *sizePtr++;
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
float defaultRotation = 0.f;
|
||||
|
||||
if (!anglePtr)
|
||||
anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
float defaultAlpha = 1.f;
|
||||
|
||||
if (!alphaPtr)
|
||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
float sin = std::sin(NzToRadians(*anglePtr));
|
||||
float cos = std::cos(NzToRadians(*anglePtr));
|
||||
anglePtr++;
|
||||
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = NzColor(255, 255, 255, static_cast<nzUInt8>(255.f * (*alphaPtr++)));
|
||||
billboardData->sinCos.Set(sin, cos);
|
||||
billboardData->size = *sizePtr++;
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
NzVector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||
|
||||
if (!sinCosPtr)
|
||||
sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
if (!colorPtr)
|
||||
colorPtr.Reset(&NzColor::White, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = *colorPtr++;
|
||||
billboardData->sinCos = *sinCosPtr++;
|
||||
billboardData->size.Set(*sizePtr++);
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
NzVector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||
|
||||
if (!sinCosPtr)
|
||||
sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
float defaultAlpha = 1.f;
|
||||
|
||||
if (!alphaPtr)
|
||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = NzColor(255, 255, 255, static_cast<nzUInt8>(255.f * (*alphaPtr++)));
|
||||
billboardData->sinCos = *sinCosPtr++;
|
||||
billboardData->size.Set(*sizePtr++);
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
float defaultRotation = 0.f;
|
||||
|
||||
if (!anglePtr)
|
||||
anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
if (!colorPtr)
|
||||
colorPtr.Reset(&NzColor::White, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
float sin = std::sin(NzToRadians(*anglePtr));
|
||||
float cos = std::cos(NzToRadians(*anglePtr));
|
||||
anglePtr++;
|
||||
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = *colorPtr++;
|
||||
billboardData->sinCos.Set(sin, cos);
|
||||
billboardData->size.Set(*sizePtr++);
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr)
|
||||
{
|
||||
///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White
|
||||
float defaultRotation = 0.f;
|
||||
|
||||
if (!anglePtr)
|
||||
anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile
|
||||
|
||||
float defaultAlpha = 1.f;
|
||||
|
||||
if (!alphaPtr)
|
||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||
|
||||
std::vector<BillboardData>& billboardVec = billboards[material];
|
||||
unsigned int prevSize = billboardVec.size();
|
||||
billboardVec.resize(prevSize + count);
|
||||
|
||||
BillboardData* billboardData = &billboardVec[prevSize];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
float sin = std::sin(NzToRadians(*anglePtr));
|
||||
float cos = std::cos(NzToRadians(*anglePtr));
|
||||
anglePtr++;
|
||||
|
||||
billboardData->center = *positionPtr++;
|
||||
billboardData->color = NzColor(255, 255, 255, static_cast<nzUInt8>(255.f * (*alphaPtr++)));
|
||||
billboardData->sinCos.Set(sin, cos);
|
||||
billboardData->size.Set(*sizePtr++);
|
||||
billboardData++;
|
||||
}
|
||||
}
|
||||
|
||||
void NzForwardRenderQueue::AddDrawable(const NzDrawable* drawable)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -231,7 +437,7 @@ void NzForwardRenderQueue::Sort(const NzAbstractViewer* viewer)
|
||||
{
|
||||
const NzMaterial* mat = pair.first;
|
||||
|
||||
if (mat->IsEnabled(nzRendererParameter_Blend))
|
||||
if (mat->IsDepthSortingEnabled())
|
||||
{
|
||||
BatchedBillboardEntry& entry = pair.second;
|
||||
auto& billboardVector = entry.billboards;
|
||||
|
||||
@@ -138,6 +138,11 @@ void NzMaterial::EnableAlphaTest(bool alphaTest)
|
||||
InvalidateShaders();
|
||||
}
|
||||
|
||||
void NzMaterial::EnableDepthSorting(bool depthSorting)
|
||||
{
|
||||
m_depthSortingEnabled = depthSorting;
|
||||
}
|
||||
|
||||
void NzMaterial::EnableLighting(bool lighting)
|
||||
{
|
||||
m_lightingEnabled = lighting;
|
||||
@@ -306,6 +311,11 @@ bool NzMaterial::IsAlphaTestEnabled() const
|
||||
return m_alphaTestEnabled;
|
||||
}
|
||||
|
||||
bool NzMaterial::IsDepthSortingEnabled() const
|
||||
{
|
||||
return m_depthSortingEnabled;
|
||||
}
|
||||
|
||||
bool NzMaterial::IsEnabled(nzRendererParameter parameter) const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -362,6 +372,7 @@ void NzMaterial::Reset()
|
||||
m_alphaThreshold = 0.2f;
|
||||
m_alphaTestEnabled = false;
|
||||
m_ambientColor = NzColor(128, 128, 128);
|
||||
m_depthSortingEnabled = false;
|
||||
m_diffuseColor = NzColor::White;
|
||||
m_diffuseSampler = NzTextureSampler();
|
||||
m_lightingEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user