mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 20:31:41 +00:00
Make procedural grid pattern more accurate.
This commit is contained in:
parent
0fff9a3c77
commit
88949d4cf4
1 changed files with 17 additions and 15 deletions
|
|
@ -6,14 +6,14 @@ float4 DecodeColor(uint color)
|
||||||
return float4(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, (color >> 24) & 0xFF) / 255.0;
|
return float4(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, (color >> 24) & 0xFF) / 255.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SamplePoint(int2 position)
|
float4 SamplePoint(int2 position)
|
||||||
{
|
{
|
||||||
switch (g_PushConstants.ShaderModifier)
|
switch (g_PushConstants.ShaderModifier)
|
||||||
{
|
{
|
||||||
case IMGUI_SHADER_MODIFIER_SCANLINE:
|
case IMGUI_SHADER_MODIFIER_SCANLINE:
|
||||||
{
|
{
|
||||||
if (int(position.y) % 2 == 0)
|
if (int(position.y) % 2 == 0)
|
||||||
return 0.0;
|
return float4(1.0, 1.0, 1.0, 0.0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -22,18 +22,20 @@ float SamplePoint(int2 position)
|
||||||
int remnantX = int(position.x) % 9;
|
int remnantX = int(position.x) % 9;
|
||||||
int remnantY = int(position.y) % 9;
|
int remnantY = int(position.y) % 9;
|
||||||
|
|
||||||
|
float4 color = 1.0;
|
||||||
|
|
||||||
if (remnantX == 0 || remnantY == 0)
|
if (remnantX == 0 || remnantY == 0)
|
||||||
return 0.0;
|
color.a = 0.0;
|
||||||
|
|
||||||
if ((remnantY % 2) == 0)
|
if ((remnantY % 2) == 0)
|
||||||
return 0.5;
|
color.rgb = 0.5;
|
||||||
|
|
||||||
break;
|
return color;
|
||||||
}
|
}
|
||||||
case IMGUI_SHADER_MODIFIER_SCANLINE_BUTTON:
|
case IMGUI_SHADER_MODIFIER_SCANLINE_BUTTON:
|
||||||
{
|
{
|
||||||
if (int(position.y) % 2 == 0)
|
if (int(position.y) % 2 == 0)
|
||||||
return 0.5;
|
return float4(1.0, 1.0, 1.0, 0.5);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -42,23 +44,23 @@ float SamplePoint(int2 position)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SampleLinear(float2 uvTexspace)
|
float4 SampleLinear(float2 uvTexspace)
|
||||||
{
|
{
|
||||||
int2 integerPart = floor(uvTexspace);
|
int2 integerPart = floor(uvTexspace);
|
||||||
float2 fracPart = frac(uvTexspace);
|
float2 fracPart = frac(uvTexspace);
|
||||||
|
|
||||||
float topLeft = SamplePoint(integerPart + float2(0, 0));
|
float4 topLeft = SamplePoint(integerPart + float2(0, 0));
|
||||||
float topRight = SamplePoint(integerPart + float2(1, 0));
|
float4 topRight = SamplePoint(integerPart + float2(1, 0));
|
||||||
float bottomLeft = SamplePoint(integerPart + float2(0, 1));
|
float4 bottomLeft = SamplePoint(integerPart + float2(0, 1));
|
||||||
float bottomRight = SamplePoint(integerPart + float2(1, 1));
|
float4 bottomRight = SamplePoint(integerPart + float2(1, 1));
|
||||||
|
|
||||||
float top = lerp(topLeft, topRight, fracPart.x);
|
float4 top = lerp(topLeft, topRight, fracPart.x);
|
||||||
float bottom = lerp(bottomLeft, bottomRight, fracPart.x);
|
float4 bottom = lerp(bottomLeft, bottomRight, fracPart.x);
|
||||||
|
|
||||||
return lerp(top, bottom, fracPart.y);
|
return lerp(top, bottom, fracPart.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float PixelAntialiasing(float2 uvTexspace)
|
float4 PixelAntialiasing(float2 uvTexspace)
|
||||||
{
|
{
|
||||||
float2 seam = floor(uvTexspace + 0.5);
|
float2 seam = floor(uvTexspace + 0.5);
|
||||||
uvTexspace = (uvTexspace - seam) / fwidth(uvTexspace) + seam;
|
uvTexspace = (uvTexspace - seam) / fwidth(uvTexspace) + seam;
|
||||||
|
|
@ -75,7 +77,7 @@ float PixelAntialiasing(float2 uvTexspace)
|
||||||
float4 main(in Interpolators interpolators) : SV_Target
|
float4 main(in Interpolators interpolators) : SV_Target
|
||||||
{
|
{
|
||||||
float4 color = interpolators.Color;
|
float4 color = interpolators.Color;
|
||||||
color.a *= PixelAntialiasing(interpolators.Position.xy - 0.5);
|
color *= PixelAntialiasing(interpolators.Position.xy - 0.5);
|
||||||
|
|
||||||
if (g_PushConstants.Texture2DDescriptorIndex != 0)
|
if (g_PushConstants.Texture2DDescriptorIndex != 0)
|
||||||
color *= g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex].Sample(g_SamplerDescriptorHeap[0], interpolators.UV);
|
color *= g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex].Sample(g_SamplerDescriptorHeap[0], interpolators.UV);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue