diff options
| author | hachem <im@hachem.wtf> | 2025-08-25 11:28:49 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-08-25 11:28:49 +0200 |
| commit | ecb6705c7fc4fb085184712567d0e936ea5d0d1f (patch) | |
| tree | 409937cd7fa094c36cf6607a88a2ef25913bdf18 /assets/shaders/grid.glsl | |
| parent | 12790572d039b8ea36d53013aa291d03a73ebe5c (diff) | |
fix: QOL improvements
Diffstat (limited to 'assets/shaders/grid.glsl')
| -rw-r--r-- | assets/shaders/grid.glsl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/assets/shaders/grid.glsl b/assets/shaders/grid.glsl new file mode 100644 index 0000000..81523b3 --- /dev/null +++ b/assets/shaders/grid.glsl @@ -0,0 +1,40 @@ +#type vertex + +#version 330 core + +layout(location = 0) in vec3 a_Position; + +uniform mat4 u_ViewProjection; +uniform mat4 u_Transform; +uniform float u_GridSize; + +void main() +{ + vec3 scaledPosition = a_Position * (u_GridSize / 50.0); + gl_Position = u_ViewProjection * u_Transform * vec4(scaledPosition, 1.0); +} + +#type fragment + +#version 330 core + +uniform vec3 u_GridColor; +uniform float u_GridAlpha; +uniform float u_GridSize; +uniform vec3 u_CameraPos; + +out vec4 o_FragColor; + +void main() +{ + float distance = length(u_CameraPos); + float fadeFactor = 1.0 - clamp(distance / 100.0, 0.0, 0.8); + + vec3 color = u_GridColor; + float alpha = u_GridAlpha * fadeFactor; + + float gridFade = 1.0 - clamp(distance / 50.0, 0.0, 0.9); + alpha *= gridFade; + + o_FragColor = vec4(color, alpha); +} |
