Skip to content

Commit

Permalink
shader fixes: some uvs were not using pixel center
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Jan 18, 2024
1 parent 78bdb89 commit 95aa824
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions WickedEngine/shaders/emittedparticlePS_soft.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ float4 main(VertextoPixel input) : SV_TARGET
}
}

uint2 pixel = input.pos.xy;
uint2 pixel = input.pos.xy; // no longer pixel center!

float4 inputColor;
inputColor.r = ((input.color >> 0) & 0xFF) / 255.0f;
Expand All @@ -50,7 +50,7 @@ float4 main(VertextoPixel input) : SV_TARGET
[branch]
if (GetCamera().texture_lineardepth_index >= 0)
{
float2 ScreenCoord = pixel * GetCamera().internal_resolution_rcp;
float2 ScreenCoord = input.pos.xy * GetCamera().internal_resolution_rcp; // use pixel center!
float4 depthScene = texture_lineardepth.GatherRed(sampler_linear_clamp, ScreenCoord) * GetCamera().z_far;
float depthFragment = input.pos.w;
opacity *= saturate(1.0 / input.size * (max(max(depthScene.x, depthScene.y), max(depthScene.z, depthScene.w)) - depthFragment));
Expand Down
4 changes: 2 additions & 2 deletions WickedEngine/shaders/hairparticlePS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ float4 main(VertexToPixel input) : SV_Target
V /= dist;
float emissive = 0;

const uint2 pixel = input.pos.xy;
const float2 ScreenCoord = pixel * GetCamera().internal_resolution_rcp;
const uint2 pixel = input.pos.xy; // no longer pixel center!
const float2 ScreenCoord = input.pos.xy * GetCamera().internal_resolution_rcp; // use pixel center!

Surface surface;
surface.init();
Expand Down
4 changes: 2 additions & 2 deletions WickedEngine/shaders/impostorPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ float4 main(VSOut input) : SV_Target
float dist = length(V);
V /= dist;

const uint2 pixel = input.pos.xy;
const float2 ScreenCoord = pixel * GetCamera().internal_resolution_rcp;
const uint2 pixel = input.pos.xy; // no longer pixel center!
const float2 ScreenCoord = input.pos.xy * GetCamera().internal_resolution_rcp; // use pixel center!

Surface surface;
surface.init();
Expand Down
4 changes: 2 additions & 2 deletions WickedEngine/shaders/objectHF.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target
{
const float depth = input.pos.z;
const float lineardepth = input.pos.w;
const uint2 pixel = input.pos.xy;
const float2 ScreenCoord = pixel * GetCamera().internal_resolution_rcp;
const uint2 pixel = input.pos.xy; // no longer pixel center!
const float2 ScreenCoord = input.pos.xy * GetCamera().internal_resolution_rcp; // use pixel center!

#ifdef OBJECTSHADER_USE_UVSETS
float4 uvsets = input.GetUVSets();
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/shaders/rtdiffuseCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void main(uint2 DTid : SV_DispatchThreadID)
return;

surface.pixel = DTid.xy;
surface.screenUV = surface.pixel * postprocess.resolution_rcp.xy;
surface.screenUV = (surface.pixel + 0.5) * postprocess.resolution_rcp.xy;

if (surface.material.IsUnlit())
{
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/shaders/rtreflectionCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void main(uint2 DTid : SV_DispatchThreadID)
return;

surface.pixel = DTid.xy;
surface.screenUV = surface.pixel * postprocess.resolution_rcp.xy;
surface.screenUV = (surface.pixel + 0.5) * postprocess.resolution_rcp.xy;

if (surface.material.IsUnlit())
{
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/shaders/rtreflectionLIB.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void RTReflection_ClosestHit(inout RayPayload payload, in BuiltInTriangleInterse
return;

surface.pixel = DispatchRaysIndex().xy;
surface.screenUV = surface.pixel / (float2)DispatchRaysDimensions().xy;
surface.screenUV = (surface.pixel + 0.5) / (float2)DispatchRaysDimensions().xy;

if (surface.material.IsUnlit())
{
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 360;
const int revision = 361;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit 95aa824

Please sign in to comment.