aboutsummaryrefslogtreecommitdiff
path: root/Assets/Shaders/Grid.slang
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-19 02:02:20 +0200
committerhachem <im@hachem.wtf>2026-08-19 02:02:20 +0200
commitf7e05555fb4ff6d8e51bdb5734db4dab1841d593 (patch)
tree353d350b19da7b84ca11e5801d33a921407a963e /Assets/Shaders/Grid.slang
parent5c5fc10d8938fd2da1922f01c638d42e70eb1ab1 (diff)
[feat]: migrate to slang from glsl
Diffstat (limited to 'Assets/Shaders/Grid.slang')
-rw-r--r--Assets/Shaders/Grid.slang34
1 files changed, 34 insertions, 0 deletions
diff --git a/Assets/Shaders/Grid.slang b/Assets/Shaders/Grid.slang
new file mode 100644
index 0000000..ea7d263
--- /dev/null
+++ b/Assets/Shaders/Grid.slang
@@ -0,0 +1,34 @@
+uniform float4x4 u_ViewProjection;
+uniform float4x4 u_Transform;
+uniform float u_GridSize;
+
+struct VSInput { float3 position : POSITION; };
+struct VSOutput { float4 position : SV_Position; };
+
+[shader("vertex")]
+VSOutput vertexMain(VSInput input)
+{
+ VSOutput output;
+ float3 scaledPosition = input.position * (u_GridSize / 50.0);
+ output.position = mul(u_ViewProjection, mul(u_Transform, float4(scaledPosition, 1.0)));
+ return output;
+}
+
+uniform float3 u_GridColor;
+uniform float u_GridAlpha;
+uniform float3 u_CameraPos;
+
+[shader("fragment")]
+float4 fragmentMain(VSOutput input) : SV_Target
+{
+ float dist = length(u_CameraPos);
+ float fadeFactor = 1.0 - clamp(dist / 100.0, 0.0, 0.8);
+
+ float3 color = u_GridColor;
+ float alpha = u_GridAlpha * fadeFactor;
+
+ float gridFade = 1.0 - clamp(dist / 50.0, 0.0, 0.9);
+ alpha *= gridFade;
+
+ return float4(color, alpha);
+}