added support for user stencil buffer tagging;
added renderable3dcomponent depthbuffer query;
This commit is contained in:
@@ -287,6 +287,11 @@ wiRenderTarget& DeferredRenderableComponent::GetFinalRT()
|
||||
return rtDeferred;
|
||||
}
|
||||
|
||||
wiDepthTarget* DeferredRenderableComponent::GetDepthBuffer()
|
||||
{
|
||||
return rtGBuffer.depth;
|
||||
}
|
||||
|
||||
void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short value)
|
||||
{
|
||||
Renderable3DComponent::setPreferredThreadingCount(value);
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
DeferredRenderableComponent();
|
||||
virtual ~DeferredRenderableComponent();
|
||||
|
||||
virtual wiDepthTarget* GetDepthBuffer() override;
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value) override;
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
+10
-13
@@ -182,6 +182,13 @@ void ClearSelected()
|
||||
savedParents.clear();
|
||||
}
|
||||
|
||||
enum EDITORSTENCILREF
|
||||
{
|
||||
EDITORSTENCILREF_CLEAR = 0x00,
|
||||
EDITORSTENCILREF_HIGHLIGHT = 0x01,
|
||||
EDITORSTENCILREF_LAST = 0x0F,
|
||||
};
|
||||
|
||||
|
||||
wiArchive *clipboard_write = nullptr, *clipboard_read = nullptr;
|
||||
enum ClipboardItemType
|
||||
@@ -880,6 +887,8 @@ void EditorComponent::Update(float dt)
|
||||
Material* material = picked->object->mesh->subsets[picked->subsetIndex].material;
|
||||
|
||||
materialWnd->SetMaterial(material);
|
||||
|
||||
material->SetUserStencilRef(EDITORSTENCILREF_HIGHLIGHT);
|
||||
}
|
||||
if (picked->object->isArmatureDeformed())
|
||||
{
|
||||
@@ -1219,19 +1228,7 @@ void EditorComponent::Compose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// Test Halton sequence:
|
||||
//for (int i = 0; i < 64; ++i)
|
||||
//{
|
||||
// const XMFLOAT4& halton = wiMath::GetHaltonSequence(i);
|
||||
// wiImageEffects fx = wiImageEffects();
|
||||
// fx.pos.x = halton.x * wiRenderer::GetDevice()->GetScreenWidth();
|
||||
// fx.pos.y = halton.y * wiRenderer::GetDevice()->GetScreenHeight();
|
||||
// fx.siz = XMFLOAT2(10, 10);
|
||||
// fx.pivot = XMFLOAT2(0.5f, 0.5f);
|
||||
// fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
// wiImage::Draw(wiTextureHelper::getInstance()->getWhite(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
//}
|
||||
//wiImage::Draw(GetDepthBuffer()->GetTexture(), wiImageEffects(0, 0, 400, 200), GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
}
|
||||
void EditorComponent::Unload()
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
|
||||
class Editor;
|
||||
class EditorComponent
|
||||
//: public DeferredRenderableComponent
|
||||
: public DeferredRenderableComponent
|
||||
//: public ForwardRenderableComponent
|
||||
: public TiledForwardRenderableComponent
|
||||
//: public TiledForwardRenderableComponent
|
||||
{
|
||||
private:
|
||||
wiGraphicsTypes::Texture2D pointLightTex, spotLightTex, dirLightTex, areaLightTex;
|
||||
|
||||
@@ -127,6 +127,10 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiProfiler::GetInstance().EndRange(); // Opaque Scene
|
||||
}
|
||||
|
||||
wiDepthTarget* ForwardRenderableComponent::GetDepthBuffer()
|
||||
{
|
||||
return rtMain.depth;
|
||||
}
|
||||
|
||||
void ForwardRenderableComponent::setPreferredThreadingCount(unsigned short value)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@ public:
|
||||
ForwardRenderableComponent();
|
||||
virtual ~ForwardRenderableComponent();
|
||||
|
||||
virtual wiDepthTarget* GetDepthBuffer() override;
|
||||
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value) override;
|
||||
|
||||
|
||||
@@ -409,6 +409,11 @@ MaterialWindow::~MaterialWindow()
|
||||
|
||||
void MaterialWindow::SetMaterial(Material* mat)
|
||||
{
|
||||
if (material != nullptr)
|
||||
{
|
||||
material->SetUserStencilRef(0);
|
||||
}
|
||||
|
||||
material = mat;
|
||||
if (material != nullptr)
|
||||
{
|
||||
|
||||
@@ -80,6 +80,8 @@ protected:
|
||||
virtual void RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarget& mainRT, GRAPHICSTHREAD threadID);
|
||||
virtual void RenderColorGradedComposition();
|
||||
public:
|
||||
virtual wiDepthTarget* GetDepthBuffer() = 0;
|
||||
|
||||
inline float getLightShaftQuality(){ return lightShaftQuality; }
|
||||
inline float getBloomDownSample(){ return bloomDownSample; }
|
||||
inline float getBloomStrength(){ return bloomStren; }
|
||||
|
||||
+10
-10
@@ -12,16 +12,16 @@ enum GRAPHICSTHREAD
|
||||
GRAPHICSTHREAD_COUNT
|
||||
};
|
||||
|
||||
// Do not alter order because it is bound to lua manually
|
||||
// Do not alter order or value because it is bound to lua manually!
|
||||
enum RENDERTYPE
|
||||
{
|
||||
RENDERTYPE_VOID = 0x0000000,
|
||||
RENDERTYPE_OPAQUE = 0x0000001,
|
||||
RENDERTYPE_TRANSPARENT = 0x0000010,
|
||||
RENDERTYPE_WATER = 0x0000100,
|
||||
RENDERTYPE_LIGHT = 0x0001000,
|
||||
RENDERTYPE_DECAL = 0x0010000,
|
||||
RENDERTYPE_ENVPROBE = 0x0100000,
|
||||
RENDERTYPE_VOID = 0,
|
||||
RENDERTYPE_OPAQUE = 1,
|
||||
RENDERTYPE_TRANSPARENT = 2,
|
||||
RENDERTYPE_WATER = 4,
|
||||
RENDERTYPE_LIGHT = 8,
|
||||
RENDERTYPE_DECAL = 16,
|
||||
RENDERTYPE_ENVPROBE = 32,
|
||||
};
|
||||
enum PICKTYPE
|
||||
{
|
||||
@@ -48,7 +48,7 @@ enum SHADERTYPE
|
||||
SHADERTYPE_COUNT
|
||||
};
|
||||
|
||||
// stencils
|
||||
// engine stencil reference values. These can be in range of 0-127. 128-255 are for user stencil values.
|
||||
enum STENCILREF {
|
||||
STENCILREF_EMPTY = 0x00,
|
||||
STENCILREF_SKY = 0x01,
|
||||
@@ -57,7 +57,7 @@ enum STENCILREF {
|
||||
STENCILREF_CHARACTER = 0x04,
|
||||
STENCILREF_SHADELESS = 0x05,
|
||||
STENCILREF_SKIN = 0x06,
|
||||
STENCILREF_LAST = 0xFF
|
||||
STENCILREF_LAST = 0x0F
|
||||
};
|
||||
|
||||
// constant buffers
|
||||
|
||||
@@ -1402,6 +1402,9 @@ void Material::init()
|
||||
|
||||
alphaRef = 1.0f; // no alpha test by default
|
||||
|
||||
engineStencilRef = STENCILREF::STENCILREF_DEFAULT;
|
||||
userStencilRef = 0x00;
|
||||
|
||||
|
||||
// constant buffer creation
|
||||
GPUBufferDesc bd;
|
||||
@@ -2453,7 +2456,7 @@ void Mesh::Serialize(wiArchive& archive)
|
||||
archive >> doubleSided;
|
||||
int temp;
|
||||
archive >> temp;
|
||||
stencilRef = (STENCILREF)temp;
|
||||
//engineStencilRef = (STENCILREF)temp;
|
||||
archive >> calculatedAO;
|
||||
archive >> trailInfo.base;
|
||||
archive >> trailInfo.tip;
|
||||
@@ -2546,7 +2549,7 @@ void Mesh::Serialize(wiArchive& archive)
|
||||
}
|
||||
archive << renderable;
|
||||
archive << doubleSided;
|
||||
archive << (int)stencilRef;
|
||||
archive << (int)0/*engineStencilRef*/;
|
||||
archive << calculatedAO;
|
||||
archive << trailInfo.base;
|
||||
archive << trailInfo.tip;
|
||||
|
||||
+13
-2
@@ -220,6 +220,9 @@ struct Material
|
||||
|
||||
float alphaRef;
|
||||
|
||||
STENCILREF engineStencilRef;
|
||||
uint8_t userStencilRef;
|
||||
|
||||
|
||||
Material()
|
||||
{
|
||||
@@ -246,6 +249,16 @@ struct Material
|
||||
return RENDERTYPE_OPAQUE;
|
||||
}
|
||||
void ConvertToPhysicallyBasedMaterial();
|
||||
// User stencil ref could be anything from 0-127, greater will be truncated when using 8 bit stencil buffer!
|
||||
void SetUserStencilRef(uint8_t value)
|
||||
{
|
||||
assert(value < 128);
|
||||
userStencilRef = value;
|
||||
}
|
||||
UINT GetStencilRef()
|
||||
{
|
||||
return (userStencilRef << 4) | static_cast<uint8_t>(engineStencilRef);
|
||||
}
|
||||
const wiGraphicsTypes::Texture2D* GetBaseColorMap() const;
|
||||
const wiGraphicsTypes::Texture2D* GetNormalMap() const;
|
||||
const wiGraphicsTypes::Texture2D* GetRoughnessMap() const;
|
||||
@@ -328,7 +341,6 @@ public:
|
||||
wiGraphicsTypes::GPUBuffer instanceBufferPrev;
|
||||
|
||||
bool renderable,doubleSided;
|
||||
STENCILREF stencilRef;
|
||||
|
||||
bool calculatedAO;
|
||||
|
||||
@@ -384,7 +396,6 @@ public:
|
||||
indices.resize(0);
|
||||
renderable=false;
|
||||
doubleSided=false;
|
||||
stencilRef = STENCILREF::STENCILREF_DEFAULT;
|
||||
aabb=AABB();
|
||||
trailInfo=RibbonTrail();
|
||||
armature=nullptr;
|
||||
|
||||
@@ -4294,14 +4294,15 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
device->BindIndexBuffer(&subset.indexBuffer, subset.GetIndexFormat(), threadID);
|
||||
device->BindConstantBufferPS(&material->constantBuffer, CB_GETBINDSLOT(Material::MaterialCB), threadID);
|
||||
|
||||
UINT realStencilRef = mesh->stencilRef;
|
||||
UINT realStencilRef = material->GetStencilRef();
|
||||
// todo: better
|
||||
if (material->shadeless)
|
||||
{
|
||||
realStencilRef = STENCILREF_SHADELESS;
|
||||
realStencilRef = (material->userStencilRef << 4) | STENCILREF_SHADELESS;
|
||||
}
|
||||
else if (material->subsurfaceScattering > 0)
|
||||
{
|
||||
realStencilRef = STENCILREF_SKIN;
|
||||
realStencilRef = (material->userStencilRef << 4) | STENCILREF_SKIN;
|
||||
}
|
||||
if (prevStencilRef != realStencilRef)
|
||||
{
|
||||
@@ -5983,7 +5984,7 @@ void wiRenderer::CreateImpostor(Mesh* mesh)
|
||||
|
||||
GetDevice()->BindBlendState(blendStates[BSTYPE_OPAQUE], threadID);
|
||||
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_DOUBLESIDED], threadID);
|
||||
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEFAULT], mesh->stencilRef, threadID);
|
||||
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEFAULT], 0, threadID);
|
||||
GetDevice()->BindPrimitiveTopology(TRIANGLELIST, threadID);
|
||||
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_OBJECT_ALL], threadID);
|
||||
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT_COMMON], threadID);
|
||||
|
||||
@@ -713,10 +713,13 @@ namespace wiRenderer_BindLua
|
||||
wiLua::GetGlobal()->RegisterFunc("PutEnvProbe", PutEnvProbe);
|
||||
|
||||
|
||||
wiLua::GetGlobal()->RunText("PICK_VOID = 0x0000000");
|
||||
wiLua::GetGlobal()->RunText("PICK_OPAQUE = 0x0000001");
|
||||
wiLua::GetGlobal()->RunText("PICK_TRANSPARENT = 0x0000010");
|
||||
wiLua::GetGlobal()->RunText("PICK_WATER = 0x0000100");
|
||||
wiLua::GetGlobal()->RunText("PICK_VOID = 0");
|
||||
wiLua::GetGlobal()->RunText("PICK_OPAQUE = 1");
|
||||
wiLua::GetGlobal()->RunText("PICK_TRANSPARENT = 2");
|
||||
wiLua::GetGlobal()->RunText("PICK_WATER = 4");
|
||||
wiLua::GetGlobal()->RunText("PICK_LIGHT = 8");
|
||||
wiLua::GetGlobal()->RunText("PICK_DECAL = 16");
|
||||
wiLua::GetGlobal()->RunText("PICK_ENVPROBE = 32");
|
||||
|
||||
|
||||
wiLua::GetGlobal()->RegisterFunc("ClearWorld", ClearWorld);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 11;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 75;
|
||||
const int revision = 76;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Reference in New Issue
Block a user