volumetric cloud updates

This commit is contained in:
Turanszki Janos
2020-07-27 20:14:45 +01:00
parent c7600b31ed
commit 6d4992a22f
11 changed files with 74 additions and 67 deletions
+10 -1
View File
@@ -13,7 +13,7 @@ PostprocessWindow::PostprocessWindow(EditorComponent* editor) : GUI(&editor->Get
assert(GUI && "Invalid GUI!");
ppWindow = new wiWindow(GUI, "PostProcess Window");
ppWindow->SetSize(XMFLOAT2(400, 600));
ppWindow->SetSize(XMFLOAT2(400, 620));
GUI->AddWidget(ppWindow);
float x = 150;
@@ -51,6 +51,15 @@ PostprocessWindow::PostprocessWindow(EditorComponent* editor) : GUI(&editor->Get
});
ppWindow->AddWidget(lightShaftsCheckBox);
volumetricCloudsCheckBox = new wiCheckBox("Volumetric clouds: ");
volumetricCloudsCheckBox->SetTooltip("Enable volumetric cloud rendering.");
volumetricCloudsCheckBox->SetPos(XMFLOAT2(x, y += step));
volumetricCloudsCheckBox->SetCheck(editor->renderPath->getVolumetricCloudsEnabled());
volumetricCloudsCheckBox->OnClick([=](wiEventArgs args) {
editor->renderPath->setVolumetricCloudsEnabled(args.bValue);
});
ppWindow->AddWidget(volumetricCloudsCheckBox);
aoComboBox = new wiComboBox("AO: ");
aoComboBox->SetTooltip("Choose Ambient Occlusion type. RTAO is only available if hardware supports ray tracing");
aoComboBox->SetScriptTip("RenderPath3D::SetAO(int value)");
+1
View File
@@ -22,6 +22,7 @@ public:
wiSlider* exposureSlider;
wiCheckBox* lensFlareCheckBox;
wiCheckBox* lightShaftsCheckBox;
wiCheckBox* volumetricCloudsCheckBox;
wiComboBox* aoComboBox;
wiSlider* aoPowerSlider;
wiSlider* aoRangeSlider;
+20 -24
View File
@@ -22,31 +22,9 @@ WeatherWindow::WeatherWindow(EditorComponent* editor) : GUI(&editor->GetGUI())
float step = 32;
skyTypeCustomButton = new wiButton("Sky Custom");
skyTypeCustomButton->SetTooltip("Set sky to Custom Atmosphere...");
skyTypeCustomButton->SetSize(XMFLOAT2(120, 30));
skyTypeCustomButton->SetPos(XMFLOAT2(x - 100, y += y));
skyTypeCustomButton->OnClick([=](wiEventArgs args) {
GetWeather().skyType = 0;
InvalidateProbes();
});
weatherWindow->AddWidget(skyTypeCustomButton);
skyTypeAccurateButton = new wiButton("Sky Accurate");
skyTypeAccurateButton->SetTooltip("Set sky to PBR Atmosphere...");
skyTypeAccurateButton->SetSize(XMFLOAT2(120, 30));
skyTypeAccurateButton->SetPos(XMFLOAT2(x + 30, y));
skyTypeAccurateButton->OnClick([=](wiEventArgs args) {
GetWeather().skyType = 1;
InvalidateProbes();
});
weatherWindow->AddWidget(skyTypeAccurateButton);
fogStartSlider = new wiSlider(0, 5000, 0, 100000, "Fog Start: ");
fogStartSlider->SetSize(XMFLOAT2(100, 30));
fogStartSlider->SetPos(XMFLOAT2(x, y += step * 2));
fogStartSlider->SetPos(XMFLOAT2(x, y += step));
fogStartSlider->OnSlide([&](wiEventArgs args) {
GetWeather().fogStart = args.fValue;
});
@@ -138,9 +116,26 @@ WeatherWindow::WeatherWindow(EditorComponent* editor) : GUI(&editor->GetGUI())
simpleskyCheckBox->OnClick([&](wiEventArgs args) {
auto& weather = GetWeather();
weather.SetSimpleSky(args.bValue);
});
if (args.bValue)
{
weather.SetRealisticSky(false);
}
});
weatherWindow->AddWidget(simpleskyCheckBox);
realisticskyCheckBox = new wiCheckBox("Realistic sky: ");
realisticskyCheckBox->SetTooltip("Physically based sky rendering model.");
realisticskyCheckBox->SetPos(XMFLOAT2(x + 120, y));
realisticskyCheckBox->OnClick([&](wiEventArgs args) {
auto& weather = GetWeather();
weather.SetRealisticSky(args.bValue);
if (args.bValue)
{
weather.SetSimpleSky(false);
}
});
weatherWindow->AddWidget(realisticskyCheckBox);
skyButton = new wiButton("Load Sky");
skyButton->SetTooltip("Load a skybox cubemap texture...");
skyButton->SetSize(XMFLOAT2(240, 30));
@@ -532,6 +527,7 @@ void WeatherWindow::Update()
horizonColorPicker->SetPickColor(wiColor::fromFloat3(weather.horizon));
zenithColorPicker->SetPickColor(wiColor::fromFloat3(weather.zenith));
simpleskyCheckBox->SetCheck(weather.IsSimpleSky());
realisticskyCheckBox->SetCheck(weather.IsRealisticSky());
ocean_enabledCheckBox->SetCheck(weather.IsOceanEnabled());
ocean_patchSizeSlider->SetValue(weather.oceanParameters.patch_length);
+1 -2
View File
@@ -25,8 +25,6 @@ public:
wiGUI* GUI;
wiWindow* weatherWindow;
wiButton* skyTypeAccurateButton;
wiButton* skyTypeCustomButton;
wiSlider* fogStartSlider;
wiSlider* fogEndSlider;
wiSlider* fogHeightSlider;
@@ -39,6 +37,7 @@ public:
wiSlider* windWaveSizeSlider;
wiSlider* windRandomnessSlider;
wiCheckBox* simpleskyCheckBox;
wiCheckBox* realisticskyCheckBox;
wiButton* skyButton;
wiColorPicker* ambientColorPicker;
wiColorPicker* horizonColorPicker;
+1
View File
@@ -772,6 +772,7 @@ void RenderPath3D::RenderPostprocessChain(const Texture& srcSceneRT, const Textu
std::swap(rt_read, rt_write);
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, cmd);
}
if (wiRenderer::GetTemporalAAEnabled() && !wiRenderer::GetTemporalAADebugEnabled())
{
GraphicsDevice* device = wiRenderer::GetDevice();
+1 -1
View File
@@ -41,7 +41,7 @@ private:
bool reflectionsEnabled = true;
bool shadowsEnabled = true;
bool bloomEnabled = true;
bool volumetricCloudsEnabled = true;
bool volumetricCloudsEnabled = false;
bool colorGradingEnabled = false;
bool volumeLightsEnabled = true;
bool lightShaftsEnabled = false;
+3 -6
View File
@@ -160,7 +160,8 @@ static const uint OPTION_BIT_VOXELGI_ENABLED = 1 << 2;
static const uint OPTION_BIT_VOXELGI_REFLECTIONS_ENABLED = 1 << 3;
static const uint OPTION_BIT_VOXELGI_RETARGETTED = 1 << 4;
static const uint OPTION_BIT_SIMPLE_SKY = 1 << 5;
static const uint OPTION_BIT_RAYTRACED_SHADOWS = 1 << 6;
static const uint OPTION_BIT_REALISTIC_SKY = 1 << 6;
static const uint OPTION_BIT_RAYTRACED_SHADOWS = 1 << 7;
// ---------- Common Constant buffers: -----------------
@@ -211,7 +212,7 @@ CBUFFER(FrameCB, CBSLOT_RENDERER_FRAME)
float g_xFrame_Time;
float g_xFrame_TimePrev;
float _padding0_frameCB;
float g_xFrame_SunEnergy;
float g_xFrame_WindSpeed;
float g_xFrame_DeltaTime;
uint g_xFrame_FrameCount;
@@ -249,10 +250,6 @@ CBUFFER(FrameCB, CBSLOT_RENDERER_FRAME)
float4x4 g_xFrame_MainCamera_PrevVP; // PrevView*PrevProjection
float4x4 g_xFrame_MainCamera_PrevInvVP; // Inverse(PrevView*PrevProjection)
float4x4 g_xFrame_MainCamera_ReflVP; // ReflectionView*ReflectionProjection
float2 _padding1_frameCB;
float g_xFrame_SunEnergy;
float g_xFrame_SkyType;
};
CBUFFER(CameraCB, CBSLOT_RENDERER_CAMERA)
-1
View File
@@ -79,7 +79,6 @@ inline float2 GetInternalResolution() { return g_xFrame_InternalResolution; }
inline float GetTime() { return g_xFrame_Time; }
inline uint2 GetTemporalAASampleRotation() { return uint2((g_xFrame_TemporalAASampleRotation >> 0) & 0x000000FF, (g_xFrame_TemporalAASampleRotation >> 8) & 0x000000FF); }
inline bool IsStaticSky() { return g_xFrame_StaticSkyGamma > 0.0f; }
inline float GetSkyType() { return g_xFrame_SkyType; }
inline void ConvertToSpecularGlossiness(inout float4 surface_occlusion_roughness_metallic_reflectance)
{
surface_occlusion_roughness_metallic_reflectance.r = 1;
+19 -21
View File
@@ -409,11 +409,27 @@ float3 GetDynamicSkyColor(in float3 V, bool sun_enabled = true, bool clouds_enab
const float3 sunDirection = GetSunDirection();
const float3 sunColor = GetSunColor();
const float sunEnergy = GetSunEnergy();
const float atmosphereType = GetSkyType();
float3 sky = float3(0, 0, 0);
if (atmosphereType == 0)
if (g_xFrame_Options & OPTION_BIT_REALISTIC_SKY)
{
AtmosphericMedium medium = CreateAtmosphericScattering();
sky = AccurateAtmosphericScattering
(
g_xCamera_CamPos, // Ray origin
V, // Ray direction
sunDirection, // Position of the sun
float3(0.0, -6372e3, 0.0), // Center of the planet
6371e3, // Radius of the planet in meters
6471e3, // Radius of the atmosphere in meters
medium, // Atmospheric medium constructor.
sun_enabled, // Use sun and total
dark_enabled // Enable dark mode for light shafts etc.
);
}
else
{
sky = CustomAtmosphericScattering
(
@@ -424,25 +440,7 @@ float3 GetDynamicSkyColor(in float3 V, bool sun_enabled = true, bool clouds_enab
dark_enabled // enable dark mode for light shafts etc.
);
}
else
{
AtmosphericMedium medium = CreateAtmosphericScattering();
sky = AccurateAtmosphericScattering
(
g_xCamera_CamPos, // Ray origin
V, // Ray direction
sunDirection, // Position of the sun
float3(0.0, -6372e3, 0.0), // Center of the planet
6371e3, // Radius of the planet in meters
6471e3, // Radius of the atmosphere in meters
medium, // Atmospheric medium constructor.
sun_enabled, // Use sun and total
dark_enabled // Enable dark mode for light shafts etc.
);
}
if (clouds_enabled)
{
CalculateClouds(sky, V, dark_enabled);
+15 -10
View File
@@ -9182,7 +9182,6 @@ void UpdateFrameCB(CommandList cmd)
cb.g_xFrame_Fog = float3(scene.weather.fogStart, scene.weather.fogEnd, scene.weather.fogHeight);
cb.g_xFrame_Horizon = scene.weather.horizon;
cb.g_xFrame_Zenith = scene.weather.zenith;
cb.g_xFrame_SkyType = scene.weather.skyType;
cb.g_xFrame_VoxelRadianceMaxDistance = voxelSceneData.maxDistance;
cb.g_xFrame_VoxelRadianceDataSize = voxelSceneData.voxelsize;
cb.g_xFrame_VoxelRadianceDataSize_rcp = 1.0f / (float)cb.g_xFrame_VoxelRadianceDataSize;
@@ -9297,6 +9296,10 @@ void UpdateFrameCB(CommandList cmd)
{
cb.g_xFrame_Options |= OPTION_BIT_SIMPLE_SKY;
}
if (scene.weather.IsRealisticSky())
{
cb.g_xFrame_Options |= OPTION_BIT_REALISTIC_SKY;
}
if (GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_RAYTRACING) && GetRaytracedShadowsEnabled())
{
cb.g_xFrame_Options |= OPTION_BIT_RAYTRACED_SHADOWS;
@@ -11577,6 +11580,8 @@ void Postprocess_VolumetricClouds(
device->EventBegin("Postprocess_VolumetricClouds", cmd);
auto range = wiProfiler::BeginRangeGPU("Volumetric Clouds", cmd);
GPUBarrier memory_barrier = GPUBarrier::Memory();
const TextureDesc& desc = output.GetDesc();
static TextureDesc initialized_desc;
@@ -11678,7 +11683,7 @@ void Postprocess_VolumetricClouds(
device->Dispatch(noiseThreadXY, noiseThreadXY, noiseThreadZ, cmd);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
@@ -11698,14 +11703,14 @@ void Postprocess_VolumetricClouds(
device->Dispatch(noiseThreadXYZ, noiseThreadXYZ, noiseThreadXYZ, cmd);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
// Generate mip chains for 3D textures:
GenerateMipChain(texture_shapeNoise, MIPGENFILTER_GAUSSIAN, cmd);
GenerateMipChain(texture_detailNoise, MIPGENFILTER_GAUSSIAN, cmd);
GenerateMipChain(texture_shapeNoise, MIPGENFILTER_LINEAR, cmd);
GenerateMipChain(texture_detailNoise, MIPGENFILTER_LINEAR, cmd);
// Curl Noise pass:
{
@@ -11723,7 +11728,7 @@ void Postprocess_VolumetricClouds(
device->Dispatch(curlThread, curlThread, 1, cmd);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
@@ -11744,7 +11749,7 @@ void Postprocess_VolumetricClouds(
device->Dispatch(weatherThread, weatherThread, 1, cmd);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
@@ -11789,7 +11794,7 @@ void Postprocess_VolumetricClouds(
cmd
);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
@@ -11832,7 +11837,7 @@ void Postprocess_VolumetricClouds(
cmd
);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
@@ -11860,7 +11865,7 @@ void Postprocess_VolumetricClouds(
cmd
);
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->Barrier(&memory_barrier, 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
device->EventEnd(cmd);
}
+3 -1
View File
@@ -958,14 +958,17 @@ namespace wiScene
EMPTY = 0,
OCEAN_ENABLED = 1 << 0,
SIMPLE_SKY = 1 << 1,
REALISTIC_SKY = 1 << 2,
};
uint32_t _flags = EMPTY;
inline bool IsOceanEnabled() const { return _flags & OCEAN_ENABLED; }
inline bool IsSimpleSky() const { return _flags & SIMPLE_SKY; }
inline bool IsRealisticSky() const { return _flags & REALISTIC_SKY; }
inline void SetOceanEnabled(bool value = true) { if (value) { _flags |= OCEAN_ENABLED; } else { _flags &= ~OCEAN_ENABLED; } }
inline void SetSimpleSky(bool value = true) { if (value) { _flags |= SIMPLE_SKY; } else { _flags &= ~SIMPLE_SKY; } }
inline void SetRealisticSky(bool value = true) { if (value) { _flags |= REALISTIC_SKY; } else { _flags &= ~REALISTIC_SKY; } }
XMFLOAT3 sunColor = XMFLOAT3(0, 0, 0);
XMFLOAT3 sunDirection = XMFLOAT3(0, 1, 0);
@@ -983,7 +986,6 @@ namespace wiScene
float windRandomness = 5;
float windWaveSize = 1;
float windSpeed = 1;
float skyType = 0;
struct OceanParameters
{