diff --git a/WickedEngine/offlineshadercompiler.cpp b/WickedEngine/offlineshadercompiler.cpp index 0cc3d5c665..f7876a49fa 100644 --- a/WickedEngine/offlineshadercompiler.cpp +++ b/WickedEngine/offlineshadercompiler.cpp @@ -175,7 +175,6 @@ wi::vector shaders = { {"volumetricCloud_renderCS_capture", wi::graphics::ShaderStage::CS }, {"volumetricCloud_renderCS_capture_MSAA", wi::graphics::ShaderStage::CS }, {"volumetricCloud_reprojectCS", wi::graphics::ShaderStage::CS }, - {"volumetricCloud_shadow_filterCS", wi::graphics::ShaderStage::CS }, {"volumetricCloud_shadow_renderCS", wi::graphics::ShaderStage::CS }, {"volumetricCloud_shapenoiseCS", wi::graphics::ShaderStage::CS }, {"volumetricCloud_upsamplePS", wi::graphics::ShaderStage::PS }, diff --git a/WickedEngine/shaders/Shaders_SOURCE.vcxitems b/WickedEngine/shaders/Shaders_SOURCE.vcxitems index 67a91108d3..8eca7c6085 100644 --- a/WickedEngine/shaders/Shaders_SOURCE.vcxitems +++ b/WickedEngine/shaders/Shaders_SOURCE.vcxitems @@ -1071,10 +1071,6 @@ Compute 4.0 - - Compute - 4.0 - Compute 4.0 diff --git a/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters b/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters index cdcd8826b2..65927223b0 100644 --- a/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters +++ b/WickedEngine/shaders/Shaders_SOURCE.vcxitems.filters @@ -968,9 +968,6 @@ CS - - CS - CS diff --git a/WickedEngine/shaders/shadowHF.hlsli b/WickedEngine/shaders/shadowHF.hlsli index bb4eb11933..348a118ce1 100644 --- a/WickedEngine/shaders/shadowHF.hlsli +++ b/WickedEngine/shaders/shadowHF.hlsli @@ -154,8 +154,8 @@ inline half3 shadow_cube(in ShaderEntity light, in float3 Lunnormalized, in min1 inline half shadow_2D_volumetricclouds(float3 P) { // Project into shadow map space (no need to divide by .w because ortho projection!): - half3 shadow_pos = mul(GetFrame().cloudShadowLightSpaceMatrix, float4(P, 1)).xyz; - half3 shadow_uv = clipspace_to_uv(shadow_pos); + float3 shadow_pos = mul(GetFrame().cloudShadowLightSpaceMatrix, float4(P, 1)).xyz; + float3 shadow_uv = clipspace_to_uv(shadow_pos); [branch] if (shadow_uv.z < 0.5) @@ -166,7 +166,7 @@ inline half shadow_2D_volumetricclouds(float3 P) [branch] if (is_saturated(shadow_uv)) { - half cloudShadowSampleZ = shadow_pos.z; + float cloudShadowSampleZ = shadow_pos.z; Texture2D texture_volumetricclouds_shadow = bindless_textures_half4[GetFrame().texture_volumetricclouds_shadow_index]; half3 cloudShadowData = texture_volumetricclouds_shadow.SampleLevel(sampler_linear_clamp, shadow_uv.xy, 0.0).rgb; diff --git a/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl b/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl deleted file mode 100644 index 829f439536..0000000000 --- a/WickedEngine/shaders/volumetricCloud_shadow_filterCS.hlsl +++ /dev/null @@ -1,44 +0,0 @@ -#include "globals.hlsli" -#include "ShaderInterop_Postprocess.h" - -PUSHCONSTANT(postprocess, PostProcess); - -Texture2D input : register(t0); -RWTexture2D output : register(u0); - -[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ - const float2 uv = (DTid.xy + 0.5) * postprocess.resolution_rcp; - -#if 0 // Debug - output[DTid.xy] = input[DTid.xy]; - return; -#endif - - // Filter - float3 filteredResult = 0.0; - float sum = 0.0; - - const int radius = 1; - for (int x = -radius; x <= radius; x++) - { - for (int y = -radius; y <= radius; y++) - { - int2 offset = int2(x, y); - int2 neighborCoord = DTid.xy + offset; - - if (all(and(neighborCoord >= int2(0, 0), neighborCoord < (int2) postprocess.resolution))) - { - const float2 neighborUV = (neighborCoord + 0.5) * postprocess.resolution_rcp; - float3 neighborResult = input.SampleLevel(sampler_linear_clamp, neighborUV, 0); - - filteredResult += neighborResult; - sum += 1.0; - } - } - } - filteredResult /= sum; - - output[DTid.xy] = filteredResult; -} diff --git a/WickedEngine/shaders/volumetricCloud_shadow_renderCS.hlsl b/WickedEngine/shaders/volumetricCloud_shadow_renderCS.hlsl index 865326aafa..dca0e5f8ba 100644 --- a/WickedEngine/shaders/volumetricCloud_shadow_renderCS.hlsl +++ b/WickedEngine/shaders/volumetricCloud_shadow_renderCS.hlsl @@ -11,7 +11,7 @@ Texture2D texture_curlNoise : register(t2); Texture2D texture_weatherMapFirst : register(t3); Texture2D texture_weatherMapSecond : register(t4); -RWTexture2D texture_render : register(u0); +RWTexture2D texture_render : register(u0); static const float2 sampleCountMinMax = float2(16.0, 32.0); // Based on sun angle, more angle more samples @@ -139,5 +139,5 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint3 } // Output - texture_render[DTid.xy] = result; + texture_render[DTid.xy] = float4(result, 1); } diff --git a/WickedEngine/wiEnums.h b/WickedEngine/wiEnums.h index 85eabe4b5f..3d0fa66215 100644 --- a/WickedEngine/wiEnums.h +++ b/WickedEngine/wiEnums.h @@ -89,7 +89,7 @@ namespace wi::enums enum TEXTYPES { TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW, - TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED, + TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_GAUSSIAN_TEMP, TEXTYPE_2D_SKYATMOSPHERE_TRANSMITTANCELUT, TEXTYPE_2D_SKYATMOSPHERE_MULTISCATTEREDLUMINANCELUT, TEXTYPE_2D_SKYATMOSPHERE_SKYVIEWLUT, @@ -342,7 +342,6 @@ namespace wi::enums CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_RENDER_CAPTURE_MSAA, CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_REPROJECT, CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_SHADOW_RENDER, - CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_SHADOW_FILTER, CSTYPE_POSTPROCESS_FXAA, CSTYPE_POSTPROCESS_TEMPORALAA, CSTYPE_POSTPROCESS_SHARPEN, diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 2ec0a805ea..29ffbf55e6 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -1067,7 +1067,6 @@ void LoadShaders() wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_RENDER_CAPTURE_MSAA], "volumetricCloud_renderCS_capture_MSAA.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_REPROJECT], "volumetricCloud_reprojectCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_SHADOW_RENDER], "volumetricCloud_shadow_renderCS.cso"); }); - wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_SHADOW_FILTER], "volumetricCloud_shadow_filterCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_FXAA], "fxaaCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_TEMPORALAA], "temporalaaCS.cso"); }); wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) { LoadShader(ShaderStage::CS, shaders[CSTYPE_POSTPROCESS_SHARPEN], "sharpenCS.cso"); }); @@ -3854,12 +3853,12 @@ void UpdatePerFrameData( desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; device->CreateTexture(&desc, nullptr, &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW]); device->SetName(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], "textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW]"); - device->CreateTexture(&desc, nullptr, &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED]); - device->SetName(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], "textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED]"); + device->CreateTexture(&desc, nullptr, &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_GAUSSIAN_TEMP]); + device->SetName(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_GAUSSIAN_TEMP], "textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_GAUSSIAN_TEMP]"); } const float cloudShadowSnapLength = 5000.0f; - const float cloudShadowExtent = 35000.0f; // The cloud shadow bounding box size + const float cloudShadowExtent = 10000.0f; // The cloud shadow bounding box size const float cloudShadowNearPlane = 0.0f; const float cloudShadowFarPlane = cloudShadowExtent * 2.0; @@ -3891,7 +3890,7 @@ void UpdatePerFrameData( XMStoreFloat4x4(&frameCB.cloudShadowLightSpaceMatrix, cloudShadowLightSpaceMatrix); XMStoreFloat4x4(&frameCB.cloudShadowLightSpaceMatrixInverse, cloudShadowLightSpaceMatrixInverse); frameCB.cloudShadowFarPlaneKm = cloudShadowFarPlane * metersToSkyUnit; - frameCB.texture_volumetricclouds_shadow_index = device->GetDescriptorIndex(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], SubresourceType::SRV); + frameCB.texture_volumetricclouds_shadow_index = device->GetDescriptorIndex(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], SubresourceType::SRV); } if (scene.weather.IsRealisticSky() && !textures[TEXTYPE_2D_SKYATMOSPHERE_TRANSMITTANCELUT].IsValid()) @@ -8113,7 +8112,6 @@ void ComputeVolumetricCloudShadows( { GPUBarrier barriers[] = { - GPUBarrier::Memory(), GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], ResourceState::UNORDERED_ACCESS, textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW].desc.layout), }; device->Barrier(barriers, arraysize(barriers), cmd); @@ -8122,49 +8120,14 @@ void ComputeVolumetricCloudShadows( device->EventEnd(cmd); } - auto CloudShadowFilter = [&](PostProcess& postprocess, CommandList cmd) - { - // Cloud shadow filter pass: - { - device->EventBegin("Volumetric Cloud Filter Shadow", cmd); - device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_VOLUMETRICCLOUDS_SHADOW_FILTER], cmd); - device->PushConstants(&postprocess, sizeof(postprocess), cmd); - - device->BindResource(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], 0, cmd); - - const GPUResource* uavs[] = { - &textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], - }; - device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].desc.layout, ResourceState::UNORDERED_ACCESS), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - - device->Dispatch( - (textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - (textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, - 1, - cmd - ); - - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED], ResourceState::UNORDERED_ACCESS, textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_FILTERED].desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - - device->EventEnd(cmd); - } - }; - - // We filter twice for to avoid rapid changing pixels and to mimic penumbra - CloudShadowFilter(postprocess, cmd); - CloudShadowFilter(postprocess, cmd); + Postprocess_Blur_Gaussian( + textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], + textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW_GAUSSIAN_TEMP], + textures[TEXTYPE_2D_VOLUMETRICCLOUDS_SHADOW], + cmd, + -1, -1, + false // wide + ); wi::profiler::EndRange(range); device->EventEnd(cmd); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 7b6b4f4963..54f5f23065 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 = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 646; + const int revision = 647; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);