Skip to content

Commit

Permalink
make the grid fade out, looks nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
Astral-C committed Nov 21, 2024
1 parent a43d5ff commit b236122
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/UGridShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const char* UGridVertexShader =
"layout(location = 1) in vec3 aTex;\n\n"

"// Output to Fragment Shader\n"
"out vec2 oTex;\n\n"
"out vec2 oTex;\n"
"out vec2 oTexCenter;\n\n"

"uniform mat4 uModelMtx;\n"
"uniform mat4 uViewMtx;\n"
Expand All @@ -18,6 +19,7 @@ const char* UGridVertexShader =
"void main()\n"
"{\n"
"\toTex = aTex.xy * uTexScale;\n"
"\toTexCenter = vec2(uTexScale / 2, uTexScale / 2);\n"
"\tmat4 MVP = uProjMtx * uViewMtx * uModelMtx;\n\n"

"\tgl_Position = MVP * vec4(aPos, 1);\n"
Expand All @@ -27,7 +29,8 @@ const char* UGridFragmentShader =
"#version 460\n\n"

"// Input from Vertex Shader\n"
"in vec2 oTex;\n\n"
"in vec2 oTex;\n"
"in vec2 oTexCenter;\n\n"

"// Final pixel color\n"
"out vec4 PixelColor;\n\n"
Expand All @@ -38,6 +41,7 @@ const char* UGridFragmentShader =
"void main()\n"
"{\n"
"\tPixelColor = texture(uTexture, oTex);\n"
"\tPixelColor.a -= distance(oTex, oTexCenter) / 32;\n"
"\tif (PixelColor.a < 0.01f)\n"
"\t{\n"
"\t\tdiscard;\n"
Expand Down

0 comments on commit b236122

Please sign in to comment.