implemented alpha composition rendering for hair particle systems; implemented controllable alpharef for alpha testing behaviour;
This commit is contained in:
@@ -9,15 +9,18 @@
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
DeferredRenderableComponent::DeferredRenderableComponent(){
|
||||
DeferredRenderableComponent::DeferredRenderableComponent()
|
||||
{
|
||||
Renderable3DComponent::setProperties();
|
||||
|
||||
setSSREnabled(true);
|
||||
setSSAOEnabled(true);
|
||||
setHairParticleAlphaCompositionEnabled(false);
|
||||
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
DeferredRenderableComponent::~DeferredRenderableComponent(){
|
||||
DeferredRenderableComponent::~DeferredRenderableComponent()
|
||||
{
|
||||
}
|
||||
void DeferredRenderableComponent::Initialize()
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ Luna<DeferredRenderableComponent_BindLua>::FunctionType DeferredRenderableCompon
|
||||
lunamethod(Renderable3DComponent_BindLua, SetStereogramEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEyeAdaptionEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetTessellationEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticleAlphaCompositionEnabled),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
@@ -6,16 +6,18 @@
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
ForwardRenderableComponent::ForwardRenderableComponent(){
|
||||
ForwardRenderableComponent::ForwardRenderableComponent()
|
||||
{
|
||||
Renderable3DComponent::setProperties();
|
||||
|
||||
setSSREnabled(false);
|
||||
setSSAOEnabled(false);
|
||||
setShadowsEnabled(true);
|
||||
setShadowsEnabled(false);
|
||||
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
ForwardRenderableComponent::~ForwardRenderableComponent(){
|
||||
ForwardRenderableComponent::~ForwardRenderableComponent()
|
||||
{
|
||||
}
|
||||
void ForwardRenderableComponent::Initialize()
|
||||
{
|
||||
|
||||
@@ -9,11 +9,13 @@ protected:
|
||||
|
||||
wiRenderTarget rtMain;
|
||||
|
||||
|
||||
virtual void RenderScene(GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
public:
|
||||
ForwardRenderableComponent();
|
||||
virtual ~ForwardRenderableComponent();
|
||||
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value) override;
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
@@ -49,6 +49,8 @@ Luna<ForwardRenderableComponent_BindLua>::FunctionType ForwardRenderableComponen
|
||||
lunamethod(Renderable3DComponent_BindLua, SetStereogramEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEyeAdaptionEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetTessellationEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetMSAASampleCount),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticleAlphaCompositionEnabled),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
|
||||
@@ -12,7 +12,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
|
||||
float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight();
|
||||
|
||||
materialWindow = new wiWindow(GUI, "Material Window");
|
||||
materialWindow->SetSize(XMFLOAT2(600, 570));
|
||||
materialWindow->SetSize(XMFLOAT2(600, 600));
|
||||
materialWindow->SetEnabled(false);
|
||||
GUI->AddWidget(materialWindow);
|
||||
|
||||
@@ -86,6 +86,14 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
|
||||
});
|
||||
materialWindow->AddWidget(alphaSlider);
|
||||
|
||||
alphaRefSlider = new wiSlider(0, 1, 1.0f, 1000, "AlphaRef: ");
|
||||
alphaRefSlider->SetSize(XMFLOAT2(100, 30));
|
||||
alphaRefSlider->SetPos(XMFLOAT2(x, y += step));
|
||||
alphaRefSlider->OnSlide([&](wiEventArgs args) {
|
||||
material->alphaRef = args.fValue;
|
||||
});
|
||||
materialWindow->AddWidget(alphaRefSlider);
|
||||
|
||||
refractionIndexSlider = new wiSlider(0, 1.0f, 0.02f, 1000, "Refraction Index: ");
|
||||
refractionIndexSlider->SetSize(XMFLOAT2(100, 30));
|
||||
refractionIndexSlider->SetPos(XMFLOAT2(x, y += step));
|
||||
@@ -177,6 +185,7 @@ MaterialWindow::~MaterialWindow()
|
||||
SAFE_DELETE(movingTexSliderV);
|
||||
SAFE_DELETE(colorPickerToggleButton);
|
||||
SAFE_DELETE(colorPicker);
|
||||
SAFE_DELETE(alphaRefSlider);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +210,7 @@ void MaterialWindow::SetMaterial(Material* mat)
|
||||
pomSlider->SetValue(material->parallaxOcclusionMapping);
|
||||
movingTexSliderU->SetValue(material->movingTex.x);
|
||||
movingTexSliderU->SetValue(material->movingTex.x);
|
||||
alphaRefSlider->SetValue(material->alphaRef);
|
||||
materialWindow->SetEnabled(true);
|
||||
colorPicker->SetEnabled(true);
|
||||
}
|
||||
|
||||
@@ -39,5 +39,6 @@ public:
|
||||
wiSlider* movingTexSliderV;
|
||||
wiButton* colorPickerToggleButton;
|
||||
wiColorPicker* colorPicker;
|
||||
wiSlider* alphaRefSlider;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ private:
|
||||
bool stereogramEnabled;
|
||||
bool eyeAdaptionEnabled;
|
||||
bool tessellationEnabled;
|
||||
bool hairParticleAlphaComposition;
|
||||
|
||||
UINT msaaSampleCount;
|
||||
|
||||
@@ -109,6 +110,7 @@ public:
|
||||
inline bool getStereogramEnabled() { return stereogramEnabled; }
|
||||
inline bool getEyeAdaptionEnabled() { return eyeAdaptionEnabled; }
|
||||
inline bool getTessellationEnabled() { return tessellationEnabled && wiRenderer::GetDevice()->CheckCapability(wiGraphicsTypes::GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_TESSELLATION); }
|
||||
inline bool getHairParticleAlphaCompositionEnabled() { return hairParticleAlphaComposition; }
|
||||
|
||||
inline UINT getMSAASampleCount() { return msaaSampleCount; }
|
||||
|
||||
@@ -146,6 +148,8 @@ public:
|
||||
inline void setStereogramEnabled(bool value) { stereogramEnabled = value; }
|
||||
inline void setEyeAdaptionEnabled(bool value) { eyeAdaptionEnabled = value; }
|
||||
inline void setTessellationEnabled(bool value) { tessellationEnabled = value; }
|
||||
// Render hair particle systems in two passes to achieve smooth alpha blending (tiledforward only yet)
|
||||
inline void setHairParticleAlphaCompositionEnabled(bool value) { hairParticleAlphaComposition = value; }
|
||||
|
||||
inline void setMSAASampleCount(UINT value) { msaaSampleCount = value; }
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ Luna<Renderable3DComponent_BindLua>::FunctionType Renderable3DComponent_BindLua:
|
||||
lunamethod(Renderable3DComponent_BindLua, SetEyeAdaptionEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetTessellationEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetMSAASampleCount),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetHairParticleAlphaCompositionEnabled),
|
||||
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
|
||||
@@ -347,6 +348,21 @@ int Renderable3DComponent_BindLua::SetMSAASampleCount(lua_State* L)
|
||||
wiLua::SError(L, "SetMSAASampleCount(int value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Renderable3DComponent_BindLua::SetHairParticleAlphaCompositionEnabled(lua_State* L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetHairParticleAlphaCompositionEnabled(bool value) component is null!");
|
||||
return 0;
|
||||
}
|
||||
if (wiLua::SGetArgCount(L) > 0)
|
||||
{
|
||||
((Renderable3DComponent*)component)->setHairParticleAlphaCompositionEnabled(wiLua::SGetBool(L, 1));
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetHairParticleAlphaCompositionEnabled(bool value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Renderable3DComponent_BindLua::SetDepthOfFieldFocus(lua_State* L)
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
int SetEyeAdaptionEnabled(lua_State* L);
|
||||
int SetTessellationEnabled(lua_State* L);
|
||||
int SetMSAASampleCount(lua_State* L);
|
||||
int SetHairParticleAlphaCompositionEnabled(lua_State* L);
|
||||
|
||||
int SetDepthOfFieldFocus(lua_State* L);
|
||||
int SetDepthOfFieldStrength(lua_State* L);
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
TiledForwardRenderableComponent::TiledForwardRenderableComponent() {
|
||||
TiledForwardRenderableComponent::TiledForwardRenderableComponent()
|
||||
{
|
||||
ForwardRenderableComponent::setProperties();
|
||||
setShadowsEnabled(true);
|
||||
setHairParticleAlphaCompositionEnabled(true);
|
||||
}
|
||||
TiledForwardRenderableComponent::~TiledForwardRenderableComponent() {
|
||||
TiledForwardRenderableComponent::~TiledForwardRenderableComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
@@ -19,6 +22,10 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
rtMain.Activate(threadID, 0, 0, 0, 0, true); // depth prepass
|
||||
{
|
||||
if (getHairParticleAlphaCompositionEnabled())
|
||||
{
|
||||
wiRenderer::SetAlphaRef(0.1f, threadID);
|
||||
}
|
||||
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_ALPHATESTONLY, nullptr, true);
|
||||
}
|
||||
|
||||
@@ -47,9 +54,10 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
void TiledForwardRenderableComponent::RenderTransparentScene(wiRenderTarget& mainRT, wiRenderTarget& shadedSceneRT, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
rtTransparent.Activate(threadID, mainRT.depth); {
|
||||
rtTransparent.Activate(threadID, mainRT.depth);
|
||||
{
|
||||
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_TILEDFORWARD, shadedSceneRT.GetTexture(), rtReflection.GetTexture()
|
||||
, rtWaterRipple.GetTexture(), threadID, false);
|
||||
, rtWaterRipple.GetTexture(), threadID, getHairParticleAlphaCompositionEnabled());
|
||||
wiRenderer::DrawTrails(threadID, shadedSceneRT.GetTexture());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ CBUFFER(MiscCB, CBSLOT_RENDERER_MISC)
|
||||
CBUFFER(APICB, CBSLOT_API)
|
||||
{
|
||||
float4 g_xClipPlane;
|
||||
float g_xAlphaRef;
|
||||
float3 g_xPadding0_APICB;
|
||||
};
|
||||
|
||||
static const float PI = 3.14159265358979323846;
|
||||
@@ -109,7 +111,7 @@ static const float PI = 3.14159265358979323846;
|
||||
#ifdef DISABLE_ALPHATEST
|
||||
#define ALPHATEST(x)
|
||||
#else
|
||||
#define ALPHATEST(x) clip((x)-0.1);
|
||||
#define ALPHATEST(x) clip((x) - (1.0f - g_xAlphaRef));
|
||||
#endif
|
||||
|
||||
static const float g_GammaValue = 2.2;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "grassHF_PS.hlsli"
|
||||
#include "ditherHF.hlsli"
|
||||
|
||||
[earlydepthstencil]
|
||||
float4 main(GS_OUT PSIn) : SV_Target
|
||||
{
|
||||
float4 color = float4(PSIn.col,1);
|
||||
|
||||
@@ -7,7 +7,6 @@ float4 main(QGS_OUT PSIn) : SV_Target
|
||||
{
|
||||
float4 color = texture_0.Sample(sampler_linear_clamp,PSIn.tex);
|
||||
color = DEGAMMA(color);
|
||||
color.a = 1; // do not blend
|
||||
float3 P = PSIn.pos3D;
|
||||
float3 V = normalize(g_xCamera_CamPos - P);
|
||||
float emissive = 0;
|
||||
|
||||
@@ -70,7 +70,7 @@ enum CBTYPES
|
||||
CBTYPE_VOLUMELIGHT,
|
||||
CBTYPE_DECAL,
|
||||
CBTYPE_CUBEMAPRENDER,
|
||||
CBTYPE_CLIPPLANE,
|
||||
CBTYPE_API,
|
||||
CBTYPE_TESSELLATION,
|
||||
CBTYPE_DISPATCHPARAMS,
|
||||
CBTYPE_LAST
|
||||
@@ -240,6 +240,7 @@ enum DSSTYPES
|
||||
DSSTYPE_LIGHT,
|
||||
DSSTYPE_STENCILREAD_MATCH,
|
||||
DSSTYPE_DEPTHREADEQUAL,
|
||||
DSSTYPE_HAIRALPHACOMPOSITION,
|
||||
DSSTYPE_LAST
|
||||
};
|
||||
// blend states
|
||||
|
||||
@@ -415,8 +415,6 @@ void wiHairParticle::Draw(Camera* camera, SHADERTYPE shaderType, GRAPHICSTHREAD
|
||||
{
|
||||
device->BindResourcePS(texture,TEXSLOT_ONDEMAND0,threadID);
|
||||
device->BindResourceGS(texture,TEXSLOT_ONDEMAND0,threadID);
|
||||
|
||||
device->BindBlendState(bs,threadID);
|
||||
}
|
||||
else
|
||||
device->BindRasterizerState(ncrs,threadID);
|
||||
|
||||
@@ -152,6 +152,8 @@ struct Material
|
||||
|
||||
bool planar_reflections;
|
||||
|
||||
float alphaRef;
|
||||
|
||||
|
||||
Material()
|
||||
{
|
||||
@@ -207,6 +209,8 @@ struct Material
|
||||
parallaxOcclusionMapping = 0.0f;
|
||||
|
||||
planar_reflections = false;
|
||||
|
||||
alphaRef = 0.75f;
|
||||
}
|
||||
|
||||
bool IsTransparent() const { return alpha < 1.0f; }
|
||||
|
||||
+64
-32
@@ -568,7 +568,7 @@ void wiRenderer::LoadBuffers()
|
||||
GetDevice()->CreateBuffer(&bd, nullptr, constantBuffers[CBTYPE_MISC]);
|
||||
|
||||
bd.ByteWidth = sizeof(APICB);
|
||||
GetDevice()->CreateBuffer(&bd, nullptr, constantBuffers[CBTYPE_CLIPPLANE]);
|
||||
GetDevice()->CreateBuffer(&bd, nullptr, constantBuffers[CBTYPE_API]);
|
||||
|
||||
|
||||
// On demand buffers...
|
||||
@@ -1118,6 +1118,12 @@ void wiRenderer::SetUpStates()
|
||||
GetDevice()->CreateDepthStencilState(&dsd, depthStencils[DSSTYPE_DEPTHREADEQUAL]);
|
||||
|
||||
|
||||
dsd.DepthEnable = true;
|
||||
dsd.DepthWriteMask = DEPTH_WRITE_MASK_ZERO;
|
||||
dsd.DepthFunc = COMPARISON_LESS;
|
||||
GetDevice()->CreateDepthStencilState(&dsd, depthStencils[DSSTYPE_HAIRALPHACOMPOSITION]);
|
||||
|
||||
|
||||
for (int i = 0; i < BSTYPE_LAST; ++i)
|
||||
{
|
||||
blendStates[i] = new BlendState;
|
||||
@@ -1210,7 +1216,8 @@ void wiRenderer::BindPersistentState(GRAPHICSTHREAD threadID)
|
||||
GetDevice()->BindConstantBufferHS(constantBuffers[CBTYPE_MISC], CB_GETBINDSLOT(MiscCB), threadID);
|
||||
GetDevice()->BindConstantBufferCS(constantBuffers[CBTYPE_MISC], CB_GETBINDSLOT(MiscCB), threadID);
|
||||
|
||||
GetDevice()->BindConstantBufferVS(constantBuffers[CBTYPE_CLIPPLANE], CB_GETBINDSLOT(APICB), threadID);
|
||||
GetDevice()->BindConstantBufferVS(constantBuffers[CBTYPE_API], CB_GETBINDSLOT(APICB), threadID);
|
||||
GetDevice()->BindConstantBufferPS(constantBuffers[CBTYPE_API], CB_GETBINDSLOT(APICB), threadID);
|
||||
|
||||
GetDevice()->BindResourcePS(resourceBuffers[RBTYPE_LIGHTARRAY], STRUCTUREDBUFFER_GETBINDSLOT(LightArrayType), threadID);
|
||||
GetDevice()->BindResourceCS(resourceBuffers[RBTYPE_LIGHTARRAY], STRUCTUREDBUFFER_GETBINDSLOT(LightArrayType), threadID);
|
||||
@@ -2943,7 +2950,6 @@ PSTYPES GetPSTYPE(SHADERTYPE shaderType, const Material* const material)
|
||||
void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culledRenderer, SHADERTYPE shaderType, UINT renderTypeFlags, GRAPHICSTHREAD threadID,
|
||||
bool tessellation)
|
||||
{
|
||||
|
||||
if (!culledRenderer.empty())
|
||||
{
|
||||
GetDevice()->EventBegin(L"RenderMeshes", threadID);
|
||||
@@ -3247,6 +3253,8 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
GetDevice()->BindResourceDS(material->GetDisplacementMap(), TEXSLOT_ONDEMAND5, threadID);
|
||||
}
|
||||
|
||||
SetAlphaRef(material->alphaRef, threadID);
|
||||
|
||||
GetDevice()->DrawIndexedInstanced((int)subset.subsetIndices.size(), k, threadID);
|
||||
}
|
||||
}
|
||||
@@ -3260,6 +3268,8 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
|
||||
GetDevice()->BindDS(nullptr, threadID);
|
||||
GetDevice()->BindHS(nullptr, threadID);
|
||||
|
||||
ResetAlphaRef(threadID);
|
||||
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
}
|
||||
}
|
||||
@@ -3270,10 +3280,26 @@ void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD thr
|
||||
const FrameCulling& culling = frameCullings[camera];
|
||||
const CulledCollection& culledRenderer = culling.culledRenderer;
|
||||
|
||||
GetDevice()->EventBegin(L"DrawWorld");
|
||||
|
||||
if (shaderType == SHADERTYPE_TILEDFORWARD)
|
||||
{
|
||||
GetDevice()->BindResourcePS(resourceBuffers[RBTYPE_LIGHTINDEXLIST_OPAQUE], SBSLOT_LIGHTINDEXLIST, threadID);
|
||||
GetDevice()->BindResourcePS(textures[TEXTYPE_2D_LIGHTGRID_OPAQUE], TEXSLOT_LIGHTGRID, threadID);
|
||||
}
|
||||
|
||||
if (grass)
|
||||
{
|
||||
GetDevice()->BindDepthStencilState(depthStencils[shaderType == SHADERTYPE_TILEDFORWARD ? DSSTYPE_DEPTHREADEQUAL : DSSTYPE_DEFAULT], STENCILREF_DEFAULT, threadID);
|
||||
GetDevice()->BindBlendState(blendStates[BSTYPE_OPAQUE], threadID);
|
||||
for (wiHairParticle* hair : culling.culledHairParticleSystems)
|
||||
{
|
||||
hair->Draw(camera, shaderType, threadID);
|
||||
}
|
||||
}
|
||||
|
||||
if (!culledRenderer.empty() || (grass && culling.culledHairParticleSystems.empty()))
|
||||
{
|
||||
GetDevice()->EventBegin(L"DrawWorld");
|
||||
|
||||
if (!wireRender)
|
||||
{
|
||||
if (refRes != nullptr)
|
||||
@@ -3282,26 +3308,11 @@ void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD thr
|
||||
}
|
||||
}
|
||||
|
||||
if (shaderType == SHADERTYPE_TILEDFORWARD)
|
||||
{
|
||||
GetDevice()->BindResourcePS(resourceBuffers[RBTYPE_LIGHTINDEXLIST_OPAQUE], SBSLOT_LIGHTINDEXLIST, threadID);
|
||||
GetDevice()->BindResourcePS(textures[TEXTYPE_2D_LIGHTGRID_OPAQUE], TEXSLOT_LIGHTGRID, threadID);
|
||||
}
|
||||
|
||||
if (grass)
|
||||
{
|
||||
GetDevice()->BindDepthStencilState(depthStencils[shaderType == SHADERTYPE_TILEDFORWARD ? DSSTYPE_DEPTHREADEQUAL : DSSTYPE_DEFAULT], STENCILREF_DEFAULT, threadID);
|
||||
for (wiHairParticle* hair : culling.culledHairParticleSystems)
|
||||
{
|
||||
hair->Draw(camera, shaderType, threadID);
|
||||
}
|
||||
}
|
||||
|
||||
RenderMeshes(camera->translation, culledRenderer, shaderType, RENDERTYPE_OPAQUE, threadID, tessellation);
|
||||
|
||||
GetDevice()->EventEnd();
|
||||
}
|
||||
|
||||
GetDevice()->EventEnd();
|
||||
|
||||
}
|
||||
|
||||
void wiRenderer::DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, Texture2D* refracRes, Texture2D* refRes
|
||||
@@ -3311,9 +3322,26 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, Tex
|
||||
const FrameCulling& culling = frameCullings[camera];
|
||||
const CulledCollection& culledRenderer = culling.culledRenderer_transparent;
|
||||
|
||||
GetDevice()->EventBegin(L"DrawWorldTransparent");
|
||||
|
||||
if (shaderType == SHADERTYPE_TILEDFORWARD)
|
||||
{
|
||||
GetDevice()->BindResourcePS(resourceBuffers[RBTYPE_LIGHTINDEXLIST_TRANSPARENT], SBSLOT_LIGHTINDEXLIST, threadID);
|
||||
GetDevice()->BindResourcePS(textures[TEXTYPE_2D_LIGHTGRID_TRANSPARENT], TEXSLOT_LIGHTGRID, threadID);
|
||||
}
|
||||
|
||||
if (grass)
|
||||
{
|
||||
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_HAIRALPHACOMPOSITION], STENCILREF_DEFAULT, threadID); // minimizes overdraw by depthcomp = less
|
||||
GetDevice()->BindBlendState(blendStates[BSTYPE_TRANSPARENT], threadID);
|
||||
for (wiHairParticle* hair : culling.culledHairParticleSystems)
|
||||
{
|
||||
hair->Draw(camera, shaderType, threadID);
|
||||
}
|
||||
}
|
||||
|
||||
if (!culledRenderer.empty())
|
||||
{
|
||||
GetDevice()->EventBegin(L"DrawWorld");
|
||||
|
||||
if (!wireRender)
|
||||
{
|
||||
@@ -3321,17 +3349,11 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, Tex
|
||||
GetDevice()->BindResourcePS(refracRes, TEXSLOT_ONDEMAND7, threadID);
|
||||
GetDevice()->BindResourcePS(waterRippleNormals, TEXSLOT_ONDEMAND8, threadID);
|
||||
}
|
||||
|
||||
if (shaderType == SHADERTYPE_TILEDFORWARD)
|
||||
{
|
||||
GetDevice()->BindResourcePS(resourceBuffers[RBTYPE_LIGHTINDEXLIST_TRANSPARENT], SBSLOT_LIGHTINDEXLIST, threadID);
|
||||
GetDevice()->BindResourcePS(textures[TEXTYPE_2D_LIGHTGRID_TRANSPARENT], TEXSLOT_LIGHTGRID, threadID);
|
||||
}
|
||||
|
||||
RenderMeshes(camera->translation, culledRenderer, shaderType, RENDERTYPE_TRANSPARENT | RENDERTYPE_WATER, threadID, false);
|
||||
|
||||
GetDevice()->EventEnd();
|
||||
}
|
||||
|
||||
GetDevice()->EventEnd();
|
||||
}
|
||||
|
||||
|
||||
@@ -3652,9 +3674,19 @@ void wiRenderer::UpdateCameraCB(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_CAMERA], &cb, threadID);
|
||||
}
|
||||
wiRenderer::APICB* apiCB = new wiRenderer::APICB(XMFLOAT4(0, 0, 0, 0), 0.75f);
|
||||
void wiRenderer::SetClipPlane(XMFLOAT4 clipPlane, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_CLIPPLANE], &clipPlane, threadID);
|
||||
apiCB->clipPlane = clipPlane;
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_API], apiCB, threadID);
|
||||
}
|
||||
void wiRenderer::SetAlphaRef(float alphaRef, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
if (alphaRef != apiCB->alphaRef)
|
||||
{
|
||||
apiCB->alphaRef = alphaRef;
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_API], apiCB, threadID);
|
||||
}
|
||||
}
|
||||
void wiRenderer::UpdateGBuffer(Texture2D* slot0, Texture2D* slot1, Texture2D* slot2, Texture2D* slot3, Texture2D* slot4, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
|
||||
@@ -201,6 +201,10 @@ public:
|
||||
GFX_STRUCT APICB
|
||||
{
|
||||
XMFLOAT4 clipPlane;
|
||||
float alphaRef;
|
||||
float pad[3];
|
||||
|
||||
APICB(const XMFLOAT4& clipPlane, float alphaRef) :clipPlane(clipPlane), alphaRef(alphaRef) {}
|
||||
|
||||
CB_SETBINDSLOT(CBSLOT_API)
|
||||
|
||||
@@ -368,6 +372,8 @@ public:
|
||||
static void UpdateFrameCB(GRAPHICSTHREAD threadID);
|
||||
static void UpdateCameraCB(Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void SetClipPlane(XMFLOAT4 clipPlane, GRAPHICSTHREAD threadID);
|
||||
static void SetAlphaRef(float alphaRef, GRAPHICSTHREAD threadID);
|
||||
static void ResetAlphaRef(GRAPHICSTHREAD threadID) { SetAlphaRef(0.75f, threadID); }
|
||||
static void UpdateGBuffer(wiGraphicsTypes::Texture2D* slot0, wiGraphicsTypes::Texture2D* slot1, wiGraphicsTypes::Texture2D* slot2, wiGraphicsTypes::Texture2D* slot3, wiGraphicsTypes::Texture2D* slot4, GRAPHICSTHREAD threadID);
|
||||
static void UpdateDepthBuffer(wiGraphicsTypes::Texture2D* depth, wiGraphicsTypes::Texture2D* linearDepth, GRAPHICSTHREAD threadID);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 9;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 19;
|
||||
const int revision = 20;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Reference in New Issue
Block a user