-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Fix shaders so tiling now works (at least at native res)
- Loading branch information
Showing
2 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
52 changes: 49 additions & 3 deletions
52
Rzxe/Windowing/Implementations/GlfwFx/Shaders/fragment.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,59 @@ | ||
#version 330 core | ||
|
||
in vec2 fsUV; | ||
in vec2 fsUV; | ||
in vec4 fsSourceRect; | ||
in vec2 fsOrigin; | ||
in float fsDrawMode; | ||
|
||
out vec4 Colour; | ||
out vec4 outColor; | ||
|
||
uniform vec2 gCanvasResolution; | ||
uniform vec2 gUvMapResolution; | ||
uniform sampler2D TextureSampler; | ||
|
||
|
||
vec2 makeRelative( | ||
in vec2 point, | ||
in vec2 factor | ||
) | ||
{ | ||
return vec2( | ||
point.x / factor.x, | ||
1.0 - (point.y / factor.y) | ||
); | ||
} | ||
|
||
|
||
void main() | ||
{ | ||
Colour = texture(TextureSampler, fsUV).rgba; | ||
// Set up UV | ||
// | ||
vec2 naturalUV = vec2(0, 0); | ||
vec2 scaledUV = vec2(0, 0); | ||
|
||
if (fsDrawMode == 0) | ||
{ | ||
naturalUV = fsUV; | ||
} | ||
else if (fsDrawMode == 1) | ||
{ | ||
vec2 modUV; | ||
vec2 naturalVertex; | ||
|
||
modUV = | ||
vec2( | ||
mod(gl_FragCoord.x - fsOrigin.x, fsSourceRect.z), | ||
mod(gCanvasResolution.y - gl_FragCoord.y - fsOrigin.y, fsSourceRect.w) | ||
); | ||
|
||
naturalUV = fsSourceRect.xy + modUV.xy; | ||
} | ||
|
||
scaledUV = | ||
makeRelative( | ||
naturalUV, | ||
gUvMapResolution | ||
); | ||
|
||
outColor = texture(TextureSampler, scaledUV).rgba; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters