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 | 86df8b19063f73b7803daaa1e5b21da33ac976ed (patch) | |
| tree | ee274484bd1ca6ba8eba196b70abe9f2958c8c81 /Assets/Shaders/Grid.glsl | |
| parent | 59b917dcb36c227182da0c55a99acbcf74f7563d (diff) | |
[fix]: QOL improvements
Diffstat (limited to 'Assets/Shaders/Grid.glsl')
| -rw-r--r-- | Assets/Shaders/Grid.glsl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Assets/Shaders/Grid.glsl b/Assets/Shaders/Grid.glsl new file mode 100644 index 0000000..32c091a --- /dev/null +++ b/Assets/Shaders/Grid.glsl @@ -0,0 +1,41 @@ +#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() +{ + // Scale the grid based on the grid size uniform + 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); +} |
