summaryrefslogtreecommitdiff
path: root/workspaces/main/shaders/renderer_3d.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'workspaces/main/shaders/renderer_3d.wgsl')
-rw-r--r--workspaces/main/shaders/renderer_3d.wgsl64
1 files changed, 32 insertions, 32 deletions
diff --git a/workspaces/main/shaders/renderer_3d.wgsl b/workspaces/main/shaders/renderer_3d.wgsl
index d3b0bae..824be2f 100644
--- a/workspaces/main/shaders/renderer_3d.wgsl
+++ b/workspaces/main/shaders/renderer_3d.wgsl
@@ -12,31 +12,31 @@
@group(0) @binding(5) var sky_tex: texture_2d<f32>;
struct VertexOutput {
- @builtin(position) position: vec4<f32>,
- @location(0) local_pos: vec3<f32>,
- @location(1) color: vec4<f32>,
+ @builtin(position) position: vec4f,
+ @location(0) local_pos: vec3f,
+ @location(1) color: vec4f,
@location(2) @interpolate(flat) instance_index: u32,
- @location(3) world_pos: vec3<f32>,
- @location(4) transformed_normal: vec3<f32>,
+ @location(3) world_pos: vec3f,
+ @location(4) transformed_normal: vec3f,
};
@vertex
fn vs_main(@builtin(vertex_index) vertex_index: u32,
@builtin(instance_index) instance_index: u32) -> VertexOutput {
- var pos = array<vec3<f32>, 36>(
- vec3(-1.0, -1.0, 1.0), vec3( 1.0, -1.0, 1.0), vec3( 1.0, 1.0, 1.0),
- vec3(-1.0, -1.0, 1.0), vec3( 1.0, 1.0, 1.0), vec3(-1.0, 1.0, 1.0),
- vec3(-1.0, -1.0, -1.0), vec3(-1.0, 1.0, -1.0), vec3( 1.0, 1.0, -1.0),
- vec3(-1.0, -1.0, -1.0), vec3( 1.0, 1.0, -1.0), vec3( 1.0, -1.0, -1.0),
- vec3(-1.0, 1.0, -1.0), vec3(-1.0, 1.0, 1.0), vec3( 1.0, 1.0, 1.0),
- vec3(-1.0, 1.0, -1.0), vec3( 1.0, 1.0, 1.0), vec3( 1.0, 1.0, -1.0),
- vec3(-1.0, -1.0, -1.0), vec3( 1.0, -1.0, -1.0), vec3( 1.0, -1.0, 1.0),
- vec3(-1.0, -1.0, -1.0), vec3( 1.0, -1.0, 1.0), vec3(-1.0, -1.0, 1.0),
- vec3( 1.0, -1.0, -1.0), vec3( 1.0, 1.0, -1.0), vec3( 1.0, 1.0, 1.0),
- vec3( 1.0, -1.0, -1.0), vec3( 1.0, 1.0, 1.0), vec3( 1.0, -1.0, 1.0),
- vec3(-1.0, -1.0, -1.0), vec3(-1.0, -1.0, 1.0), vec3(-1.0, 1.0, 1.0),
- vec3(-1.0, -1.0, -1.0), vec3(-1.0, 1.0, 1.0), vec3(-1.0, 1.0, -1.0)
+ var pos = array<vec3f, 36>(
+ vec3f(-1.0, -1.0, 1.0), vec3f( 1.0, -1.0, 1.0), vec3f( 1.0, 1.0, 1.0),
+ vec3f(-1.0, -1.0, 1.0), vec3f( 1.0, 1.0, 1.0), vec3f(-1.0, 1.0, 1.0),
+ vec3f(-1.0, -1.0, -1.0), vec3f(-1.0, 1.0, -1.0), vec3f( 1.0, 1.0, -1.0),
+ vec3f(-1.0, -1.0, -1.0), vec3f( 1.0, 1.0, -1.0), vec3f( 1.0, -1.0, -1.0),
+ vec3f(-1.0, 1.0, -1.0), vec3f(-1.0, 1.0, 1.0), vec3f( 1.0, 1.0, 1.0),
+ vec3f(-1.0, 1.0, -1.0), vec3f( 1.0, 1.0, 1.0), vec3f( 1.0, 1.0, -1.0),
+ vec3f(-1.0, -1.0, -1.0), vec3f( 1.0, -1.0, -1.0), vec3f( 1.0, -1.0, 1.0),
+ vec3f(-1.0, -1.0, -1.0), vec3f( 1.0, -1.0, 1.0), vec3f(-1.0, -1.0, 1.0),
+ vec3f( 1.0, -1.0, -1.0), vec3f( 1.0, 1.0, -1.0), vec3f( 1.0, 1.0, 1.0),
+ vec3f( 1.0, -1.0, -1.0), vec3f( 1.0, 1.0, 1.0), vec3f( 1.0, -1.0, 1.0),
+ vec3f(-1.0, -1.0, -1.0), vec3f(-1.0, -1.0, 1.0), vec3f(-1.0, 1.0, 1.0),
+ vec3f(-1.0, -1.0, -1.0), vec3f(-1.0, 1.0, 1.0), vec3f(-1.0, 1.0, -1.0)
);
var p = pos[vertex_index];
@@ -47,7 +47,7 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32,
// For meshes, we use the actual vertex data, not proxy geometry.
// The position here is a placeholder, the real mesh data is handled by mesh_pipeline_.
var out: VertexOutput;
- out.position = vec4<f32>(0.0, 0.0, 2.0, 1.0); // Outside far plane, so it's not rendered by this pipeline.
+ out.position = vec4f(0.0, 0.0, 2.0, 1.0); // Outside far plane, so it's not rendered by this pipeline.
return out;
}
@@ -58,7 +58,7 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32,
p.y = p.y * 0.5;
}
- let world_pos = obj.model * vec4<f32>(p, 1.0);
+ let world_pos = obj.model * vec4f(p, 1.0);
let clip_pos = globals.view_proj * world_pos;
var out: VertexOutput;
@@ -70,7 +70,7 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32,
// For SDF primitives, we don't use vertex normals - they are computed analytically in the fragment shader.
// This field is only used by the mesh pipeline (mesh_render.wgsl), not this SDF pipeline.
- out.transformed_normal = normalize(vec3<f32>(0.0, 1.0, 0.0)); // Placeholder
+ out.transformed_normal = normalize(vec3f(0.0, 1.0, 0.0)); // Placeholder
return out;
}
@@ -81,7 +81,7 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32,
#include "ray_box"
struct FragmentOutput {
- @location(0) color: vec4<f32>,
+ @location(0) color: vec4f,
@builtin(frag_depth) depth: f32,
};
@@ -90,10 +90,10 @@ fn fs_main(in: VertexOutput) -> FragmentOutput {
let obj = object_data.objects[in.instance_index];
let obj_type = obj.params.x;
- var p: vec3<f32>;
- var normal: vec3<f32>;
+ var p: vec3f;
+ var normal: vec3f;
var base_color = in.color.rgb;
- let light_dir = normalize(vec3<f32>(1.0, 1.0, 1.0));
+ let light_dir = normalize(vec3f(1.0, 1.0, 1.0));
if (obj_type <= 0.0) { // Raster path (legacy or generic)
p = in.world_pos;
@@ -109,13 +109,13 @@ fn fs_main(in: VertexOutput) -> FragmentOutput {
let rd_world = normalize(in.world_pos - ro_world);
// Ray-Box Intersection in local space to find tight bounds
- let ro_local = (obj.inv_model * vec4<f32>(ro_world, 1.0)).xyz;
- let rd_local = normalize((obj.inv_model * vec4<f32>(rd_world, 0.0)).xyz);
+ let ro_local = (obj.inv_model * vec4f(ro_world, 1.0)).xyz;
+ let rd_local = normalize((obj.inv_model * vec4f(rd_world, 0.0)).xyz);
// Proxy box extent (matches vs_main)
// MESHES use obj.params.yzw for extent
- var extent = vec3<f32>(1.0);
- if (obj.params.x == 3.0) { extent = vec3<f32>(1.5, 0.5, 1.5); } // Torus
+ var extent = vec3f(1.0);
+ if (obj.params.x == 3.0) { extent = vec3f(1.5, 0.5, 1.5); } // Torus
else if (obj.params.x == 5.0) { extent = obj.params.yzw; } // MESH extent
let bounds = ray_box_intersection(ro_local, rd_local, extent);
@@ -134,7 +134,7 @@ fn fs_main(in: VertexOutput) -> FragmentOutput {
if (!hit) { discard; }
let q_hit = ro_local + rd_local * t;
- p = (obj.model * vec4<f32>(q_hit, 1.0)).xyz; // Correct world position
+ p = (obj.model * vec4f(q_hit, 1.0)).xyz; // Correct world position
// Calculate normal with bump mapping (using utility function)
let disp_strength = 0.05;
@@ -157,10 +157,10 @@ fn fs_main(in: VertexOutput) -> FragmentOutput {
let lit_color = calculate_lighting(base_color, normal, p, shadow);
var out: FragmentOutput;
- out.color = vec4<f32>(lit_color, 1.0);
+ out.color = vec4f(lit_color, 1.0);
// Calculate and write correct depth
- let clip_pos = globals.view_proj * vec4<f32>(p, 1.0);
+ let clip_pos = globals.view_proj * vec4f(p, 1.0);
out.depth = clip_pos.z / clip_pos.w;
return out;