surfel gi improvements, added boost setting

This commit is contained in:
Turánszki János
2022-01-15 13:51:17 +01:00
parent 7c8526bd3e
commit ddd276d0ac
10 changed files with 35 additions and 8 deletions
+10
View File
@@ -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));
+1
View File
@@ -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;
@@ -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;
};
@@ -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
+1 -1
View File
@@ -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
+1
View File
@@ -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"
+6 -4
View File
@@ -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);
+11
View File
@@ -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;
+2
View File
@@ -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();
+1 -1
View File
@@ -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);