Remove texture coord from model vertex

This commit is contained in:
Connor Slade
2024-07-31 14:14:44 -04:00
parent e63e0f54bb
commit 2e6fb2d478
9 changed files with 13 additions and 42 deletions

View File

@@ -3,8 +3,7 @@ use std::mem;
use dispatch::solid_line::SolidLineDispatch;
use eframe::CreationContext;
use pipelines::{
model::ModelPipeline, slice_preview::SlicePreviewPipeline,
target_point::TargetPointPipeline,
model::ModelPipeline, slice_preview::SlicePreviewPipeline, target_point::TargetPointPipeline,
};
use slice_preview::SlicePreviewRenderResources;
use wgpu::{BufferAddress, VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode};
@@ -28,15 +27,10 @@ pub const VERTEX_BUFFER_LAYOUT: VertexBufferLayout = VertexBufferLayout {
shader_location: 0,
},
VertexAttribute {
format: VertexFormat::Float32x2,
format: VertexFormat::Float32x3,
offset: 4 * 4,
shader_location: 1,
},
VertexAttribute {
format: VertexFormat::Float32x3,
offset: 4 * 4 + 4 * 2,
shader_location: 2,
},
],
};
@@ -44,7 +38,6 @@ pub const VERTEX_BUFFER_LAYOUT: VertexBufferLayout = VertexBufferLayout {
#[derive(Default, Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct ModelVertex {
pub position: [f32; 4],
pub tex_coords: [f32; 2],
pub normal: [f32; 3],
}

View File

@@ -57,6 +57,7 @@ impl ModelPipeline {
push_constant_ranges: &[],
});
println!("ModelPipeline created");
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),

View File

@@ -69,6 +69,7 @@ impl SlicePreviewPipeline {
push_constant_ranges: &[],
});
println!("SlicePreviewPipeline created");
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),
@@ -105,7 +106,6 @@ impl SlicePreviewPipeline {
.into_iter()
.map(|[x, y]| ModelVertex {
position: [x, y, 0.0, 1.0],
tex_coords: [0.0, 0.0],
normal: [0.0, 0.0, 1.0],
})
.collect::<Vec<_>>();

View File

@@ -92,6 +92,7 @@ impl SolidLinePipeline {
}],
});
println!("SolidLinePipeline created");
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),

View File

@@ -8,8 +8,8 @@ use plexus::primitive::{
use wgpu::{
util::{BufferInitDescriptor, DeviceExt},
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, BlendState, Buffer,
BufferBinding, BufferDescriptor, BufferUsages, ColorTargetState, ColorWrites,
CompareFunction, DepthStencilState, Device, FragmentState, IndexFormat, MultisampleState,
BufferBinding, BufferDescriptor, BufferUsages, ColorTargetState, ColorWrites, CompareFunction,
DepthStencilState, Device, FragmentState, IndexFormat, MultisampleState,
PipelineLayoutDescriptor, PrimitiveState, Queue, RenderPass, RenderPipeline,
RenderPipelineDescriptor, ShaderModuleDescriptor, ShaderSource, TextureFormat, VertexState,
};
@@ -69,6 +69,7 @@ impl TargetPointPipeline {
}],
});
println!("TargetPointPipeline created");
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),
@@ -176,7 +177,6 @@ fn generate_sphere(precision: usize) -> (Vec<ModelVertex>, Vec<u32>) {
x.2.into_inner() as f32,
1.0,
],
tex_coords: [0.0, 0.0],
normal: [0.0, 0.0, 0.0],
})
.collect();

View File

@@ -45,17 +45,14 @@ impl RenderedMesh {
out.extend_from_slice(&[
ModelVertex {
position: [a.x, a.y, a.z, 1.0],
tex_coords: [0.0, 0.0],
normal: normal.into(),
},
ModelVertex {
position: [b.x, b.y, b.z, 1.0],
tex_coords: [0.0, 0.0],
normal: normal.into(),
},
ModelVertex {
position: [c.x, c.y, c.z, 1.0],
tex_coords: [0.0, 0.0],
normal: normal.into(),
},
]);

View File

@@ -11,25 +11,18 @@ struct Context {
struct VertexOutput {
@builtin(position)
camera_position: vec4<f32>,
@location(0)
position: vec4<f32>,
@location(1)
tex_coord: vec2<f32>,
@location(2)
normal: vec3<f32>,
};
@vertex
fn vert(
@location(0) position: vec4<f32>,
@location(1) tex_coord: vec2<f32>,
@location(2) normal: vec3<f32>,
@location(1) normal: vec3<f32>,
) -> VertexOutput {
var out: VertexOutput;
out.camera_position = context.transform * position;
out.position = context.transform * position;
out.tex_coord = tex_coord;
out.normal = normalize((context.model_transform * vec4(normal, 0.0)).xyz);
return out;
}

View File

@@ -9,25 +9,18 @@ struct Context {
struct VertexOutput {
@builtin(position)
camera_position: vec4<f32>,
@location(0)
position: vec4<f32>,
@location(1)
tex_coord: vec2<f32>,
@location(2)
normal: vec3<f32>,
};
@vertex
fn vert(
@location(0) position: vec4<f32>,
@location(1) tex_coord: vec2<f32>,
@location(2) normal: vec3<f32>,
@location(1) normal: vec3<f32>,
) -> VertexOutput {
var out: VertexOutput;
out.camera_position = position;
out.position = position;
out.tex_coord = tex_coord;
out.normal = normal;
return out;
}

View File

@@ -7,25 +7,18 @@ struct Context {
struct VertexOutput {
@builtin(position)
camera_position: vec4<f32>,
@location(0)
position: vec4<f32>,
@location(1)
tex_coord: vec2<f32>,
@location(2)
@location(0)
normal: vec3<f32>,
};
@vertex
fn vert(
@location(0) position: vec4<f32>,
@location(1) tex_coord: vec2<f32>,
@location(2) normal: vec3<f32>,
@location(1) normal: vec3<f32>,
) -> VertexOutput {
var out: VertexOutput;
out.camera_position = context.transform * position;
out.position = position;
out.tex_coord = tex_coord;
out.position = context.transform * position;
out.normal = normal;
return out;
}