|
@@ -33,20 +33,14 @@
|
|
|
#include "BsLight.h"
|
|
#include "BsLight.h"
|
|
|
#include "BsRenderTexturePool.h"
|
|
#include "BsRenderTexturePool.h"
|
|
|
#include "BsRenderTargets.h"
|
|
#include "BsRenderTargets.h"
|
|
|
-#include "BsLightRendering.h"
|
|
|
|
|
|
|
|
|
|
using namespace std::placeholders;
|
|
using namespace std::placeholders;
|
|
|
|
|
|
|
|
namespace BansheeEngine
|
|
namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
- /** Basic shader that is used when no other is available. */
|
|
|
|
|
- class DefaultMaterial : public RendererMaterial<DefaultMaterial> { RMAT_DEF("Default.bsl"); };
|
|
|
|
|
-
|
|
|
|
|
- /** Basic shader that is used when no other is available, and the rendered mesh has no normal information. */
|
|
|
|
|
- class DefaultMaterialNoNormal : public RendererMaterial<DefaultMaterialNoNormal> { RMAT_DEF("DefaultNoNormal.bsl"); };
|
|
|
|
|
-
|
|
|
|
|
RenderBeast::RenderBeast()
|
|
RenderBeast::RenderBeast()
|
|
|
- :mOptions(bs_shared_ptr_new<RenderBeastOptions>()), mOptionsDirty(true), mStaticHandler(nullptr)
|
|
|
|
|
|
|
+ :mOptions(bs_shared_ptr_new<RenderBeastOptions>()), mOptionsDirty(true), mStaticHandler(nullptr),
|
|
|
|
|
+ mDefaultMaterial(nullptr), mDefaultNoNormalMaterial(nullptr), mPointLightMat(nullptr), mDirLightMat(nullptr)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -61,7 +55,7 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
CoreRenderer::_onActivated();
|
|
CoreRenderer::_onActivated();
|
|
|
|
|
|
|
|
- gCoreAccessor().queueCommand(std::bind(&RenderBeast::initializeCore, this));
|
|
|
|
|
|
|
+ gCoreThread().queueCommand(std::bind(&RenderBeast::initializeCore, this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void RenderBeast::_onDeactivated()
|
|
void RenderBeast::_onDeactivated()
|
|
@@ -77,6 +71,11 @@ namespace BansheeEngine
|
|
|
mCoreOptions = bs_shared_ptr_new<RenderBeastOptions>();
|
|
mCoreOptions = bs_shared_ptr_new<RenderBeastOptions>();
|
|
|
mStaticHandler = bs_new<StaticRenderableHandler>();
|
|
mStaticHandler = bs_new<StaticRenderableHandler>();
|
|
|
|
|
|
|
|
|
|
+ mDefaultMaterial = bs_new<DefaultMaterial>();
|
|
|
|
|
+ mDefaultNoNormalMaterial = bs_new<DefaultMaterialNoNormal>();
|
|
|
|
|
+ mPointLightMat = bs_new<PointLightMat>();
|
|
|
|
|
+ mDirLightMat = bs_new<DirectionalLightMat>();
|
|
|
|
|
+
|
|
|
RenderTexturePool::startUp();
|
|
RenderTexturePool::startUp();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -91,6 +90,11 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
RenderTexturePool::shutDown();
|
|
RenderTexturePool::shutDown();
|
|
|
|
|
|
|
|
|
|
+ bs_delete(mDefaultMaterial);
|
|
|
|
|
+ bs_delete(mDefaultNoNormalMaterial);
|
|
|
|
|
+ bs_delete(mPointLightMat);
|
|
|
|
|
+ bs_delete(mDirLightMat);
|
|
|
|
|
+
|
|
|
assert(mSamplerOverrides.empty());
|
|
assert(mSamplerOverrides.empty());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -142,9 +146,9 @@ namespace BansheeEngine
|
|
|
const VertexDeclarationProperties& vertexProps = vertexData->vertexDeclaration->getProperties();
|
|
const VertexDeclarationProperties& vertexProps = vertexData->vertexDeclaration->getProperties();
|
|
|
|
|
|
|
|
if (vertexProps.findElementBySemantic(VES_NORMAL))
|
|
if (vertexProps.findElementBySemantic(VES_NORMAL))
|
|
|
- renElement.material = DefaultMaterial::instance.getMaterial();
|
|
|
|
|
|
|
+ renElement.material = mDefaultMaterial->getMaterial();
|
|
|
else
|
|
else
|
|
|
- renElement.material = DefaultMaterialNoNormal::instance.getMaterial();
|
|
|
|
|
|
|
+ renElement.material = mDefaultNoNormalMaterial->getMaterial();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
auto iterFind = mSamplerOverrides.find(renElement.material);
|
|
auto iterFind = mSamplerOverrides.find(renElement.material);
|
|
@@ -588,7 +592,7 @@ namespace BansheeEngine
|
|
|
// Render lights and resolve gbuffer if there is one
|
|
// Render lights and resolve gbuffer if there is one
|
|
|
if (hasGBuffer)
|
|
if (hasGBuffer)
|
|
|
{
|
|
{
|
|
|
- SPtr<MaterialCore> dirMaterial = DirectionalLightMat::instance.getMaterial();
|
|
|
|
|
|
|
+ SPtr<MaterialCore> dirMaterial = mDirLightMat->getMaterial();
|
|
|
SPtr<PassCore> dirPass = dirMaterial->getPass(0);
|
|
SPtr<PassCore> dirPass = dirMaterial->getPass(0);
|
|
|
|
|
|
|
|
setPass(dirPass);
|
|
setPass(dirPass);
|
|
@@ -598,7 +602,7 @@ namespace BansheeEngine
|
|
|
if (!light.internal->getIsActive())
|
|
if (!light.internal->getIsActive())
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
- DirectionalLightMat::instance.setParameters(light.internal);
|
|
|
|
|
|
|
+ mDirLightMat->setParameters(light.internal);
|
|
|
|
|
|
|
|
SPtr<MeshCore> mesh = nullptr; // TODO - Get full screen quad
|
|
SPtr<MeshCore> mesh = nullptr; // TODO - Get full screen quad
|
|
|
draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
@@ -610,7 +614,7 @@ namespace BansheeEngine
|
|
|
if (!light.internal->getIsActive())
|
|
if (!light.internal->getIsActive())
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
- PointLightMat::instance.setParameters(light.internal);
|
|
|
|
|
|
|
+ mPointLightMat->setParameters(light.internal);
|
|
|
|
|
|
|
|
SPtr<MeshCore> mesh = light.internal->getMesh();
|
|
SPtr<MeshCore> mesh = light.internal->getMesh();
|
|
|
draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
draw(mesh, mesh->getProperties().getSubMesh(0));
|