warning fixes, realistic sky is compile time switchable for now

This commit is contained in:
Turanszki Janos
2020-07-29 21:43:41 +01:00
parent 7def2db61b
commit 796f5e7a68
6 changed files with 47 additions and 55 deletions
+17 -17
View File
@@ -116,25 +116,25 @@ WeatherWindow::WeatherWindow(EditorComponent* editor) : GUI(&editor->GetGUI())
simpleskyCheckBox->OnClick([&](wiEventArgs args) {
auto& weather = GetWeather();
weather.SetSimpleSky(args.bValue);
if (args.bValue)
{
weather.SetRealisticSky(false);
}
//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);
//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...");
@@ -527,7 +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());
//realisticskyCheckBox->SetCheck(weather.IsRealisticSky());
ocean_enabledCheckBox->SetCheck(weather.IsOceanEnabled());
ocean_patchSizeSlider->SetValue(weather.oceanParameters.patch_length);
+1 -2
View File
@@ -160,8 +160,7 @@ 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_REALISTIC_SKY = 1 << 6;
static const uint OPTION_BIT_RAYTRACED_SHADOWS = 1 << 7;
static const uint OPTION_BIT_RAYTRACED_SHADOWS = 1 << 6;
// ---------- Common Constant buffers: -----------------
+27 -27
View File
@@ -2,6 +2,9 @@
#define WI_SKY_HF
#include "globals.hlsli"
// This can enable realistic sky simulation (performance heavy)
//#define REALISTIC_SKY
// Accurate Atmosphere based on: https://www.scratchapixel.com/lessons/procedural-generation-virtual-worlds/simulating-sky
// Custom Atmosphere based on: https://www.shadertoy.com/view/Ml2cWG
// Cloud noise based on: https://www.shadertoy.com/view/4tdSWr
@@ -412,34 +415,31 @@ float3 GetDynamicSkyColor(in float3 V, bool sun_enabled = true, bool clouds_enab
float3 sky = float3(0, 0, 0);
if (g_xFrame_Options & OPTION_BIT_REALISTIC_SKY)
{
AtmosphericMedium medium = CreateAtmosphericScattering();
#ifdef 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
(
V, // normalized ray direction
sunDirection, // position of the sun
sunColor, // color of the sun, for disc
sun_enabled, // use sun and total
dark_enabled // enable dark mode for light shafts etc.
);
}
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
(
V, // normalized ray direction
sunDirection, // position of the sun
sunColor, // color of the sun, for disc
sun_enabled, // use sun and total
dark_enabled // enable dark mode for light shafts etc.
);
#endif // REALISTIC_SKY
if (clouds_enabled)
{
+2 -2
View File
@@ -204,7 +204,7 @@ float SampleCloudDensity(float3 p, float heightFraction, float3 weatherData, flo
float densityHeightGradient = GetDensityHeightGradient(heightFraction, weatherData);
float cloudSample = (lowFrequencyNoises.r + lowFrequencyNoises.g + lowFrequencyNoises.b + lowFrequencyNoises.a) * g_ShapeNoiseMultiplier * densityHeightGradient;
cloudSample = pow(cloudSample, min(1.0, g_ShapeNoisePower * heightFraction));
cloudSample = pow(abs(cloudSample), min(1.0, g_ShapeNoisePower * heightFraction));
cloudSample = smoothstep(g_ShapeNoiseMinMax.x, g_ShapeNoiseMinMax.y, cloudSample);
@@ -251,7 +251,7 @@ float HenyeyGreensteinPhase(float g, float cosTheta)
{
float numer = 1.0 - g * g;
float denom = 1.0 + g * g - 2.0 * g * cosTheta;
return (numer / pow(denom, 1.5)) / 4.0 * PI;
return (numer / pow(abs(denom), 1.5)) / 4.0 * PI;
}
// Clamp the base, so it's never <= 0.0f (INF/NaN).
-4
View File
@@ -9296,10 +9296,6 @@ 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;
-3
View File
@@ -958,17 +958,14 @@ 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);