Skip to content

Commit

Permalink
take bilinear changes from cemu-project#879
Browse files Browse the repository at this point in the history
this makes the shader consistent with hermite and fixes the wrong offset
  • Loading branch information
goeiecool9999 committed Oct 27, 2024
1 parent 03074e7 commit 49b6fb4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,23 @@ vec4 cubic(float x)
return w / 6.0;
}
vec4 bcFilter(vec2 texcoord, vec2 texscale)
vec4 bcFilter(vec2 uv, vec4 texelSize)
{
float fx = fract(texcoord.x);
float fy = fract(texcoord.y);
texcoord.x -= fx;
texcoord.y -= fy;
vec2 pixel = uv*texelSize.zw - 0.5;
vec2 pixelFrac = fract(pixel);
vec2 pixelInt = pixel - pixelFrac;
vec4 xcubic = cubic(fx);
vec4 ycubic = cubic(fy);
vec4 xcubic = cubic(pixelFrac.x);
vec4 ycubic = cubic(pixelFrac.y);
vec4 c = vec4(texcoord.x - 0.5, texcoord.x + 1.5, texcoord.y - 0.5, texcoord.y + 1.5);
vec4 c = vec4(pixelInt.x - 0.5, pixelInt.x + 1.5, pixelInt.y - 0.5, pixelInt.y + 1.5);
vec4 s = vec4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x + ycubic.y, ycubic.z + ycubic.w);
vec4 offset = c + vec4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) / s;
vec4 sample0 = texture(textureSrc, vec2(offset.x, offset.z) * texscale);
vec4 sample1 = texture(textureSrc, vec2(offset.y, offset.z) * texscale);
vec4 sample2 = texture(textureSrc, vec2(offset.x, offset.w) * texscale);
vec4 sample3 = texture(textureSrc, vec2(offset.y, offset.w) * texscale);
vec4 sample0 = texture(textureSrc, vec2(offset.x, offset.z) * texelSize.xy);
vec4 sample1 = texture(textureSrc, vec2(offset.y, offset.z) * texelSize.xy);
vec4 sample2 = texture(textureSrc, vec2(offset.x, offset.w) * texelSize.xy);
vec4 sample3 = texture(textureSrc, vec2(offset.y, offset.w) * texelSize.xy);
float sx = s.x / (s.x + s.y);
float sy = s.z / (s.z + s.w);
Expand All @@ -76,7 +75,8 @@ vec4 bcFilter(vec2 texcoord, vec2 texscale)
}
void main(){
colorOut0 = vec4(bcFilter(passUV*inputResolution, vec2(1.0,1.0)/inputResolution).rgb,1.0);
vec4 texelSize = vec4( 1.0 / inputResolution.xy, inputResolution.xy);
colorOut0 = vec4(bcFilter(passUV, texelSize).rgb,1.0);
}
)";

Expand Down

0 comments on commit 49b6fb4

Please sign in to comment.