postprocess updates
This commit is contained in:
@@ -13,17 +13,18 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
assert(GUI && "Invalid GUI!");
|
||||
|
||||
ppWindow = new wiWindow(GUI, "PostProcess Window");
|
||||
ppWindow->SetSize(XMFLOAT2(400, 740));
|
||||
ppWindow->SetSize(XMFLOAT2(400, 700));
|
||||
GUI->AddWidget(ppWindow);
|
||||
|
||||
float x = 150;
|
||||
float y = 0;
|
||||
float y = 10;
|
||||
float step = 30;
|
||||
|
||||
exposureSlider = new wiSlider(0.0f, 3.0f, 1, 10000, "Exposure: ");
|
||||
exposureSlider->SetTooltip("Set the tonemap exposure value");
|
||||
exposureSlider->SetScriptTip("RenderPath3D::SetExposure(float value)");
|
||||
exposureSlider->SetSize(XMFLOAT2(100, 20));
|
||||
exposureSlider->SetPos(XMFLOAT2(x, y += 35));
|
||||
exposureSlider->SetPos(XMFLOAT2(x, y += step));
|
||||
exposureSlider->SetValue(component->getExposure());
|
||||
exposureSlider->OnSlide([&](wiEventArgs args) {
|
||||
component->setExposure(args.fValue);
|
||||
@@ -33,7 +34,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
lensFlareCheckBox = new wiCheckBox("LensFlare: ");
|
||||
lensFlareCheckBox->SetTooltip("Toggle visibility of light source flares. Additional setup needed per light for a lensflare to be visible.");
|
||||
lensFlareCheckBox->SetScriptTip("RenderPath3D::SetLensFlareEnabled(bool value)");
|
||||
lensFlareCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
lensFlareCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
lensFlareCheckBox->SetCheck(component->getLensFlareEnabled());
|
||||
lensFlareCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setLensFlareEnabled(args.bValue);
|
||||
@@ -43,7 +44,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
lightShaftsCheckBox = new wiCheckBox("LightShafts: ");
|
||||
lightShaftsCheckBox->SetTooltip("Enable light shaft for directional light sources.");
|
||||
lightShaftsCheckBox->SetScriptTip("RenderPath3D::SetLightShaftsEnabled(bool value)");
|
||||
lightShaftsCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
lightShaftsCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
lightShaftsCheckBox->SetCheck(component->getLightShaftsEnabled());
|
||||
lightShaftsCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setLightShaftsEnabled(args.bValue);
|
||||
@@ -53,7 +54,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
ssaoCheckBox = new wiCheckBox("SSAO: ");
|
||||
ssaoCheckBox->SetTooltip("Enable Screen Space Ambient Occlusion.");
|
||||
ssaoCheckBox->SetScriptTip("RenderPath3D::SetSSAOEnabled(bool value)");
|
||||
ssaoCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
ssaoCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
ssaoCheckBox->SetCheck(component->getSSAOEnabled());
|
||||
ssaoCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setSSAOEnabled(args.bValue);
|
||||
@@ -73,7 +74,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
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->SetPos(XMFLOAT2(x + 100, y += step));
|
||||
ssaoSampleCountSlider->SetValue((float)component->getSSAOSampleCount());
|
||||
ssaoSampleCountSlider->OnSlide([&](wiEventArgs args) {
|
||||
component->setSSAOSampleCount((UINT)args.iValue);
|
||||
@@ -83,7 +84,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
ssaoPowerSlider = new wiSlider(0.25f, 8.0f, 2, 1000, "Power: ");
|
||||
ssaoPowerSlider->SetTooltip("Set SSAO Power. Higher values produce darker, more pronounced effect");
|
||||
ssaoPowerSlider->SetSize(XMFLOAT2(100, 20));
|
||||
ssaoPowerSlider->SetPos(XMFLOAT2(x + 100, y += 35));
|
||||
ssaoPowerSlider->SetPos(XMFLOAT2(x + 100, y += step));
|
||||
ssaoPowerSlider->SetValue((float)component->getSSAOPower());
|
||||
ssaoPowerSlider->OnSlide([&](wiEventArgs args) {
|
||||
component->setSSAOPower(args.fValue);
|
||||
@@ -93,7 +94,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
ssrCheckBox = new wiCheckBox("SSR: ");
|
||||
ssrCheckBox->SetTooltip("Enable Screen Space Reflections.");
|
||||
ssrCheckBox->SetScriptTip("RenderPath3D::SetSSREnabled(bool value)");
|
||||
ssrCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
ssrCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
ssrCheckBox->SetCheck(component->getSSREnabled());
|
||||
ssrCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setSSREnabled(args.bValue);
|
||||
@@ -103,7 +104,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
sssCheckBox = new wiCheckBox("SSS: ");
|
||||
sssCheckBox->SetTooltip("Enable Subsurface Scattering. (Deferred only for now)");
|
||||
sssCheckBox->SetScriptTip("RenderPath3D::SetSSSEnabled(bool value)");
|
||||
sssCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
sssCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
sssCheckBox->SetCheck(component->getSSSEnabled());
|
||||
sssCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setSSSEnabled(args.bValue);
|
||||
@@ -112,7 +113,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
|
||||
eyeAdaptionCheckBox = new wiCheckBox("EyeAdaption: ");
|
||||
eyeAdaptionCheckBox->SetTooltip("Enable eye adaption for the overall screen luminance");
|
||||
eyeAdaptionCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
eyeAdaptionCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
eyeAdaptionCheckBox->SetCheck(component->getEyeAdaptionEnabled());
|
||||
eyeAdaptionCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setEyeAdaptionEnabled(args.bValue);
|
||||
@@ -122,7 +123,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
motionBlurCheckBox = new wiCheckBox("MotionBlur: ");
|
||||
motionBlurCheckBox->SetTooltip("Enable motion blur for camera movement and animated meshes.");
|
||||
motionBlurCheckBox->SetScriptTip("RenderPath3D::SetMotionBlurEnabled(bool value)");
|
||||
motionBlurCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
motionBlurCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
motionBlurCheckBox->SetCheck(component->getMotionBlurEnabled());
|
||||
motionBlurCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setMotionBlurEnabled(args.bValue);
|
||||
@@ -143,7 +144,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
depthOfFieldCheckBox = new wiCheckBox("DepthOfField: ");
|
||||
depthOfFieldCheckBox->SetTooltip("Enable Depth of field effect. Additional focus and strength setup required.");
|
||||
depthOfFieldCheckBox->SetScriptTip("RenderPath3D::SetDepthOfFieldEnabled(bool value)");
|
||||
depthOfFieldCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
depthOfFieldCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
depthOfFieldCheckBox->SetCheck(component->getDepthOfFieldEnabled());
|
||||
depthOfFieldCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setDepthOfFieldEnabled(args.bValue);
|
||||
@@ -165,7 +166,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
depthOfFieldScaleSlider->SetTooltip("Set depth of field scale/falloff.");
|
||||
depthOfFieldScaleSlider->SetScriptTip("RenderPath3D::SetDepthOfFieldStrength(float value)");
|
||||
depthOfFieldScaleSlider->SetSize(XMFLOAT2(100, 20));
|
||||
depthOfFieldScaleSlider->SetPos(XMFLOAT2(x + 100, y += 35));
|
||||
depthOfFieldScaleSlider->SetPos(XMFLOAT2(x + 100, y += step));
|
||||
depthOfFieldScaleSlider->SetValue(component->getDepthOfFieldStrength());
|
||||
depthOfFieldScaleSlider->OnSlide([&](wiEventArgs args) {
|
||||
component->setDepthOfFieldStrength(args.fValue);
|
||||
@@ -176,7 +177,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
depthOfFieldAspectSlider->SetTooltip("Set depth of field bokeh aspect ratio (width/height).");
|
||||
depthOfFieldAspectSlider->SetScriptTip("RenderPath3D::SetDepthOfFieldAspect(float value)");
|
||||
depthOfFieldAspectSlider->SetSize(XMFLOAT2(100, 20));
|
||||
depthOfFieldAspectSlider->SetPos(XMFLOAT2(x + 100, y += 35));
|
||||
depthOfFieldAspectSlider->SetPos(XMFLOAT2(x + 100, y += step));
|
||||
depthOfFieldAspectSlider->SetValue(component->getDepthOfFieldAspect());
|
||||
depthOfFieldAspectSlider->OnSlide([&](wiEventArgs args) {
|
||||
component->setDepthOfFieldAspect(args.fValue);
|
||||
@@ -186,7 +187,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
bloomCheckBox = new wiCheckBox("Bloom: ");
|
||||
bloomCheckBox->SetTooltip("Enable bloom. The effect adds color bleeding to the brightest parts of the scene.");
|
||||
bloomCheckBox->SetScriptTip("RenderPath3D::SetBloomEnabled(bool value)");
|
||||
bloomCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
bloomCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
bloomCheckBox->SetCheck(component->getBloomEnabled());
|
||||
bloomCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setBloomEnabled(args.bValue);
|
||||
@@ -206,7 +207,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
fxaaCheckBox = new wiCheckBox("FXAA: ");
|
||||
fxaaCheckBox->SetTooltip("Fast Approximate Anti Aliasing. A fast antialiasing method, but can be a bit too blurry.");
|
||||
fxaaCheckBox->SetScriptTip("RenderPath3D::SetFXAAEnabled(bool value)");
|
||||
fxaaCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
fxaaCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
fxaaCheckBox->SetCheck(component->getFXAAEnabled());
|
||||
fxaaCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setFXAAEnabled(args.bValue);
|
||||
@@ -216,7 +217,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
colorGradingCheckBox = new wiCheckBox("Color Grading: ");
|
||||
colorGradingCheckBox->SetTooltip("Enable color grading of the final render. An additional lookup texture must be set for it to take effect.");
|
||||
colorGradingCheckBox->SetScriptTip("RenderPath3D::SetColorGradingEnabled(bool value)");
|
||||
colorGradingCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
colorGradingCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
colorGradingCheckBox->SetCheck(component->getColorGradingEnabled());
|
||||
colorGradingCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setColorGradingEnabled(args.bValue);
|
||||
@@ -262,10 +263,19 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
});
|
||||
ppWindow->AddWidget(colorGradingButton);
|
||||
|
||||
outlineCheckBox = new wiCheckBox("Dithering: ");
|
||||
outlineCheckBox->SetTooltip("Toggle the full screen dithering effect. This helps to reduce color banding.");
|
||||
outlineCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
outlineCheckBox->SetCheck(component->getDitherEnabled());
|
||||
outlineCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setDitherEnabled(args.bValue);
|
||||
});
|
||||
ppWindow->AddWidget(outlineCheckBox);
|
||||
|
||||
sharpenFilterCheckBox = new wiCheckBox("Sharpen Filter: ");
|
||||
sharpenFilterCheckBox->SetTooltip("Toggle sharpening post process of the final image.");
|
||||
sharpenFilterCheckBox->SetScriptTip("RenderPath3D::SetSharpenFilterEnabled(bool value)");
|
||||
sharpenFilterCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
sharpenFilterCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
sharpenFilterCheckBox->SetCheck(component->getSharpenFilterEnabled());
|
||||
sharpenFilterCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setSharpenFilterEnabled(args.bValue);
|
||||
@@ -285,7 +295,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
|
||||
outlineCheckBox = new wiCheckBox("Cartoon Outline: ");
|
||||
outlineCheckBox->SetTooltip("Toggle the full screen cartoon outline effect.");
|
||||
outlineCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
outlineCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
outlineCheckBox->SetCheck(component->getOutlineEnabled());
|
||||
outlineCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setOutlineEnabled(args.bValue);
|
||||
@@ -305,7 +315,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
outlineThicknessSlider = new wiSlider(0, 4, 1, 1000, "Thickness: ");
|
||||
outlineThicknessSlider->SetTooltip("Set outline thickness.");
|
||||
outlineThicknessSlider->SetSize(XMFLOAT2(100, 20));
|
||||
outlineThicknessSlider->SetPos(XMFLOAT2(x + 100, y += 35));
|
||||
outlineThicknessSlider->SetPos(XMFLOAT2(x + 100, y += step));
|
||||
outlineThicknessSlider->SetValue(component->getOutlineThickness());
|
||||
outlineThicknessSlider->OnSlide([&](wiEventArgs args) {
|
||||
component->setOutlineThickness(args.fValue);
|
||||
@@ -314,7 +324,7 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui),
|
||||
|
||||
chromaticaberrationCheckBox = new wiCheckBox("Chromatic Aberration: ");
|
||||
chromaticaberrationCheckBox->SetTooltip("Toggle the full screen chromatic aberration effect. This simulates lens distortion at screen edges.");
|
||||
chromaticaberrationCheckBox->SetPos(XMFLOAT2(x, y += 35));
|
||||
chromaticaberrationCheckBox->SetPos(XMFLOAT2(x, y += step));
|
||||
chromaticaberrationCheckBox->SetCheck(component->getOutlineEnabled());
|
||||
chromaticaberrationCheckBox->OnClick([&](wiEventArgs args) {
|
||||
component->setChromaticAberrationEnabled(args.bValue);
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
wiCheckBox* fxaaCheckBox;
|
||||
wiCheckBox* colorGradingCheckBox;
|
||||
wiButton* colorGradingButton;
|
||||
wiCheckBox* ditherCheckBox;
|
||||
wiCheckBox* sharpenFilterCheckBox;
|
||||
wiSlider* sharpenFilterAmountSlider;
|
||||
wiCheckBox* outlineCheckBox;
|
||||
|
||||
@@ -17,33 +17,14 @@ void RenderPath3D::ResizeBuffers()
|
||||
|
||||
|
||||
// Render targets:
|
||||
{
|
||||
TextureDesc desc;
|
||||
desc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
|
||||
desc.Format = FORMAT_R16G16B16A16_FLOAT;
|
||||
desc.Width = wiRenderer::GetInternalResolution().x / 2;
|
||||
desc.Height = wiRenderer::GetInternalResolution().y / 2;
|
||||
desc.MipLevels = 5;
|
||||
device->CreateTexture(&desc, nullptr, &rtSSR);
|
||||
device->SetName(&rtSSR, "rtSSR");
|
||||
|
||||
for (uint32_t i = 0; i < rtSSR.GetDesc().MipLevels; ++i)
|
||||
{
|
||||
int subresource_index;
|
||||
subresource_index = device->CreateSubresource(&rtSSR, SRV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtSSR, UAV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
}
|
||||
}
|
||||
{
|
||||
TextureDesc desc;
|
||||
desc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
|
||||
desc.Format = FORMAT_R16G16B16A16_FLOAT;
|
||||
desc.Width = wiRenderer::GetInternalResolution().x;
|
||||
desc.Height = wiRenderer::GetInternalResolution().y;
|
||||
device->CreateTexture(&desc, nullptr, &rtStochasticSSR);
|
||||
device->SetName(&rtStochasticSSR, "rtStochasticSSR");
|
||||
device->CreateTexture(&desc, nullptr, &rtSSR);
|
||||
device->SetName(&rtSSR, "rtSSR");
|
||||
}
|
||||
{
|
||||
TextureDesc desc;
|
||||
@@ -88,14 +69,21 @@ void RenderPath3D::ResizeBuffers()
|
||||
desc.MipLevels = std::min(8u, (uint32_t)std::log2(std::max(desc.Width, desc.Height)));
|
||||
device->CreateTexture(&desc, nullptr, &rtSceneCopy);
|
||||
device->SetName(&rtSceneCopy, "rtSceneCopy");
|
||||
desc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
|
||||
device->CreateTexture(&desc, nullptr, &rtSceneCopy_tmp);
|
||||
device->SetName(&rtSceneCopy_tmp, "rtSceneCopy_tmp");
|
||||
|
||||
for (uint32_t i = 0; i < rtSceneCopy.GetDesc().MipLevels; ++i)
|
||||
{
|
||||
int subresource_index;
|
||||
subresource_index = device->CreateSubresource(&rtSceneCopy, SRV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtSceneCopy_tmp, SRV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtSceneCopy, UAV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtSceneCopy_tmp, UAV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -148,20 +136,26 @@ void RenderPath3D::ResizeBuffers()
|
||||
{
|
||||
TextureDesc desc;
|
||||
desc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
|
||||
desc.Format = defaultTextureFormat;
|
||||
desc.Format = FORMAT_R11G11B10_FLOAT;
|
||||
desc.Width = wiRenderer::GetInternalResolution().x / 4;
|
||||
desc.Height = wiRenderer::GetInternalResolution().y / 4;
|
||||
desc.MipLevels = 5;
|
||||
desc.MipLevels = std::min(5u, (uint32_t)std::log2(std::max(desc.Width, desc.Height)));
|
||||
device->CreateTexture(&desc, nullptr, &rtBloom);
|
||||
device->SetName(&rtBloom, "rtBloom");
|
||||
device->CreateTexture(&desc, nullptr, &rtBloom_tmp);
|
||||
device->SetName(&rtBloom_tmp, "rtBloom_tmp");
|
||||
|
||||
for (uint32_t i = 0; i < rtBloom.GetDesc().MipLevels; ++i)
|
||||
{
|
||||
int subresource_index;
|
||||
subresource_index = device->CreateSubresource(&rtBloom, SRV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtBloom_tmp, SRV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtBloom, UAV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
subresource_index = device->CreateSubresource(&rtBloom_tmp, UAV, 0, 1, i, 1);
|
||||
assert(subresource_index == i);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -445,7 +439,6 @@ void RenderPath3D::RenderSSAO(CommandList cmd) const
|
||||
cmd,
|
||||
getSSAORange(),
|
||||
getSSAOSampleCount(),
|
||||
getSSAOBlur(),
|
||||
getSSAOPower()
|
||||
);
|
||||
}
|
||||
@@ -454,7 +447,7 @@ void RenderPath3D::RenderSSR(const Texture& gbuffer1, const Texture& gbuffer2, C
|
||||
{
|
||||
if (getSSREnabled())
|
||||
{
|
||||
wiRenderer::Postprocess_SSR(rtSceneCopy, depthBuffer_Copy, rtLinearDepth_minmax, gbuffer1, gbuffer2, rtStochasticSSR, cmd);
|
||||
wiRenderer::Postprocess_SSR(rtSceneCopy, depthBuffer_Copy, rtLinearDepth_minmax, gbuffer1, gbuffer2, rtSSR, cmd);
|
||||
}
|
||||
}
|
||||
void RenderPath3D::DownsampleDepthBuffer(CommandList cmd) const
|
||||
@@ -564,7 +557,7 @@ void RenderPath3D::RenderSceneMIPChain(const Texture& srcSceneRT, CommandList cm
|
||||
|
||||
device->RenderPassEnd(cmd);
|
||||
|
||||
wiRenderer::GenerateMipChain(rtSceneCopy, wiRenderer::MIPGENFILTER_GAUSSIAN, cmd);
|
||||
wiRenderer::GenerateMipChain(rtSceneCopy, wiRenderer::MIPGENFILTER_GAUSSIAN, cmd, -1, &rtSceneCopy_tmp);
|
||||
|
||||
device->EventEnd(cmd);
|
||||
wiProfiler::EndRange(range);
|
||||
@@ -701,7 +694,7 @@ void RenderPath3D::RenderPostprocessChain(const Texture& srcSceneRT, const Textu
|
||||
|
||||
if (getBloomEnabled())
|
||||
{
|
||||
wiRenderer::Postprocess_Bloom(rt_first == nullptr ? *rt_read : *rt_first, rtBloom, *rt_write, cmd, getBloomThreshold());
|
||||
wiRenderer::Postprocess_Bloom(rt_first == nullptr ? *rt_read : *rt_first, rtBloom, rtBloom_tmp, *rt_write, cmd, getBloomThreshold());
|
||||
rt_first = nullptr;
|
||||
|
||||
std::swap(rt_read, rt_write);
|
||||
@@ -719,7 +712,9 @@ void RenderPath3D::RenderPostprocessChain(const Texture& srcSceneRT, const Textu
|
||||
getMSAASampleCount() > 1 ? rtParticleDistortion_Resolved : rtParticleDistortion,
|
||||
*rt_write,
|
||||
cmd,
|
||||
getExposure()
|
||||
getExposure(),
|
||||
getDitherEnabled(),
|
||||
getColorGradingEnabled() ? (colorGradingTex != nullptr ? colorGradingTex->texture : wiTextureHelper::getColorGradeDefault()) : nullptr
|
||||
);
|
||||
|
||||
rt_read = rt_write;
|
||||
@@ -737,19 +732,6 @@ void RenderPath3D::RenderPostprocessChain(const Texture& srcSceneRT, const Textu
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, cmd);
|
||||
}
|
||||
|
||||
if (getColorGradingEnabled())
|
||||
{
|
||||
wiRenderer::Postprocess_Colorgrade(
|
||||
*rt_read,
|
||||
colorGradingTex != nullptr ? *colorGradingTex->texture : *wiTextureHelper::getColorGradeDefault(),
|
||||
*rt_write,
|
||||
cmd
|
||||
);
|
||||
|
||||
std::swap(rt_read, rt_write);
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, cmd);
|
||||
}
|
||||
|
||||
if (getFXAAEnabled())
|
||||
{
|
||||
wiRenderer::Postprocess_FXAA(*rt_read, *rt_write, cmd);
|
||||
|
||||
@@ -12,7 +12,6 @@ class RenderPath3D :
|
||||
private:
|
||||
float exposure = 1.0f;
|
||||
float bloomThreshold = 1.0f;
|
||||
float ssaoBlur = 2.3f;
|
||||
float motionBlurStrength = 100.0f;
|
||||
float dofFocus = 10.0f;
|
||||
float dofStrength = 1.0f;
|
||||
@@ -44,6 +43,7 @@ private:
|
||||
bool sharpenFilterEnabled = false;
|
||||
bool outlineEnabled = false;
|
||||
bool chromaticAberrationEnabled = false;
|
||||
bool ditherEnabled = true;
|
||||
|
||||
std::shared_ptr<wiResource> colorGradingTex;
|
||||
|
||||
@@ -52,14 +52,15 @@ private:
|
||||
protected:
|
||||
wiGraphics::Texture rtReflection; // conains the scene rendered for planar reflections
|
||||
wiGraphics::Texture rtSSR; // standard screen-space reflection results
|
||||
wiGraphics::Texture rtStochasticSSR; // stochastic screen-space reflection results
|
||||
wiGraphics::Texture rtSceneCopy; // contains the rendered scene that can be fed into transparent pass for distortion effect
|
||||
wiGraphics::Texture rtSceneCopy_tmp; // temporary for gaussian mipchain
|
||||
wiGraphics::Texture rtWaterRipple; // water ripple sprite normal maps are rendered into this
|
||||
wiGraphics::Texture rtParticleDistortion; // contains distortive particles
|
||||
wiGraphics::Texture rtParticleDistortion_Resolved; // contains distortive particles
|
||||
wiGraphics::Texture rtVolumetricLights; // contains the volumetric light results
|
||||
wiGraphics::Texture rtTemporalAA[2]; // temporal AA history buffer
|
||||
wiGraphics::Texture rtBloom; // contains the bright parts of the image + mipchain
|
||||
wiGraphics::Texture rtBloom_tmp; // temporary for bloom downsampling
|
||||
wiGraphics::Texture rtSSAO[2]; // ping-pong when rendering and blurring SSAO
|
||||
wiGraphics::Texture rtSun[2]; // 0: sun render target used for lightshafts (can be MSAA), 1: radial blurred lightshafts
|
||||
wiGraphics::Texture rtSun_resolved; // sun render target, but the resolved version if MSAA is enabled
|
||||
@@ -88,7 +89,6 @@ protected:
|
||||
{
|
||||
int ldr_postprocess_count = 0;
|
||||
ldr_postprocess_count += sharpenFilterEnabled ? 1 : 0;
|
||||
ldr_postprocess_count += colorGradingEnabled ? 1 : 0;
|
||||
ldr_postprocess_count += fxaaEnabled ? 1 : 0;
|
||||
ldr_postprocess_count += chromaticAberrationEnabled ? 1 : 0;
|
||||
int rt_index = ldr_postprocess_count % 2;
|
||||
@@ -117,7 +117,6 @@ public:
|
||||
|
||||
constexpr float getExposure() const { return exposure; }
|
||||
constexpr float getBloomThreshold() const { return bloomThreshold; }
|
||||
constexpr float getSSAOBlur() const { return ssaoBlur; }
|
||||
constexpr float getMotionBlurStrength() const { return motionBlurStrength; }
|
||||
constexpr float getDepthOfFieldFocus() const { return dofFocus; }
|
||||
constexpr float getDepthOfFieldStrength() const { return dofStrength; }
|
||||
@@ -149,6 +148,7 @@ public:
|
||||
constexpr bool getSharpenFilterEnabled() const { return sharpenFilterEnabled && getSharpenFilterAmount() > 0; }
|
||||
constexpr bool getOutlineEnabled() const { return outlineEnabled; }
|
||||
constexpr bool getChromaticAberrationEnabled() const { return chromaticAberrationEnabled; }
|
||||
constexpr bool getDitherEnabled() const { return ditherEnabled; }
|
||||
|
||||
constexpr const std::shared_ptr<wiResource>& getColorGradingTexture() const { return colorGradingTex; }
|
||||
|
||||
@@ -156,7 +156,6 @@ public:
|
||||
|
||||
constexpr void setExposure(float value) { exposure = value; }
|
||||
constexpr void setBloomThreshold(float value){ bloomThreshold = value; }
|
||||
constexpr void setSSAOBlur(float value){ ssaoBlur = value; }
|
||||
constexpr void setMotionBlurStrength(float value) { motionBlurStrength = value; }
|
||||
constexpr void setDepthOfFieldFocus(float value){ dofFocus = value; }
|
||||
constexpr void setDepthOfFieldStrength(float value) { dofStrength = value; }
|
||||
@@ -188,6 +187,7 @@ public:
|
||||
constexpr void setSharpenFilterEnabled(bool value) { sharpenFilterEnabled = value; }
|
||||
constexpr void setOutlineEnabled(bool value) { outlineEnabled = value; }
|
||||
constexpr void setChromaticAberrationEnabled(bool value) { chromaticAberrationEnabled = value; }
|
||||
constexpr void setDitherEnabled(bool value) { ditherEnabled = value; }
|
||||
|
||||
void setColorGradingTexture(std::shared_ptr<wiResource> resource) { colorGradingTex = resource; }
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ void RenderPath3D_Deferred::Render() const
|
||||
device->BindViewports(1, &vp, cmd);
|
||||
|
||||
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO[0] : wiTextureHelper::getWhite(), TEXSLOT_RENDERPATH_SSAO, cmd);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtStochasticSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
wiRenderer::DrawDeferredLights(wiRenderer::GetCamera(), depthBuffer_Copy, rtGBuffer[0], rtGBuffer[1], rtGBuffer[2], cmd);
|
||||
|
||||
device->RenderPassEnd(cmd);
|
||||
|
||||
@@ -171,7 +171,7 @@ void RenderPath3D_Forward::Render() const
|
||||
|
||||
device->BindResource(PS, getReflectionsEnabled() ? &rtReflection : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_REFLECTION, cmd);
|
||||
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO[0] : wiTextureHelper::getWhite(), TEXSLOT_RENDERPATH_SSAO, cmd);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtStochasticSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), cmd, RENDERPASS_FORWARD, true, true);
|
||||
wiRenderer::DrawSky(cmd);
|
||||
|
||||
|
||||
@@ -149,7 +149,9 @@ void RenderPath3D_PathTracing::Render() const
|
||||
*wiTextureHelper::getBlack(),
|
||||
rtPostprocess_LDR[0],
|
||||
cmd,
|
||||
getExposure()
|
||||
getExposure(),
|
||||
false,
|
||||
nullptr
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ void RenderPath3D_TiledDeferred::Render() const
|
||||
RenderDecals(cmd);
|
||||
|
||||
device->BindResource(CS, getSSAOEnabled() ? &rtSSAO[0] : wiTextureHelper::getWhite(), TEXSLOT_RENDERPATH_SSAO, cmd);
|
||||
device->BindResource(CS, getSSREnabled() ? &rtStochasticSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
device->BindResource(CS, getSSREnabled() ? &rtSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
|
||||
|
||||
if (device->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_UAV_LOAD_FORMAT_R11G11B10_FLOAT))
|
||||
|
||||
@@ -101,7 +101,7 @@ void RenderPath3D_TiledForward::Render() const
|
||||
|
||||
device->BindResource(PS, getReflectionsEnabled() ? &rtReflection : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_REFLECTION, cmd);
|
||||
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO[0] : wiTextureHelper::getWhite(), TEXSLOT_RENDERPATH_SSAO, cmd);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtStochasticSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, cmd);
|
||||
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), cmd, RENDERPASS_TILEDFORWARD, true, true);
|
||||
wiRenderer::DrawSky(cmd);
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
|
||||
static const uint POSTPROCESS_BLOCKSIZE = 8;
|
||||
static const uint POSTPROCESS_LINEARDEPTH_BLOCKSIZE = 16;
|
||||
static const uint POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT = 256;
|
||||
|
||||
CBUFFER(PostProcessCB, CBSLOT_RENDERER_POSTPROCESS)
|
||||
{
|
||||
uint2 xPPResolution;
|
||||
float2 xPPResolution_rcp;
|
||||
float4 xPPParams0;
|
||||
float4 xPPParams1;
|
||||
uint2 xPPResolution;
|
||||
float2 xPPResolution_rcp;
|
||||
float4 xPPParams0;
|
||||
float4 xPPParams1;
|
||||
};
|
||||
|
||||
#define lineardepth_inputresolution xPPParams0.xy
|
||||
@@ -29,6 +30,10 @@ static const uint DEPTHOFFIELD_TILESIZE = 32;
|
||||
#define dof_aspect xPPParams0.z
|
||||
#define dof_maxcoc xPPParams0.w
|
||||
|
||||
#define tonemap_exposure xPPParams0.x
|
||||
#define tonemap_dither xPPParams0.y
|
||||
#define tonemap_colorgrading xPPParams0.z
|
||||
|
||||
static const uint TILE_STATISTICS_OFFSET_EARLYEXIT = 0;
|
||||
static const uint TILE_STATISTICS_OFFSET_CHEAP = TILE_STATISTICS_OFFSET_EARLYEXIT + 4;
|
||||
static const uint TILE_STATISTICS_OFFSET_EXPENSIVE = TILE_STATISTICS_OFFSET_CHEAP + 4;
|
||||
|
||||
@@ -81,9 +81,6 @@
|
||||
<FxCompile Include="circlePS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||
</FxCompile>
|
||||
<FxCompile Include="colorgradeCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
</FxCompile>
|
||||
<FxCompile Include="copytexture2D_float4CS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
@@ -211,10 +208,6 @@
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_unorm4_GaussianCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_unorm4_SimpleFilterCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
@@ -331,10 +324,6 @@
|
||||
<FxCompile Include="fxaaCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_float4_GaussianCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_float4_SimpleFilterCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
|
||||
@@ -603,18 +603,12 @@
|
||||
<FxCompile Include="copytexture2D_unorm4_borderexpandCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_float4_GaussianCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_float4_SimpleFilterCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain3D_float4_SimpleFilterCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_unorm4_GaussianCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="generateMIPChain2D_unorm4_SimpleFilterCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
@@ -741,9 +735,6 @@
|
||||
<FxCompile Include="fxaaCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="colorgradeCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="lineardepthCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
TEXTURE2D(input, float4, TEXSLOT_ONDEMAND0);
|
||||
|
||||
RWTEXTURE2D(output, unorm float4, 0);
|
||||
RWTEXTURE2D(output, float4, 0);
|
||||
|
||||
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define UPSAMPLE_FORMAT float
|
||||
#define BLUR_FORMAT float
|
||||
#include "blur_bilateral_float4CS.hlsl"
|
||||
|
||||
@@ -1,34 +1,2 @@
|
||||
#include "globals.hlsli"
|
||||
#include "ShaderInterop_Postprocess.h"
|
||||
|
||||
#ifndef BLUR_FORMAT
|
||||
#define BLUR_FORMAT float4
|
||||
#endif // BLUR_FORMAT
|
||||
|
||||
TEXTURE2D(input, BLUR_FORMAT, TEXSLOT_ONDEMAND0);
|
||||
|
||||
RWTEXTURE2D(output, BLUR_FORMAT, 0);
|
||||
|
||||
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
{
|
||||
const float2 direction = xPPParams0.xy;
|
||||
const float mip = xPPParams0.z;
|
||||
const float depth_threshold = xPPParams0.w;
|
||||
|
||||
const float2 uv = (DTid.xy + 0.5f) * xPPResolution_rcp;
|
||||
|
||||
const float center_depth = texture_lineardepth.SampleLevel(sampler_point_clamp, uv, 0);
|
||||
const BLUR_FORMAT center_color = input.SampleLevel(sampler_linear_clamp, uv, mip);
|
||||
|
||||
BLUR_FORMAT color = 0;
|
||||
for (uint i = 0; i < 9; ++i)
|
||||
{
|
||||
const float2 uv2 = uv + direction * gaussianOffsets[i] * xPPResolution_rcp;
|
||||
const float depth = texture_lineardepth.SampleLevel(sampler_point_clamp, uv2, 0);
|
||||
const float weight = saturate(abs(depth - center_depth) * g_xCamera_ZFarP * depth_threshold);
|
||||
color += lerp(input.SampleLevel(sampler_linear_clamp, uv2, mip), center_color, weight) * gaussianWeightsNormalized[i];
|
||||
}
|
||||
|
||||
output[DTid.xy] = color;
|
||||
}
|
||||
#define BILATERAL
|
||||
#include "blur_gaussian_float4CS.hlsl"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define UPSAMPLE_FORMAT unorm float
|
||||
#define BLUR_FORMAT unorm float
|
||||
#include "blur_bilateral_float4CS.hlsl"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define UPSAMPLE_FORMAT unorm float4
|
||||
#define BLUR_FORMAT unorm float4
|
||||
#include "blur_bilateral_float4CS.hlsl"
|
||||
|
||||
@@ -9,17 +9,85 @@ TEXTURE2D(input, BLUR_FORMAT, TEXSLOT_ONDEMAND0);
|
||||
|
||||
RWTEXTURE2D(output, BLUR_FORMAT, 0);
|
||||
|
||||
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
{
|
||||
const float2 direction = xPPParams0.xy;
|
||||
const float mip = xPPParams0.z;
|
||||
static const int TILE_BORDER = 4;
|
||||
static const int CACHE_SIZE = TILE_BORDER + POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT + TILE_BORDER;
|
||||
groupshared BLUR_FORMAT color_cache[CACHE_SIZE];
|
||||
|
||||
BLUR_FORMAT color = 0;
|
||||
for (uint i = 0; i < 9; ++i)
|
||||
#ifdef BILATERAL
|
||||
groupshared float depth_cache[CACHE_SIZE];
|
||||
#endif // BILATERAL
|
||||
|
||||
static const float gaussWeight0 = 1.0f;
|
||||
static const float gaussWeight1 = 0.9f;
|
||||
static const float gaussWeight2 = 0.55f;
|
||||
static const float gaussWeight3 = 0.18f;
|
||||
static const float gaussWeight4 = 0.1f;
|
||||
static const float gaussNormalization = 1.0f / (gaussWeight0 + 2.0f * (gaussWeight1 + gaussWeight2 + gaussWeight3 + gaussWeight4));
|
||||
static const float gaussianWeightsNormalized[9] = {
|
||||
gaussWeight4 * gaussNormalization,
|
||||
gaussWeight3 * gaussNormalization,
|
||||
gaussWeight2 * gaussNormalization,
|
||||
gaussWeight1 * gaussNormalization,
|
||||
gaussWeight0 * gaussNormalization,
|
||||
gaussWeight1 * gaussNormalization,
|
||||
gaussWeight2 * gaussNormalization,
|
||||
gaussWeight3 * gaussNormalization,
|
||||
gaussWeight4 * gaussNormalization,
|
||||
};
|
||||
static const int gaussianOffsets[9] = {
|
||||
-4, -3, -2, -1, 0, 1, 2, 3, 4
|
||||
};
|
||||
|
||||
[numthreads(POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT, 1, 1)]
|
||||
void main(uint3 Gid : SV_GroupID, uint groupIndex : SV_GroupIndex)
|
||||
{
|
||||
float2 direction = xPPParams0.xy;
|
||||
const bool horizontal = direction.y == 0;
|
||||
|
||||
uint2 tile_start = Gid.xy;
|
||||
[flatten]
|
||||
if (horizontal)
|
||||
{
|
||||
color += input.SampleLevel(sampler_linear_clamp, (DTid.xy + 0.5f + direction * gaussianOffsets[i]) * xPPResolution_rcp, mip) * gaussianWeightsNormalized[i];
|
||||
tile_start.x *= POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
tile_start.y *= POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT;
|
||||
}
|
||||
|
||||
output[DTid.xy] = color;
|
||||
int i;
|
||||
for (i = groupIndex; i < CACHE_SIZE; i += POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT)
|
||||
{
|
||||
const float2 uv = (tile_start + 0.5f + direction * (i - TILE_BORDER)) * xPPResolution_rcp;
|
||||
color_cache[i] = input.SampleLevel(sampler_linear_clamp, uv, 0);
|
||||
#ifdef BILATERAL
|
||||
depth_cache[i] = texture_lineardepth.SampleLevel(sampler_point_clamp, uv, 0);
|
||||
#endif // BILATERAL
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
const int center = TILE_BORDER + groupIndex;
|
||||
|
||||
#ifdef BILATERAL
|
||||
const float depth_threshold = xPPParams0.w;
|
||||
const float center_depth = depth_cache[center];
|
||||
const BLUR_FORMAT center_color = color_cache[center];
|
||||
#endif // BILATERAL
|
||||
|
||||
BLUR_FORMAT color = 0;
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
const uint sam = center + gaussianOffsets[i];
|
||||
const BLUR_FORMAT color2 = color_cache[sam];
|
||||
#ifdef BILATERAL
|
||||
const float depth = depth_cache[sam];
|
||||
const float weight = saturate(abs(depth - center_depth) * g_xCamera_ZFarP * depth_threshold);
|
||||
color += lerp(color2, center_color, weight) * gaussianWeightsNormalized[i];
|
||||
#else
|
||||
color += color2 * gaussianWeightsNormalized[i];
|
||||
#endif // BILATERAL
|
||||
}
|
||||
|
||||
const int2 pixel = tile_start + groupIndex * direction;
|
||||
output[pixel] = color;
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#include "globals.hlsli"
|
||||
#include "ShaderInterop_Postprocess.h"
|
||||
|
||||
TEXTURE2D(input, float4, TEXSLOT_ONDEMAND0);
|
||||
TEXTURE2D(lookuptable, float4, TEXSLOT_ONDEMAND1);
|
||||
|
||||
RWTEXTURE2D(output, unorm float4, 0);
|
||||
|
||||
float4 sampleAs3DTexture(in float3 uv, in float width)
|
||||
{
|
||||
float sliceSize = 1.0 / width; // space of 1 slice
|
||||
float slicePixelSize = sliceSize / width; // space of 1 pixel
|
||||
float sliceInnerSize = slicePixelSize * (width - 1.0); // space of width pixels
|
||||
float zSlice0 = min(floor(uv.z * width), width - 1.0);
|
||||
float zSlice1 = min(zSlice0 + 1.0, width - 1.0);
|
||||
float xOffset = slicePixelSize * 0.5 + uv.x * sliceInnerSize;
|
||||
float s0 = xOffset + (zSlice0 * sliceSize);
|
||||
float s1 = xOffset + (zSlice1 * sliceSize);
|
||||
float4 slice0Color = lookuptable.SampleLevel(sampler_linear_clamp, float2(s0, uv.y),0);
|
||||
float4 slice1Color = lookuptable.SampleLevel(sampler_linear_clamp, float2(s1, uv.y),0);
|
||||
float zOffset = (uv.z * width) % 1.0;
|
||||
float4 result = lerp(slice0Color, slice1Color, zOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
{
|
||||
const float2 uv = (DTid.xy + 0.5f) * xPPResolution_rcp;
|
||||
|
||||
float4 color = input.SampleLevel(sampler_linear_clamp, uv, 0);
|
||||
|
||||
float2 dim;
|
||||
lookuptable.GetDimensions(dim.x, dim.y);
|
||||
output[DTid.xy] = sampleAs3DTexture(color.rgb, dim.y);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#include "globals.hlsli"
|
||||
#include "ShaderInterop_Utility.h"
|
||||
|
||||
#ifndef MIP_OUTPUT_FORMAT
|
||||
#define MIP_OUTPUT_FORMAT float4
|
||||
#endif
|
||||
|
||||
TEXTURE2D(input, float4, TEXSLOT_UNIQUE0);
|
||||
RWTEXTURE2D(output, MIP_OUTPUT_FORMAT, 0);
|
||||
|
||||
static const uint TILE_BORDER = 4;
|
||||
static const uint TILE_SIZE = TILE_BORDER + GENERATEMIPCHAIN_2D_BLOCK_SIZE + TILE_BORDER;
|
||||
groupshared float4 tile[TILE_SIZE * TILE_SIZE];
|
||||
|
||||
[numthreads(GENERATEMIPCHAIN_2D_BLOCK_SIZE, GENERATEMIPCHAIN_2D_BLOCK_SIZE, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint3 Gid : SV_GroupID)
|
||||
{
|
||||
uint i;
|
||||
|
||||
// First, we prewarm the tile cache, including border region:
|
||||
const int2 tile_upperleft = Gid.xy * GENERATEMIPCHAIN_2D_BLOCK_SIZE - TILE_BORDER;
|
||||
const int2 co[] = {
|
||||
uint2(0, 0), uint2(1, 0),
|
||||
uint2(0, 1), uint2(1, 1)
|
||||
};
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
const int2 coord = GTid.xy * 2 + co[i];
|
||||
const float2 uv = (tile_upperleft + coord + 0.5f) * (float2)outputResolution_rcp.xy;
|
||||
tile[flatten2D(coord, TILE_SIZE)] = input.SampleLevel(sampler_linear_clamp, uv, 0);
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
const int2 thread_to_cache = GTid.xy + TILE_BORDER;
|
||||
|
||||
float4 sum = 0;
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
float4 sumY = 0;
|
||||
for (uint j = 0; j < 9; ++j)
|
||||
{
|
||||
const uint2 coord = thread_to_cache + int2(gaussianOffsets[i], gaussianOffsets[j]);
|
||||
sumY += tile[flatten2D(coord, TILE_SIZE)] * gaussianWeightsNormalized[j];
|
||||
}
|
||||
sum += sumY * gaussianWeightsNormalized[i];
|
||||
}
|
||||
|
||||
if (DTid.x < outputResolution.x && DTid.y < outputResolution.y)
|
||||
{
|
||||
// Each valid thread writes out one pixel:
|
||||
output[DTid.xy] = sum;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#define MIP_OUTPUT_FORMAT unorm float4
|
||||
|
||||
#include "generateMIPChain2D_float4_GaussianCS.hlsl"
|
||||
|
||||
@@ -48,27 +48,6 @@ SAMPLERSTATE( sampler_objectshader, SSLOT_OBJECTSHADER )
|
||||
static const float PI = 3.14159265358979323846;
|
||||
static const float SQRT2 = 1.41421356237309504880;
|
||||
|
||||
static const float gaussWeight0 = 1.0f;
|
||||
static const float gaussWeight1 = 0.9f;
|
||||
static const float gaussWeight2 = 0.55f;
|
||||
static const float gaussWeight3 = 0.18f;
|
||||
static const float gaussWeight4 = 0.1f;
|
||||
static const float gaussNormalization = 1.0f / (gaussWeight0 + 2.0f * (gaussWeight1 + gaussWeight2 + gaussWeight3 + gaussWeight4));
|
||||
static const float gaussianWeightsNormalized[9] = {
|
||||
gaussWeight4 * gaussNormalization,
|
||||
gaussWeight3 * gaussNormalization,
|
||||
gaussWeight2 * gaussNormalization,
|
||||
gaussWeight1 * gaussNormalization,
|
||||
gaussWeight0 * gaussNormalization,
|
||||
gaussWeight1 * gaussNormalization,
|
||||
gaussWeight2 * gaussNormalization,
|
||||
gaussWeight3 * gaussNormalization,
|
||||
gaussWeight4 * gaussNormalization,
|
||||
};
|
||||
static const int gaussianOffsets[9] = {
|
||||
-4, -3, -2, -1, 0, 1, 2, 3, 4
|
||||
};
|
||||
|
||||
#define sqr(a) ((a)*(a))
|
||||
|
||||
inline bool is_saturated(float a) { return a == saturate(a); }
|
||||
|
||||
@@ -4,9 +4,27 @@
|
||||
TEXTURE2D(input, float4, TEXSLOT_ONDEMAND0);
|
||||
TEXTURE2D(input_luminance, float, TEXSLOT_ONDEMAND1);
|
||||
TEXTURE2D(input_distortion, float4, TEXSLOT_ONDEMAND2);
|
||||
TEXTURE2D(colorgrade_lookuptable, float4, TEXSLOT_ONDEMAND3);
|
||||
|
||||
RWTEXTURE2D(output, unorm float4, 0);
|
||||
|
||||
float4 sampleAs3DTexture(in float3 uv, in float width)
|
||||
{
|
||||
float sliceSize = 1.0 / width; // space of 1 slice
|
||||
float slicePixelSize = sliceSize / width; // space of 1 pixel
|
||||
float sliceInnerSize = slicePixelSize * (width - 1.0); // space of width pixels
|
||||
float zSlice0 = min(floor(uv.z * width), width - 1.0);
|
||||
float zSlice1 = min(zSlice0 + 1.0, width - 1.0);
|
||||
float xOffset = slicePixelSize * 0.5 + uv.x * sliceInnerSize;
|
||||
float s0 = xOffset + (zSlice0 * sliceSize);
|
||||
float s1 = xOffset + (zSlice1 * sliceSize);
|
||||
float4 slice0Color = colorgrade_lookuptable.SampleLevel(sampler_linear_clamp, float2(s0, uv.y), 0);
|
||||
float4 slice1Color = colorgrade_lookuptable.SampleLevel(sampler_linear_clamp, float2(s1, uv.y), 0);
|
||||
float zOffset = (uv.z * width) % 1.0;
|
||||
float4 result = lerp(slice0Color, slice1Color, zOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
{
|
||||
@@ -27,8 +45,18 @@ void main(uint3 DTid : SV_DispatchThreadID)
|
||||
|
||||
ldr.rgb = GAMMA(ldr.rgb);
|
||||
|
||||
// dithering before outputting to SDR will reduce color banding:
|
||||
ldr.rgb += (dither((float2)DTid.xy) - 0.5f) / 64.0f;
|
||||
if (tonemap_colorgrading)
|
||||
{
|
||||
float2 dim;
|
||||
colorgrade_lookuptable.GetDimensions(dim.x, dim.y);
|
||||
ldr.rgb = sampleAs3DTexture(ldr.rgb, dim.y).rgb;
|
||||
}
|
||||
|
||||
if (tonemap_dither)
|
||||
{
|
||||
// dithering before outputting to SDR will reduce color banding:
|
||||
ldr.rgb += (dither((float2)DTid.xy) - 0.5f) / 64.0f;
|
||||
}
|
||||
|
||||
output[DTid.xy] = ldr;
|
||||
}
|
||||
@@ -268,8 +268,6 @@ enum CSTYPES
|
||||
CSTYPE_VOXELCLEARONLYNORMAL,
|
||||
CSTYPE_GENERATEMIPCHAIN2D_UNORM4_SIMPLEFILTER,
|
||||
CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_SIMPLEFILTER,
|
||||
CSTYPE_GENERATEMIPCHAIN2D_UNORM4_GAUSSIAN,
|
||||
CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_GAUSSIAN,
|
||||
CSTYPE_GENERATEMIPCHAIN2D_UNORM4_BICUBIC,
|
||||
CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_BICUBIC,
|
||||
CSTYPE_GENERATEMIPCHAIN3D_UNORM4_SIMPLEFILTER,
|
||||
@@ -328,7 +326,6 @@ enum CSTYPES
|
||||
CSTYPE_POSTPROCESS_BLOOMCOMBINE,
|
||||
CSTYPE_POSTPROCESS_FXAA,
|
||||
CSTYPE_POSTPROCESS_TEMPORALAA,
|
||||
CSTYPE_POSTPROCESS_COLORGRADE,
|
||||
CSTYPE_POSTPROCESS_LINEARDEPTH,
|
||||
CSTYPE_POSTPROCESS_SHARPEN,
|
||||
CSTYPE_POSTPROCESS_TONEMAP,
|
||||
|
||||
+71
-104
@@ -1299,8 +1299,6 @@ void LoadShaders()
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_VOXELCLEARONLYNORMAL], "voxelClearOnlyNormalCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN2D_UNORM4_SIMPLEFILTER], "generateMIPChain2D_unorm4_SimpleFilterCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_SIMPLEFILTER], "generateMIPChain2D_float4_SimpleFilterCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN2D_UNORM4_GAUSSIAN], "generateMIPChain2D_unorm4_GaussianCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_GAUSSIAN], "generateMIPChain2D_float4_GaussianCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN2D_UNORM4_BICUBIC], "generateMIPChain2D_unorm4_BicubicCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_BICUBIC], "generateMIPChain2D_float4_BicubicCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_GENERATEMIPCHAIN3D_UNORM4_SIMPLEFILTER], "generateMIPChain3D_unorm4_SimpleFilterCS.cso"); });
|
||||
@@ -1360,7 +1358,6 @@ void LoadShaders()
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_BLOOMCOMBINE], "bloomcombineCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_FXAA], "fxaaCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_TEMPORALAA], "temporalaaCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_COLORGRADE], "colorgradeCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_LINEARDEPTH], "lineardepthCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_SHARPEN], "sharpenCS.cso"); });
|
||||
wiJobSystem::Execute(ctx, [] { LoadShader(CS, computeShaders[CSTYPE_POSTPROCESS_TONEMAP], "tonemapCS.cso"); });
|
||||
@@ -7103,7 +7100,7 @@ void DownsampleDepthBuffer(const wiGraphics::Texture& src, wiGraphics::CommandLi
|
||||
device->EventEnd(cmd);
|
||||
}
|
||||
|
||||
void GenerateMipChain(const Texture& texture, MIPGENFILTER filter, CommandList cmd, int arrayIndex)
|
||||
void GenerateMipChain(const Texture& texture, MIPGENFILTER filter, CommandList cmd, int arrayIndex, const Texture* gaussian_temp)
|
||||
{
|
||||
GraphicsDevice* device = GetDevice();
|
||||
TextureDesc desc = texture.GetDesc();
|
||||
@@ -7237,8 +7234,17 @@ void GenerateMipChain(const Texture& texture, MIPGENFILTER filter, CommandList c
|
||||
device->BindSampler(CS, &samplers[SSLOT_LINEAR_CLAMP], SSLOT_ONDEMAND0, cmd);
|
||||
break;
|
||||
case MIPGENFILTER_GAUSSIAN:
|
||||
{
|
||||
assert(gaussian_temp != nullptr); // needed for separate filter!
|
||||
device->EventBegin("GenerateMipChain 2D - GaussianFilter", cmd);
|
||||
device->BindComputeShader(&computeShaders[hdr ? CSTYPE_GENERATEMIPCHAIN2D_FLOAT4_GAUSSIAN : CSTYPE_GENERATEMIPCHAIN2D_UNORM4_GAUSSIAN], cmd);
|
||||
// Gaussian filter is a bit different as we do it in a separable way:
|
||||
for (uint32_t i = 0; i < desc.MipLevels - 1; ++i)
|
||||
{
|
||||
Postprocess_Blur_Gaussian(texture, *gaussian_temp, texture, cmd, i, i + 1);
|
||||
}
|
||||
device->EventEnd(cmd);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case MIPGENFILTER_BICUBIC:
|
||||
device->EventBegin("GenerateMipChain 2D - BicubicFilter", cmd);
|
||||
@@ -8512,9 +8518,8 @@ void Postprocess_Blur_Gaussian(
|
||||
const Texture& temp,
|
||||
const Texture& output,
|
||||
CommandList cmd,
|
||||
float amountX,
|
||||
float amountY,
|
||||
float mip
|
||||
int mip_src,
|
||||
int mip_dst
|
||||
)
|
||||
{
|
||||
GraphicsDevice* device = GetDevice();
|
||||
@@ -8533,6 +8538,7 @@ void Postprocess_Blur_Gaussian(
|
||||
break;
|
||||
case FORMAT_R16G16B16A16_UNORM:
|
||||
case FORMAT_R8G8B8A8_UNORM:
|
||||
case FORMAT_R10G10B10A2_UNORM:
|
||||
cs = CSTYPE_POSTPROCESS_BLUR_GAUSSIAN_UNORM4;
|
||||
break;
|
||||
case FORMAT_R11G11B10_FLOAT:
|
||||
@@ -8554,29 +8560,29 @@ void Postprocess_Blur_Gaussian(
|
||||
PostProcessCB cb;
|
||||
cb.xPPResolution.x = desc.Width;
|
||||
cb.xPPResolution.y = desc.Height;
|
||||
if (mip_dst > 0)
|
||||
{
|
||||
cb.xPPResolution.x >>= mip_dst;
|
||||
cb.xPPResolution.y >>= mip_dst;
|
||||
}
|
||||
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
|
||||
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
|
||||
cb.xPPParams0.x = amountX;
|
||||
cb.xPPParams0.x = 1;
|
||||
cb.xPPParams0.y = 0;
|
||||
cb.xPPParams0.z = mip;
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
|
||||
|
||||
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
&temp,
|
||||
};
|
||||
device->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);
|
||||
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd, mip_src);
|
||||
device->BindUAV(CS, &temp, 0, cmd, mip_dst);
|
||||
|
||||
device->Dispatch(
|
||||
(desc.Width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(desc.Height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(cb.xPPResolution.x + POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT - 1) / POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT,
|
||||
cb.xPPResolution.y,
|
||||
1,
|
||||
cmd
|
||||
);
|
||||
|
||||
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
|
||||
device->UnbindUAVs(0, arraysize(uavs), cmd);
|
||||
device->UnbindUAVs(0, 1, cmd);
|
||||
}
|
||||
|
||||
// Vertical:
|
||||
@@ -8586,29 +8592,29 @@ void Postprocess_Blur_Gaussian(
|
||||
PostProcessCB cb;
|
||||
cb.xPPResolution.x = desc.Width;
|
||||
cb.xPPResolution.y = desc.Height;
|
||||
if (mip_dst > 0)
|
||||
{
|
||||
cb.xPPResolution.x >>= mip_dst;
|
||||
cb.xPPResolution.y >>= mip_dst;
|
||||
}
|
||||
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
|
||||
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
|
||||
cb.xPPParams0.x = 0;
|
||||
cb.xPPParams0.y = amountY;
|
||||
cb.xPPParams0.z = mip;
|
||||
cb.xPPParams0.y = 1;
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
|
||||
|
||||
device->BindResource(CS, &temp, TEXSLOT_ONDEMAND0, cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
&output,
|
||||
};
|
||||
device->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);
|
||||
device->BindResource(CS, &temp, TEXSLOT_ONDEMAND0, cmd, mip_dst); // <- also mip_dst because it's second pass!
|
||||
device->BindUAV(CS, &output, 0, cmd, mip_dst);
|
||||
|
||||
device->Dispatch(
|
||||
(desc.Width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(desc.Height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
cb.xPPResolution.x,
|
||||
(cb.xPPResolution.y + POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT - 1) / POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT,
|
||||
1,
|
||||
cmd
|
||||
);
|
||||
|
||||
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
|
||||
device->UnbindUAVs(0, arraysize(uavs), cmd);
|
||||
device->UnbindUAVs(0, 1, cmd);
|
||||
}
|
||||
|
||||
device->EventEnd(cmd);
|
||||
@@ -8619,10 +8625,9 @@ void Postprocess_Blur_Bilateral(
|
||||
const Texture& temp,
|
||||
const Texture& output,
|
||||
CommandList cmd,
|
||||
float amountX,
|
||||
float amountY,
|
||||
float depth_threshold,
|
||||
float mip
|
||||
int mip_src,
|
||||
int mip_dst
|
||||
)
|
||||
{
|
||||
GraphicsDevice* device = GetDevice();
|
||||
@@ -8642,6 +8647,7 @@ void Postprocess_Blur_Bilateral(
|
||||
break;
|
||||
case FORMAT_R16G16B16A16_UNORM:
|
||||
case FORMAT_R8G8B8A8_UNORM:
|
||||
case FORMAT_R10G10B10A2_UNORM:
|
||||
cs = CSTYPE_POSTPROCESS_BLUR_BILATERAL_UNORM4;
|
||||
break;
|
||||
case FORMAT_R11G11B10_FLOAT:
|
||||
@@ -8665,30 +8671,30 @@ void Postprocess_Blur_Bilateral(
|
||||
PostProcessCB cb;
|
||||
cb.xPPResolution.x = desc.Width;
|
||||
cb.xPPResolution.y = desc.Height;
|
||||
if (mip_dst > 0)
|
||||
{
|
||||
cb.xPPResolution.x >>= mip_dst;
|
||||
cb.xPPResolution.y >>= mip_dst;
|
||||
}
|
||||
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
|
||||
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
|
||||
cb.xPPParams0.x = amountX;
|
||||
cb.xPPParams0.x = 1;
|
||||
cb.xPPParams0.y = 0;
|
||||
cb.xPPParams0.z = mip;
|
||||
cb.xPPParams0.w = depth_threshold;
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
|
||||
|
||||
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
&temp,
|
||||
};
|
||||
device->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);
|
||||
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd, mip_src);
|
||||
device->BindUAV(CS, &temp, 0, cmd, mip_dst);
|
||||
|
||||
device->Dispatch(
|
||||
(desc.Width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(desc.Height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(cb.xPPResolution.x + POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT - 1) / POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT,
|
||||
cb.xPPResolution.y,
|
||||
1,
|
||||
cmd
|
||||
);
|
||||
|
||||
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
|
||||
device->UnbindUAVs(0, arraysize(uavs), cmd);
|
||||
device->UnbindUAVs(0, 1, cmd);
|
||||
}
|
||||
|
||||
// Vertical:
|
||||
@@ -8698,30 +8704,30 @@ void Postprocess_Blur_Bilateral(
|
||||
PostProcessCB cb;
|
||||
cb.xPPResolution.x = desc.Width;
|
||||
cb.xPPResolution.y = desc.Height;
|
||||
if (mip_dst > 0)
|
||||
{
|
||||
cb.xPPResolution.x >>= mip_dst;
|
||||
cb.xPPResolution.y >>= mip_dst;
|
||||
}
|
||||
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
|
||||
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
|
||||
cb.xPPParams0.x = 0;
|
||||
cb.xPPParams0.y = amountY;
|
||||
cb.xPPParams0.z = mip;
|
||||
cb.xPPParams0.y = 1;
|
||||
cb.xPPParams0.w = depth_threshold;
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
|
||||
|
||||
device->BindResource(CS, &temp, TEXSLOT_ONDEMAND0, cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
&output,
|
||||
};
|
||||
device->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);
|
||||
device->BindResource(CS, &temp, TEXSLOT_ONDEMAND0, cmd, mip_dst); // <- also mip_dst because it's second pass!
|
||||
device->BindUAV(CS, &output, 0, cmd, mip_dst);
|
||||
|
||||
device->Dispatch(
|
||||
(desc.Width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(desc.Height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
cb.xPPResolution.x,
|
||||
(cb.xPPResolution.y + POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT - 1) / POSTPROCESS_BLUR_GAUSSIAN_THREADCOUNT,
|
||||
1,
|
||||
cmd
|
||||
);
|
||||
|
||||
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
|
||||
device->UnbindUAVs(0, arraysize(uavs), cmd);
|
||||
device->UnbindUAVs(0, 1, cmd);
|
||||
}
|
||||
|
||||
device->EventEnd(cmd);
|
||||
@@ -8735,7 +8741,6 @@ void Postprocess_SSAO(
|
||||
CommandList cmd,
|
||||
float range,
|
||||
uint32_t samplecount,
|
||||
float blur,
|
||||
float power
|
||||
)
|
||||
{
|
||||
@@ -8780,7 +8785,7 @@ void Postprocess_SSAO(
|
||||
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
|
||||
device->UnbindUAVs(0, arraysize(uavs), cmd);
|
||||
|
||||
Postprocess_Blur_Bilateral(output, lineardepth, temp, output, cmd, blur, blur, 1.2f);
|
||||
Postprocess_Blur_Bilateral(output, lineardepth, temp, output, cmd, 1.2f);
|
||||
|
||||
wiProfiler::EndRange(prof_range);
|
||||
device->EventEnd(cmd);
|
||||
@@ -9728,6 +9733,7 @@ void Postprocess_MotionBlur(
|
||||
void Postprocess_Bloom(
|
||||
const Texture& input,
|
||||
const Texture& bloom,
|
||||
const Texture& bloom_tmp,
|
||||
const Texture& output,
|
||||
CommandList cmd,
|
||||
float threshold
|
||||
@@ -9775,7 +9781,7 @@ void Postprocess_Bloom(
|
||||
}
|
||||
|
||||
device->EventBegin("Bloom Mipchain", cmd);
|
||||
wiRenderer::GenerateMipChain(bloom, wiRenderer::MIPGENFILTER_GAUSSIAN, cmd);
|
||||
wiRenderer::GenerateMipChain(bloom, wiRenderer::MIPGENFILTER_GAUSSIAN, cmd, -1, &bloom_tmp);
|
||||
device->EventEnd(cmd);
|
||||
|
||||
// Combine image with bloom
|
||||
@@ -9911,50 +9917,6 @@ void Postprocess_TemporalAA(
|
||||
wiProfiler::EndRange(range);
|
||||
device->EventEnd(cmd);
|
||||
}
|
||||
void Postprocess_Colorgrade(
|
||||
const Texture& input,
|
||||
const Texture& lookuptable,
|
||||
const Texture& output,
|
||||
CommandList cmd
|
||||
)
|
||||
{
|
||||
GraphicsDevice* device = GetDevice();
|
||||
|
||||
device->EventBegin("Postprocess_Colorgrade", cmd);
|
||||
|
||||
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_COLORGRADE], cmd);
|
||||
|
||||
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
|
||||
device->BindResource(CS, &lookuptable, TEXSLOT_ONDEMAND1, cmd);
|
||||
|
||||
const TextureDesc& desc = output.GetDesc();
|
||||
|
||||
PostProcessCB cb;
|
||||
cb.xPPResolution.x = desc.Width;
|
||||
cb.xPPResolution.y = desc.Height;
|
||||
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
|
||||
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_POSTPROCESS], CB_GETBINDSLOT(PostProcessCB), cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
&output,
|
||||
};
|
||||
device->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);
|
||||
|
||||
|
||||
device->Dispatch(
|
||||
(desc.Width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
(desc.Height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
|
||||
1,
|
||||
cmd
|
||||
);
|
||||
|
||||
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
|
||||
device->UnbindUAVs(0, arraysize(uavs), cmd);
|
||||
|
||||
device->EventEnd(cmd);
|
||||
}
|
||||
void Postprocess_Lineardepth(
|
||||
const Texture& input,
|
||||
const Texture& output_fullres,
|
||||
@@ -10052,7 +10014,9 @@ void Postprocess_Tonemap(
|
||||
const Texture& input_distortion,
|
||||
const Texture& output,
|
||||
CommandList cmd,
|
||||
float exposure
|
||||
float exposure,
|
||||
bool dither,
|
||||
const Texture* colorgrade_lookuptable
|
||||
)
|
||||
{
|
||||
GraphicsDevice* device = GetDevice();
|
||||
@@ -10064,6 +10028,7 @@ void Postprocess_Tonemap(
|
||||
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
|
||||
device->BindResource(CS, &input_luminance, TEXSLOT_ONDEMAND1, cmd);
|
||||
device->BindResource(CS, &input_distortion, TEXSLOT_ONDEMAND2, cmd);
|
||||
device->BindResource(CS, colorgrade_lookuptable, TEXSLOT_ONDEMAND3, cmd);
|
||||
|
||||
const TextureDesc& desc = output.GetDesc();
|
||||
|
||||
@@ -10072,7 +10037,9 @@ void Postprocess_Tonemap(
|
||||
cb.xPPResolution.y = desc.Height;
|
||||
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
|
||||
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
|
||||
cb.xPPParams0.x = exposure;
|
||||
cb.tonemap_exposure = exposure;
|
||||
cb.tonemap_dither = dither ? 1.0f : 0.0f;
|
||||
cb.tonemap_colorgrading = colorgrade_lookuptable == nullptr ? 0.0f : 1.0f;
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_POSTPROCESS], CB_GETBINDSLOT(PostProcessCB), cmd);
|
||||
|
||||
|
||||
@@ -173,9 +173,8 @@ namespace wiRenderer
|
||||
const wiGraphics::Texture& temp,
|
||||
const wiGraphics::Texture& output,
|
||||
wiGraphics::CommandList cmd,
|
||||
float amountX = 1.0f,
|
||||
float amountY = 1.0f,
|
||||
float mip = 0.0f
|
||||
int mip_src = -1,
|
||||
int mip_dst = -1
|
||||
);
|
||||
void Postprocess_Blur_Bilateral(
|
||||
const wiGraphics::Texture& input,
|
||||
@@ -183,10 +182,9 @@ namespace wiRenderer
|
||||
const wiGraphics::Texture& temp,
|
||||
const wiGraphics::Texture& output,
|
||||
wiGraphics::CommandList cmd,
|
||||
float amountX = 1.0f,
|
||||
float amountY = 1.0f,
|
||||
float depth_threshold = 1.0f,
|
||||
float mip = 0.0f
|
||||
int mip_src = -1,
|
||||
int mip_dst = -1
|
||||
);
|
||||
void Postprocess_SSAO(
|
||||
const wiGraphics::Texture& depthbuffer,
|
||||
@@ -197,7 +195,6 @@ namespace wiRenderer
|
||||
wiGraphics::CommandList cmd,
|
||||
float range = 1.0f,
|
||||
uint32_t samplecount = 16,
|
||||
float blur = 2.3f,
|
||||
float power = 2.0f
|
||||
);
|
||||
void Postprocess_SSR(
|
||||
@@ -253,6 +250,7 @@ namespace wiRenderer
|
||||
void Postprocess_Bloom(
|
||||
const wiGraphics::Texture& input,
|
||||
const wiGraphics::Texture& bloom,
|
||||
const wiGraphics::Texture& bloom_tmp,
|
||||
const wiGraphics::Texture& output,
|
||||
wiGraphics::CommandList cmd,
|
||||
float threshold = 1.0f
|
||||
@@ -270,12 +268,6 @@ namespace wiRenderer
|
||||
const wiGraphics::Texture& output,
|
||||
wiGraphics::CommandList cmd
|
||||
);
|
||||
void Postprocess_Colorgrade(
|
||||
const wiGraphics::Texture& input,
|
||||
const wiGraphics::Texture& lookuptable,
|
||||
const wiGraphics::Texture& output,
|
||||
wiGraphics::CommandList cmd
|
||||
);
|
||||
void Postprocess_Lineardepth(
|
||||
const wiGraphics::Texture& input,
|
||||
const wiGraphics::Texture& output_fullres,
|
||||
@@ -294,7 +286,9 @@ namespace wiRenderer
|
||||
const wiGraphics::Texture& input_distortion,
|
||||
const wiGraphics::Texture& output,
|
||||
wiGraphics::CommandList cmd,
|
||||
float exposure
|
||||
float exposure,
|
||||
bool dither,
|
||||
const wiGraphics::Texture* colorgrade_lookuptable
|
||||
);
|
||||
void Postprocess_Chromatic_Aberration(
|
||||
const wiGraphics::Texture& input,
|
||||
@@ -351,7 +345,7 @@ namespace wiRenderer
|
||||
MIPGENFILTER_GAUSSIAN,
|
||||
MIPGENFILTER_BICUBIC,
|
||||
};
|
||||
void GenerateMipChain(const wiGraphics::Texture& texture, MIPGENFILTER filter, wiGraphics::CommandList cmd, int arrayIndex = -1);
|
||||
void GenerateMipChain(const wiGraphics::Texture& texture, MIPGENFILTER filter, wiGraphics::CommandList cmd, int arrayIndex = -1, const wiGraphics::Texture* gaussian_temp = nullptr);
|
||||
|
||||
enum BORDEREXPANDSTYLE
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 38;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 13;
|
||||
const int revision = 14;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Reference in New Issue
Block a user