little ssao refactor / added editor sliders;

removed xatlas warnings;
This commit is contained in:
Turanszki Janos
2019-01-20 00:06:17 +00:00
parent 8f72f884ce
commit cacf32a75c
14 changed files with 60 additions and 21 deletions
+21 -1
View File
@@ -18,7 +18,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight();
ppWindow = new wiWindow(GUI, "PostProcess Window");
ppWindow->SetSize(XMFLOAT2(360, 640));
ppWindow->SetSize(XMFLOAT2(360, 660));
GUI->AddWidget(ppWindow);
float x = 110;
@@ -65,6 +65,26 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
});
ppWindow->AddWidget(ssaoCheckBox);
ssaoRangeSlider = new wiSlider(0, 2, 1, 1000, "Range: ");
ssaoRangeSlider->SetTooltip("Set SSAO Detection range.");
ssaoRangeSlider->SetSize(XMFLOAT2(100, 20));
ssaoRangeSlider->SetPos(XMFLOAT2(x + 100, y));
ssaoRangeSlider->SetValue(component->getSSAORange());
ssaoRangeSlider->OnSlide([&](wiEventArgs args) {
component->setSSAORange(args.fValue);
});
ppWindow->AddWidget(ssaoRangeSlider);
ssaoSampleCountSlider = new wiSlider(9, 64, 16, 64-9, "SampleCount: ");
ssaoSampleCountSlider->SetTooltip("Set SSAO Sample Count. Higher values produce better quality, but slower to compute");
ssaoSampleCountSlider->SetSize(XMFLOAT2(100, 20));
ssaoSampleCountSlider->SetPos(XMFLOAT2(x + 100, y += 35));
ssaoSampleCountSlider->SetValue((float)component->getSSAOSampleCount());
ssaoSampleCountSlider->OnSlide([&](wiEventArgs args) {
component->setSSAOSampleCount((UINT)args.iValue);
});
ppWindow->AddWidget(ssaoSampleCountSlider);
ssrCheckBox = new wiCheckBox("SSR: ");
ssrCheckBox->SetTooltip("Enable Screen Space Reflections.");
ssrCheckBox->SetScriptTip("RenderPath3D::SetSSREnabled(bool value)");
+2
View File
@@ -23,6 +23,8 @@ public:
wiCheckBox* lensFlareCheckBox;
wiCheckBox* lightShaftsCheckBox;
wiCheckBox* ssaoCheckBox;
wiSlider* ssaoRangeSlider;
wiSlider* ssaoSampleCountSlider;
wiCheckBox* ssrCheckBox;
wiCheckBox* sssCheckBox;
wiCheckBox* eyeAdaptionCheckBox;
+7 -7
View File
@@ -2324,14 +2324,14 @@ public:
void clear()
{
for (size_t i = 0; i < m_vertexArray.size(); i++)
delete m_vertexArray[i];
delete m_vertexArray[(uint32_t)i];
m_vertexArray.clear();
for (EdgeMap::PseudoIndex it = m_edgeMap.start(); !m_edgeMap.isDone(it); m_edgeMap.advance(it))
delete m_edgeMap[it].value;
m_edgeArray.clear();
m_edgeMap.clear();
for (size_t i = 0; i < m_faceArray.size(); i++)
delete m_faceArray[i];
delete m_faceArray[(uint32_t)i];
m_faceArray.clear();
}
@@ -2610,9 +2610,9 @@ public:
XA_DEBUG_ASSERT(m_faceArray.size() > faceCount); // triangle count > face count
linkBoundary();
for (size_t i = 0; i < edgeArray.size(); i++)
delete edgeArray[i];
delete edgeArray[(uint32_t)i];
for (size_t i = 0; i < faceArray.size(); i++)
delete faceArray[i];
delete faceArray[(uint32_t)i];
}
/// Link boundary edges once the mesh has been created.
@@ -5431,7 +5431,7 @@ struct AtlasBuilder
}
XA_DEBUG_ASSERT(maxDistance >= 0);
// In order to prevent k-means cyles we record all the previously chosen seeds.
uint32_t index = std::find(chart->seeds.begin(), chart->seeds.end(), mostCentral) - chart->seeds.begin();
uint32_t index = (uint32_t)(std::find(chart->seeds.begin(), chart->seeds.end(), mostCentral) - chart->seeds.begin());
if (index < chart->seeds.size()) {
// Move new seed to the end of the seed array.
uint32_t last = chart->seeds.size() - 1;
@@ -6470,7 +6470,7 @@ public:
~MeshCharts()
{
for (size_t i = 0; i < m_chartArray.size(); i++)
delete m_chartArray[i];
delete m_chartArray[(uint32_t)i];
}
uint32_t chartCount() const
@@ -6779,7 +6779,7 @@ public:
~Atlas()
{
for (size_t i = 0; i < m_meshChartsArray.size(); i++)
delete m_meshChartsArray[i];
delete m_meshChartsArray[(uint32_t)i];
}
uint32_t meshCount() const
+1 -1
View File
@@ -408,7 +408,7 @@ void TestsRenderer::RunSpriteTest()
static wiSprite sprite("../logo/logo_small.png");
sprite.params = params;
sprite.anim = wiSprite::Anim();
sprite.anim.wobbleAnim.amount = XMFLOAT2(1.2, 0.8);
sprite.anim.wobbleAnim.amount = XMFLOAT2(1.2f, 0.8f);
addSprite(&sprite);
static wiFont font("Wobble animation: ");
+2
View File
@@ -163,6 +163,8 @@ void RenderPath3D::setProperties()
setOutlineThreshold(0.2f);
setOutlineThickness(1.0f);
setOutlineColor(XMFLOAT3(0, 0, 0));
setSSAORange(1.0f);
setSSAOSampleCount(16);
setSSAOEnabled(true);
setSSREnabled(true);
+6
View File
@@ -20,6 +20,8 @@ private:
float outlineThreshold;
float outlineThickness;
XMFLOAT3 outlineColor;
float ssaoRange;
UINT ssaoSampleCount;
bool fxaaEnabled;
bool ssaoEnabled;
@@ -93,6 +95,8 @@ public:
inline float getOutlineThreshold() { return outlineThreshold; }
inline float getOutlineThickness() { return outlineThickness; }
inline XMFLOAT3 getOutlineColor() { return outlineColor; }
inline float getSSAORange() { return ssaoRange; }
inline UINT getSSAOSampleCount() { return ssaoSampleCount; }
inline bool getSSAOEnabled(){ return ssaoEnabled; }
inline bool getSSREnabled(){ return ssrEnabled; }
@@ -133,6 +137,8 @@ public:
inline void setOutlineThreshold(float value) { outlineThreshold = value; }
inline void setOutlineThickness(float value) { outlineThickness = value; }
inline void setOutlineColor(const XMFLOAT3& value) { outlineColor = value; }
inline void setSSAORange(float value) { ssaoRange = value; }
inline void setSSAOSampleCount(UINT value) { ssaoSampleCount = value; }
inline void setSSAOEnabled(bool value){ ssaoEnabled = value; }
inline void setSSREnabled(bool value){ ssrEnabled = value; }
+1 -1
View File
@@ -199,7 +199,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
rtSSAO[0].Activate(threadID); {
fx.process.setSSAO();
fx.process.setSSAO(getSSAORange(), getSSAOSampleCount());
fx.setMaskMap(wiTextureHelper::getRandom64x64());
fx.quality = QUALITY_LINEAR;
fx.sampleFlag = SAMPLEMODE_MIRROR;
+1 -1
View File
@@ -123,7 +123,7 @@ void RenderPath3D_Forward::RenderScene(GRAPHICSTHREAD threadID)
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
rtSSAO[0].Activate(threadID); {
fx.process.setSSAO();
fx.process.setSSAO(getSSAORange(), getSSAOSampleCount());
fx.setMaskMap(wiTextureHelper::getRandom64x64());
fx.quality = QUALITY_LINEAR;
fx.sampleFlag = SAMPLEMODE_MIRROR;
+1 -1
View File
@@ -110,7 +110,7 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
rtSSAO[0].Activate(threadID); {
fx.process.setSSAO();
fx.process.setSSAO(getSSAORange(), getSSAOSampleCount());
fx.setMaskMap(wiTextureHelper::getRandom64x64());
fx.quality = QUALITY_LINEAR;
fx.sampleFlag = SAMPLEMODE_MIRROR;
+1 -1
View File
@@ -73,7 +73,7 @@ void RenderPath3D_TiledForward::RenderScene(GRAPHICSTHREAD threadID)
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
rtSSAO[0].Activate(threadID); {
fx.process.setSSAO();
fx.process.setSSAO(getSSAORange(), getSSAOSampleCount());
fx.setMaskMap(wiTextureHelper::getRandom64x64());
fx.quality = QUALITY_LINEAR;
fx.sampleFlag = SAMPLEMODE_MIRROR;
+7 -6
View File
@@ -44,6 +44,9 @@ inline float3x3 GetTangentSpace(float3 normal)
float4 main(VertexToPixelPostProcess input):SV_Target
{
const float range = xPPParams0.x;
const uint sampleCount = xPPParams0.y;
float3 noise = xMaskTex.Load(int3((64 * input.tex.xy * 400) % 64, 0)).xyz * 2.0 - 1.0;
float3 normal = decode(texture_gbuffer1.SampleLevel(sampler_linear_clamp, input.tex, 0).xy);
float3 P = getPosition(input.tex, texture_depth.SampleLevel(sampler_point_clamp, input.tex, 0));
@@ -53,27 +56,25 @@ float4 main(VertexToPixelPostProcess input):SV_Target
float3x3 tangentSpace = float3x3(tangent, bitangent, normal);
float center_depth = texture_lineardepth.SampleLevel(sampler_point_clamp, input.tex, 0);
center_depth -= 0.0006f; // self-occlusion bias
float ao = 0;
const uint sampleCount = 16;
for (uint i = 0; i < sampleCount; ++i)
{
float2 hamm = hammersley2d(i, sampleCount);
float3 hemisphere = hemisphereSample_uniform(hamm.x, hamm.y);
float3 cone = mul(hemisphere, tangentSpace);
float3 sam = P + cone;
float3 sam = P + cone * range;
float4 vProjectedCoord = mul(float4(sam, 1.0f), g_xCamera_VP);
vProjectedCoord.xy /= vProjectedCoord.w;
vProjectedCoord.xy = vProjectedCoord.xy * float2(0.5f, -0.5f) + float2(0.5f, 0.5f);
float ray_depth = texture_lineardepth.SampleLevel(sampler_point_clamp, vProjectedCoord.xy, 0);
ray_depth += 0.0008f; // self-occlusion bias
float depth_fix = 1 - saturate(abs(center_depth - ray_depth) * 200); // to much depth difference cancels the effect
float depth_fix = 1 - saturate(abs(center_depth - ray_depth) * 200); // too much depth difference cancels the effect
ao += (ray_depth <= center_depth ? 1 : 0) * depth_fix;
ao += (ray_depth < center_depth ? 1 : 0) * depth_fix;
}
ao /= (float)sampleCount;
+3
View File
@@ -279,6 +279,9 @@ namespace wiImage
case wiImageParams::PostProcess::FXAA:
break;
case wiImageParams::PostProcess::SSAO:
prcb.xPPParams0.x = params.process.params.ssao.range;
prcb.xPPParams0.y = (float)params.process.params.ssao.sampleCount;
device->UpdateBuffer(&processCb, &prcb, threadID);
break;
case wiImageParams::PostProcess::SSSS:
prcb.xPPParams0.x = params.process.params.ssss.x;
+6 -1
View File
@@ -134,6 +134,11 @@ struct wiImageParams
} blur;
Blur ssss;
Blur sun;
struct SSAO
{
float range;
UINT sampleCount;
} ssao;
float dofStrength;
float sharpen;
float exposure;
@@ -156,7 +161,7 @@ struct wiImageParams
params.outline.colorB = color.z;
}
void setFXAA() { type = FXAA; }
void setSSAO() { type = SSAO; }
void setSSAO(float range = 1.0f, UINT sampleCount = 16) { type = SSAO; params.ssao.range = range; params.ssao.sampleCount = sampleCount; }
void setLinDepth() { type = LINEARDEPTH; }
void setColorGrade() { type = COLORGRADE; }
void setSSSS(const XMFLOAT2& value) { type = SSSS; params.ssss.x = value.x; params.ssss.y = value.y; }
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 24;
// minor bug fixes, alterations, refactors, updates
const int revision = 26;
const int revision = 27;
long GetVersion()