diff --git a/Editor/RendererWindow.cpp b/Editor/RendererWindow.cpp index 36818c2db..d8131ec21 100644 --- a/Editor/RendererWindow.cpp +++ b/Editor/RendererWindow.cpp @@ -84,6 +84,16 @@ void RendererWindow::Create(EditorComponent* editor) }); AddWidget(&surfelGIDebugComboBox); + surfelGIBoostSlider.Create(1, 10, 1.0f, 1.0f, "Surfel GI Boost: "); + surfelGIBoostSlider.SetTooltip("Adjust the strength of surfel GI.\nNote that values other than 1.0 will cause mismatch with path tracing reference"); + surfelGIBoostSlider.SetSize(XMFLOAT2(100, itemheight)); + surfelGIBoostSlider.SetPos(XMFLOAT2(x, y += step)); + surfelGIBoostSlider.SetValue(wi::renderer::GetSurfelGIBoost()); + surfelGIBoostSlider.OnSlide([editor](wi::gui::EventArgs args) { + wi::renderer::SetSurfelGIBoost(args.fValue); + }); + AddWidget(&surfelGIBoostSlider); + voxelRadianceCheckBox.Create("Voxel GI: "); voxelRadianceCheckBox.SetTooltip("Toggle voxel Global Illumination computation."); voxelRadianceCheckBox.SetPos(XMFLOAT2(x, y += step)); diff --git a/Editor/RendererWindow.h b/Editor/RendererWindow.h index 9db94041c..8bbae82bb 100644 --- a/Editor/RendererWindow.h +++ b/Editor/RendererWindow.h @@ -29,6 +29,7 @@ public: wi::gui::Slider resolutionScaleSlider; wi::gui::CheckBox surfelGICheckBox; wi::gui::ComboBox surfelGIDebugComboBox; + wi::gui::Slider surfelGIBoostSlider; wi::gui::CheckBox voxelRadianceCheckBox; wi::gui::CheckBox voxelRadianceDebugCheckBox; wi::gui::CheckBox voxelRadianceSecondaryBounceCheckBox; diff --git a/WickedEngine/shaders/ShaderInterop_Renderer.h b/WickedEngine/shaders/ShaderInterop_Renderer.h index be138e117..c99562282 100644 --- a/WickedEngine/shaders/ShaderInterop_Renderer.h +++ b/WickedEngine/shaders/ShaderInterop_Renderer.h @@ -590,7 +590,7 @@ struct FrameCB int texture_voxelgi_index; int buffer_entityarray_index; int buffer_entitymatrixarray_index; - int padding0; + float surfelgi_boost; ShaderScene scene; }; diff --git a/WickedEngine/shaders/ShaderInterop_SurfelGI.h b/WickedEngine/shaders/ShaderInterop_SurfelGI.h index 87e09ebf5..162334629 100644 --- a/WickedEngine/shaders/ShaderInterop_SurfelGI.h +++ b/WickedEngine/shaders/ShaderInterop_SurfelGI.h @@ -43,7 +43,7 @@ static const uint SURFEL_MOMENT_TEXELS = 4 + 2; static const uint SURFEL_MOMENT_ATLAS_TEXELS = SQRT_SURFEL_CAPACITY * SURFEL_MOMENT_TEXELS; static const uint3 SURFEL_GRID_DIMENSIONS = uint3(128, 64, 128); static const uint SURFEL_TABLE_SIZE = SURFEL_GRID_DIMENSIONS.x * SURFEL_GRID_DIMENSIONS.y * SURFEL_GRID_DIMENSIONS.z; -static const float SURFEL_MAX_RADIUS = 1; +static const float SURFEL_MAX_RADIUS = 2; static const float SURFEL_RECYCLE_DISTANCE = 0; // if surfel is behind camera and farther than this distance, it starts preparing for recycling static const uint SURFEL_RECYCLE_TIME = 60; // if surfel is preparing for recycling, this is how many frames it takes to recycle it struct SurfelGridCell diff --git a/WickedEngine/shaders/objectHF.hlsli b/WickedEngine/shaders/objectHF.hlsli index 4f42f1772..a949301b6 100644 --- a/WickedEngine/shaders/objectHF.hlsli +++ b/WickedEngine/shaders/objectHF.hlsli @@ -905,7 +905,7 @@ inline void TiledLighting(inout Surface surface, inout Lighting lighting) [branch] if (GetFrame().options & OPTION_BIT_SURFELGI_ENABLED && GetCamera().texture_surfelgi_index >= 0 && surfel_cellvalid(surfel_cell(surface.P))) { - lighting.indirect.diffuse = bindless_textures[GetCamera().texture_surfelgi_index][surface.pixel].rgb; + lighting.indirect.diffuse = bindless_textures[GetCamera().texture_surfelgi_index][surface.pixel].rgb * GetFrame().surfelgi_boost; } #endif // TRANSPARENT diff --git a/WickedEngine/shaders/oceanSurfacePS.hlsl b/WickedEngine/shaders/oceanSurfacePS.hlsl index 06e4b31a5..62acb8c38 100644 --- a/WickedEngine/shaders/oceanSurfacePS.hlsl +++ b/WickedEngine/shaders/oceanSurfacePS.hlsl @@ -1,6 +1,7 @@ #define DISABLE_DECALS #define DISABLE_ENVMAPS #define DISABLE_TRANSPARENT_SHADOWMAP +#define TRANSPARENT #include "globals.hlsli" #include "oceanSurfaceHF.hlsli" #include "objectHF.hlsli" diff --git a/WickedEngine/shaders/surfel_raytraceCS.hlsl b/WickedEngine/shaders/surfel_raytraceCS.hlsl index e7b76e154..2c2baa78e 100644 --- a/WickedEngine/shaders/surfel_raytraceCS.hlsl +++ b/WickedEngine/shaders/surfel_raytraceCS.hlsl @@ -332,6 +332,7 @@ void main(uint3 DTid : SV_DispatchThreadID) Surface surface; surface.P = surfel.position; surface.N = normalize(unpack_unitvector(surfel.normal)); + const float surface_radius = surfel.GetRadius(); uint cellindex = surfel_cellindex(surfel_cell(surface.P)); SurfelGridCell cell = surfelGridBuffer[cellindex]; @@ -339,10 +340,11 @@ void main(uint3 DTid : SV_DispatchThreadID) { uint surfel_index = surfelCellBuffer[cell.offset + i]; Surfel surfel = surfelBuffer[surfel_index]; + const float combined_radius = surfel.GetRadius() + surface_radius; float3 L = surfel.position - surface.P; float dist2 = dot(L, L); - if (dist2 < sqr(surfel.GetRadius())) + if (dist2 < sqr(combined_radius)) { float3 normal = normalize(unpack_unitvector(surfel.normal)); float dotN = dot(surface.N, normal); @@ -351,9 +353,9 @@ void main(uint3 DTid : SV_DispatchThreadID) float dist = sqrt(dist2); float contribution = 1; - //contribution *= saturate(dotN); - //contribution *= saturate(1 - dist / surfel.GetRadius()); - //contribution = smoothstep(0, 1, contribution); + contribution *= saturate(dotN); + contribution *= saturate(1 - dist / combined_radius); + contribution = smoothstep(0, 1, contribution); float2 moments = surfelMomentsTexturePrev.SampleLevel(sampler_linear_clamp, surfel_moment_uv(surfel_index, normal, -L / dist), 0); contribution *= surfel_moment_weight(moments, dist); diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 79cfc1f76..18770562d 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -96,6 +96,7 @@ bool disableAlbedoMaps = false; bool forceDiffuseLighting = false; bool SCREENSPACESHADOWS = false; bool SURFELGI = false; +float SURFELGI_BOOST = 8.0f; SURFEL_DEBUG SURFELGI_DEBUG = SURFEL_DEBUG_NONE; @@ -2991,6 +2992,8 @@ void UpdatePerFrameData( frameCB.envprobe_mipcount_rcp = 1.0f / (float)frameCB.envprobe_mipcount; } + frameCB.surfelgi_boost = GetSurfelGIBoost(); + frameCB.temporalaa_samplerotation = 0; if (GetTemporalAAEnabled()) { @@ -11826,6 +11829,14 @@ bool GetSurfelGIEnabled() { return SURFELGI; } +void SetSurfelGIBoost(float value) +{ + SURFELGI_BOOST = value; +} +float GetSurfelGIBoost() +{ + return SURFELGI_BOOST; +} void SetSurfelGIDebugEnabled(SURFEL_DEBUG value) { SURFELGI_DEBUG = value; diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 9372b948a..4fc465364 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -770,6 +770,8 @@ namespace wi::renderer bool GetScreenSpaceShadowsEnabled(); void SetSurfelGIEnabled(bool value); bool GetSurfelGIEnabled(); + void SetSurfelGIBoost(float value); + float GetSurfelGIBoost(); void SetSurfelGIDebugEnabled(SURFEL_DEBUG value); SURFEL_DEBUG GetSurfelGIDebugEnabled(); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 60ecc12b6..a560fe2ed 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 60; // minor bug fixes, alterations, refactors, updates - const int revision = 17; + const int revision = 18; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);