Last active
February 20, 2022 00:17
-
-
Save snightshade/7f70cadac63d04ea6c9bc89804f043b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@# This shader renders 2D sprites. | |
@NAME "2D Sprite Render Shader" | |
@GLSL 420 | |
@VERTEX | |
uniform vec2 r_ScreenSize; | |
layout(location=0) in vec2 r_Position; | |
layout(location=1) in vec2 r_UV; | |
out vec2 f_UV; | |
void main() | |
{ | |
vec4 out_pos = vec4(0, 0, 0, 1); | |
out_pos.x = r_Position.x / r_ScreenSize.x; | |
out_pos.y = r_Position.y / r_ScreenSize.y; | |
f_UV = vec2(r_UV.xy); | |
gl_Position = out_pos; | |
} | |
@FRAGMENT | |
uniform sampler2D r_SpriteTexture; | |
in vec2 f_UV; | |
out vec4 r_FragColor; | |
void main() | |
{ | |
vec4 color = texture(r_SpriteTexture, f_UV); | |
r_FragColor = color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment