aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/grid.slang
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-24 17:07:54 +0200
committerhachem <im@hachem.wtf>2026-08-24 17:07:54 +0200
commit06398a7a176e123506de6e8851866a8bec0b3427 (patch)
tree7167ef4818f2c224840122961882efb5ec26c80b /assets/shaders/grid.slang
parent1c85c2ecaa826afd8bf80f93741cf1b2deba5798 (diff)
[chore]: cleanup shaders
Diffstat (limited to 'assets/shaders/grid.slang')
-rw-r--r--assets/shaders/grid.slang26
1 files changed, 13 insertions, 13 deletions
diff --git a/assets/shaders/grid.slang b/assets/shaders/grid.slang
index f549cb1..8dc4362 100644
--- a/assets/shaders/grid.slang
+++ b/assets/shaders/grid.slang
@@ -1,15 +1,15 @@
// Reference grid on the XZ plane. Uniforms live in a ConstantBuffer (UBO) so both
// backends drive it through the same RHI path (bind a uniform buffer at binding 0).
-struct GridU
+struct Grid
{
- float4x4 u_ViewProjection;
- float4x4 u_Transform;
- float u_GridSize;
- float3 u_GridColor;
- float u_GridAlpha;
- float3 u_CameraPos;
+ float4x4 u_view_projection;
+ float4x4 u_transform;
+ float u_grid_size;
+ float3 u_grid_color;
+ float u_grid_alpha;
+ float3 u_camera_pos;
};
-ConstantBuffer<GridU> gu;
+ConstantBuffer<Grid> gu;
struct VSInput { float3 position : POSITION; };
struct VSOutput { float4 position : SV_Position; };
@@ -18,19 +18,19 @@ struct VSOutput { float4 position : SV_Position; };
VSOutput vertexMain(VSInput input)
{
VSOutput output;
- float3 scaledPosition = input.position * (gu.u_GridSize / 50.0);
- output.position = mul(gu.u_ViewProjection, mul(gu.u_Transform, float4(scaledPosition, 1.0)));
+ float3 scaledPosition = input.position * (gu.u_grid_size / 50.0);
+ output.position = mul(gu.u_view_projection, mul(gu.u_transform, float4(scaledPosition, 1.0)));
return output;
}
[shader("fragment")]
float4 fragmentMain(VSOutput input) : SV_Target
{
- float dist = length(gu.u_CameraPos);
+ float dist = length(gu.u_camera_pos);
float fadeFactor = 1.0 - clamp(dist / 100.0, 0.0, 0.8);
- float3 color = gu.u_GridColor;
- float alpha = gu.u_GridAlpha * fadeFactor;
+ float3 color = gu.u_grid_color;
+ float alpha = gu.u_grid_alpha * fadeFactor;
float gridFade = 1.0 - clamp(dist / 50.0, 0.0, 0.9);
alpha *= gridFade;