From 8a9432b21cc9014248e76acd3156f7be17ec6fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sun, 14 May 2023 18:31:51 +0200 Subject: [PATCH] postprocess scissor fixes #676 --- WickedEngine/shaders/depthoffield_mainCS.hlsl | 6 ++---- WickedEngine/shaders/motionblurCS.hlsl | 6 ++---- WickedEngine/shaders/visibility_skyCS.hlsl | 5 +++-- WickedEngine/shaders/visibility_velocityCS.hlsl | 5 +++-- WickedEngine/wiVersion.cpp | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/WickedEngine/shaders/depthoffield_mainCS.hlsl b/WickedEngine/shaders/depthoffield_mainCS.hlsl index 9c3ee48fd..0dcd46064 100644 --- a/WickedEngine/shaders/depthoffield_mainCS.hlsl +++ b/WickedEngine/shaders/depthoffield_mainCS.hlsl @@ -32,8 +32,8 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) const uint2 subtile = unflatten2D(subtile_idx, DEPTHOFFIELD_TILESIZE / 2 / POSTPROCESS_BLOCKSIZE); const uint2 subtile_upperleft = tile * DEPTHOFFIELD_TILESIZE / 2 + subtile * POSTPROCESS_BLOCKSIZE; const uint2 pixel = subtile_upperleft + unflatten2D(GTid.x, POSTPROCESS_BLOCKSIZE); - - if (!GetCamera().is_pixel_inside_scissor(pixel * 2)) + const float2 uv = (pixel + 0.5f) * postprocess.resolution_rcp; + if (!GetCamera().is_uv_inside_scissor(uv)) return; float alpha; @@ -57,8 +57,6 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) const float center_backgroundWeight = center_presort.g; const float center_foregroundWeight = center_presort.b; - const float2 uv = (pixel + 0.5f) * postprocess.resolution_rcp; - #ifdef DEPTHOFFIELD_CHEAP color = center_color; [unroll(DOF_RING_COUNT)] diff --git a/WickedEngine/shaders/motionblurCS.hlsl b/WickedEngine/shaders/motionblurCS.hlsl index b903144aa..9d27d25d8 100644 --- a/WickedEngine/shaders/motionblurCS.hlsl +++ b/WickedEngine/shaders/motionblurCS.hlsl @@ -52,8 +52,8 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) const uint2 subtile = unflatten2D(subtile_idx, MOTIONBLUR_TILESIZE / POSTPROCESS_BLOCKSIZE); const uint2 subtile_upperleft = tile * MOTIONBLUR_TILESIZE + subtile * POSTPROCESS_BLOCKSIZE; const uint2 pixel = subtile_upperleft + unflatten2D(GTid.x, POSTPROCESS_BLOCKSIZE); - - if (!GetCamera().is_pixel_inside_scissor(pixel)) + const float2 uv = (pixel + 0.5f) * postprocess.resolution_rcp; + if (!GetCamera().is_uv_inside_scissor(uv)) return; float4 color; @@ -69,8 +69,6 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) const float neighborhood_velocity_magnitude = length(neighborhood_velocity); const float4 center_color = input[pixel]; - const float2 uv = (pixel + 0.5f) * postprocess.resolution_rcp; - const float2 center_velocity = texture_velocity.SampleLevel(sampler_point_clamp, uv, 0).xy * strength; const float center_velocity_magnitude = length(center_velocity); const float center_depth = texture_lineardepth.SampleLevel(sampler_point_clamp, uv, 0); diff --git a/WickedEngine/shaders/visibility_skyCS.hlsl b/WickedEngine/shaders/visibility_skyCS.hlsl index 9f870f76e..4b3da7299 100644 --- a/WickedEngine/shaders/visibility_skyCS.hlsl +++ b/WickedEngine/shaders/visibility_skyCS.hlsl @@ -18,14 +18,15 @@ void main(uint Gid : SV_GroupID, uint groupIndex : SV_GroupIndex) return; const uint2 GTid = remap_lane_8x8(groupIndex); const uint2 pixel = unpack_pixel(tile.visibility_tile_id) * VISIBILITY_BLOCKSIZE + GTid; + const float2 uv = ((float2) pixel + 0.5) * GetCamera().internal_resolution_rcp; + [branch] - if (!GetCamera().is_pixel_inside_scissor(pixel)) + if (!GetCamera().is_uv_inside_scissor(uv)) { output[pixel] = 0; return; } - const float2 uv = ((float2) pixel + 0.5) * GetCamera().internal_resolution_rcp; const float2 clipspace = uv_to_clipspace(uv); RayDesc ray = CreateCameraRay(clipspace); diff --git a/WickedEngine/shaders/visibility_velocityCS.hlsl b/WickedEngine/shaders/visibility_velocityCS.hlsl index b47c0c611..5590d55e8 100644 --- a/WickedEngine/shaders/visibility_velocityCS.hlsl +++ b/WickedEngine/shaders/visibility_velocityCS.hlsl @@ -9,14 +9,15 @@ RWTexture2D output_velocity : register(u0); void main(uint2 DTid : SV_DispatchThreadID) { uint2 pixel = DTid.xy; + const float2 uv = ((float2)pixel + 0.5) * GetCamera().internal_resolution_rcp; + [branch] - if (!GetCamera().is_pixel_inside_scissor(pixel)) + if (!GetCamera().is_uv_inside_scissor(uv)) { output_velocity[pixel] = 0; return; } - const float2 uv = ((float2)pixel + 0.5) * GetCamera().internal_resolution_rcp; const float2 clipspace = uv_to_clipspace(uv); RayDesc ray = CreateCameraRay(clipspace); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 0658a0c1c..98ca725db 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 = 201; + const int revision = 202; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);