diff --git a/crates/rust4d_render/src/lib.rs b/crates/rust4d_render/src/lib.rs index 424c313..ad508d2 100644 --- a/crates/rust4d_render/src/lib.rs +++ b/crates/rust4d_render/src/lib.rs @@ -27,4 +27,4 @@ pub use rust4d_core::{ConvexShape4D, Tetrahedron, Tesseract4D, Hyperplane4D}; pub use rust4d_core::{Vec4, Rotor4, RotationPlane}; // Re-export renderable for easy access -pub use renderable::{RenderableGeometry, CheckerboardGeometry, position_gradient_color, blended_color}; +pub use renderable::{RenderableGeometry, CheckerboardGeometry, position_gradient_color}; diff --git a/crates/rust4d_render/src/pipeline/render_pipeline.rs b/crates/rust4d_render/src/pipeline/render_pipeline.rs index 862f797..f3b3485 100644 --- a/crates/rust4d_render/src/pipeline/render_pipeline.rs +++ b/crates/rust4d_render/src/pipeline/render_pipeline.rs @@ -285,45 +285,6 @@ impl RenderPipeline { // Use indirect drawing with the counter from compute shader render_pass.draw_indirect(&self.indirect_buffer, 0); } - - /// Render with a known vertex count (for debugging/testing) - pub fn render_direct( - &self, - encoder: &mut wgpu::CommandEncoder, - view: &wgpu::TextureView, - vertex_buffer: &wgpu::Buffer, - vertex_count: u32, - clear_color: wgpu::Color, - ) { - let depth_view = self.depth_texture.as_ref().expect("Depth texture not created. Call ensure_depth_texture first."); - - let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - label: Some("Render Pass"), - color_attachments: &[Some(wgpu::RenderPassColorAttachment { - view, - resolve_target: None, - ops: wgpu::Operations { - load: wgpu::LoadOp::Clear(clear_color), - store: wgpu::StoreOp::Store, - }, - })], - depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment { - view: depth_view, - depth_ops: Some(wgpu::Operations { - load: wgpu::LoadOp::Clear(1.0), - store: wgpu::StoreOp::Store, - }), - stencil_ops: None, - }), - timestamp_writes: None, - occlusion_query_set: None, - }); - - render_pass.set_pipeline(&self.pipeline); - render_pass.set_bind_group(0, &self.bind_group, &[]); - render_pass.set_vertex_buffer(0, vertex_buffer.slice(..)); - render_pass.draw(0..vertex_count, 0..1); - } } /// Helper to create a perspective projection matrix diff --git a/crates/rust4d_render/src/pipeline/slice_pipeline.rs b/crates/rust4d_render/src/pipeline/slice_pipeline.rs index 9bca523..b9f9dd3 100644 --- a/crates/rust4d_render/src/pipeline/slice_pipeline.rs +++ b/crates/rust4d_render/src/pipeline/slice_pipeline.rs @@ -12,9 +12,6 @@ use super::types::{ /// Compute pipeline for slicing 4D geometry pub struct SlicePipeline { - /// Maximum number of triangles this pipeline can output - max_triangles: usize, - /// The compute pipeline for tetrahedra slicing pipeline: wgpu::ComputePipeline, /// Bind group layout for tetrahedra pipeline @@ -31,8 +28,6 @@ pub struct SlicePipeline { output_buffer: wgpu::Buffer, /// Atomic counter buffer for triangle count counter_buffer: wgpu::Buffer, - /// Staging buffer for reading counter back to CPU - counter_staging_buffer: wgpu::Buffer, /// Slice parameters uniform buffer params_buffer: wgpu::Buffer, } @@ -164,14 +159,6 @@ impl SlicePipeline { mapped_at_creation: false, }); - // Create staging buffer for reading counter - let counter_staging_buffer = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("Counter Staging Buffer"), - size: std::mem::size_of::() as u64, - usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST, - mapped_at_creation: false, - }); - // Create params buffer let params_buffer = device.create_buffer(&wgpu::BufferDescriptor { label: Some("Slice Params Buffer"), @@ -181,7 +168,6 @@ impl SlicePipeline { }); Self { - max_triangles, pipeline, bind_group_layout, vertex_buffer: None, @@ -190,7 +176,6 @@ impl SlicePipeline { bind_group: None, output_buffer, counter_buffer, - counter_staging_buffer, params_buffer, } } diff --git a/crates/rust4d_render/src/renderable.rs b/crates/rust4d_render/src/renderable.rs index 7340989..b6cd0b8 100644 --- a/crates/rust4d_render/src/renderable.rs +++ b/crates/rust4d_render/src/renderable.rs @@ -7,11 +7,6 @@ use rust4d_core::{Entity, World, Material}; use rust4d_math::Vec4; use crate::pipeline::{Vertex4D, GpuTetrahedron}; -/// A color function that generates vertex colors -/// -/// Used to customize how vertices are colored during geometry collection. -pub type ColorFn = Box [f32; 4]>; - /// GPU-ready geometry collected from entities /// /// This struct holds the vertices and tetrahedra in a format ready for @@ -153,20 +148,6 @@ pub fn position_gradient_color(vertex: &Vec4, _material: &Material) -> [f32; 4] ] } -/// Color function that blends material color with position gradient -pub fn blended_color(vertex: &Vec4, material: &Material) -> [f32; 4] { - let pos_color = position_gradient_color(vertex, material); - let base = material.base_color; - - // 50/50 blend - [ - (pos_color[0] + base[0]) * 0.5, - (pos_color[1] + base[1]) * 0.5, - (pos_color[2] + base[2]) * 0.5, - base[3], // Keep material alpha - ] -} - /// Utility struct for building geometry with checkerboard patterns pub struct CheckerboardGeometry { /// Colors for the checkerboard pattern diff --git a/crates/rust4d_render/src/shaders/render.wgsl b/crates/rust4d_render/src/shaders/render.wgsl index 8b57356..5a9fc08 100644 --- a/crates/rust4d_render/src/shaders/render.wgsl +++ b/crates/rust4d_render/src/shaders/render.wgsl @@ -128,44 +128,3 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4 { // Output with original alpha return vec4(final_color, input.vertex_color.a); } - -// ============================================================================ -// Alternative Fragment Shader: Wireframe Mode -// ============================================================================ - -// This can be used for debugging or stylistic rendering -@fragment -fn fs_wireframe(input: VertexOutput) -> @location(0) vec4 { - // Use W-depth color directly without lighting - let w_color = w_depth_to_color(input.w_depth, uniforms.w_range); - return vec4(w_color, 1.0); -} - -// ============================================================================ -// Alternative Fragment Shader: Normal Visualization -// ============================================================================ - -// Useful for debugging geometry -@fragment -fn fs_normals(input: VertexOutput) -> @location(0) vec4 { - // Map normal from [-1,1] to [0,1] for visualization - let normal = normalize(input.world_normal); - let color = normal * 0.5 + 0.5; - return vec4(color, 1.0); -} - -// ============================================================================ -// Alternative Fragment Shader: Pure W-Depth -// ============================================================================ - -// Shows only the W-depth coloring, ignoring vertex colors -@fragment -fn fs_w_depth_only(input: VertexOutput) -> @location(0) vec4 { - let normal = normalize(input.world_normal); - let light_dir = normalize(uniforms.light_direction); - let n_dot_l = max(dot(normal, light_dir), 0.0); - let light = uniforms.ambient_strength + n_dot_l * uniforms.diffuse_strength; - - let w_color = w_depth_to_color(input.w_depth, uniforms.w_range); - return vec4(w_color * light, 1.0); -}