Remove texture coord from model vertex
This commit is contained in:
@@ -3,8 +3,7 @@ use std::mem;
|
|||||||
use dispatch::solid_line::SolidLineDispatch;
|
use dispatch::solid_line::SolidLineDispatch;
|
||||||
use eframe::CreationContext;
|
use eframe::CreationContext;
|
||||||
use pipelines::{
|
use pipelines::{
|
||||||
model::ModelPipeline, slice_preview::SlicePreviewPipeline,
|
model::ModelPipeline, slice_preview::SlicePreviewPipeline, target_point::TargetPointPipeline,
|
||||||
target_point::TargetPointPipeline,
|
|
||||||
};
|
};
|
||||||
use slice_preview::SlicePreviewRenderResources;
|
use slice_preview::SlicePreviewRenderResources;
|
||||||
use wgpu::{BufferAddress, VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode};
|
use wgpu::{BufferAddress, VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode};
|
||||||
@@ -28,15 +27,10 @@ pub const VERTEX_BUFFER_LAYOUT: VertexBufferLayout = VertexBufferLayout {
|
|||||||
shader_location: 0,
|
shader_location: 0,
|
||||||
},
|
},
|
||||||
VertexAttribute {
|
VertexAttribute {
|
||||||
format: VertexFormat::Float32x2,
|
format: VertexFormat::Float32x3,
|
||||||
offset: 4 * 4,
|
offset: 4 * 4,
|
||||||
shader_location: 1,
|
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)]
|
#[derive(Default, Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
|
||||||
pub struct ModelVertex {
|
pub struct ModelVertex {
|
||||||
pub position: [f32; 4],
|
pub position: [f32; 4],
|
||||||
pub tex_coords: [f32; 2],
|
|
||||||
pub normal: [f32; 3],
|
pub normal: [f32; 3],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,6 +57,7 @@ impl ModelPipeline {
|
|||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
println!("ModelPipeline created");
|
||||||
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
|
@@ -69,6 +69,7 @@ impl SlicePreviewPipeline {
|
|||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
println!("SlicePreviewPipeline created");
|
||||||
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
@@ -105,7 +106,6 @@ impl SlicePreviewPipeline {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|[x, y]| ModelVertex {
|
.map(|[x, y]| ModelVertex {
|
||||||
position: [x, y, 0.0, 1.0],
|
position: [x, y, 0.0, 1.0],
|
||||||
tex_coords: [0.0, 0.0],
|
|
||||||
normal: [0.0, 0.0, 1.0],
|
normal: [0.0, 0.0, 1.0],
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
@@ -92,6 +92,7 @@ impl SolidLinePipeline {
|
|||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
println!("SolidLinePipeline created");
|
||||||
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
|
@@ -8,8 +8,8 @@ use plexus::primitive::{
|
|||||||
use wgpu::{
|
use wgpu::{
|
||||||
util::{BufferInitDescriptor, DeviceExt},
|
util::{BufferInitDescriptor, DeviceExt},
|
||||||
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, BlendState, Buffer,
|
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, BlendState, Buffer,
|
||||||
BufferBinding, BufferDescriptor, BufferUsages, ColorTargetState, ColorWrites,
|
BufferBinding, BufferDescriptor, BufferUsages, ColorTargetState, ColorWrites, CompareFunction,
|
||||||
CompareFunction, DepthStencilState, Device, FragmentState, IndexFormat, MultisampleState,
|
DepthStencilState, Device, FragmentState, IndexFormat, MultisampleState,
|
||||||
PipelineLayoutDescriptor, PrimitiveState, Queue, RenderPass, RenderPipeline,
|
PipelineLayoutDescriptor, PrimitiveState, Queue, RenderPass, RenderPipeline,
|
||||||
RenderPipelineDescriptor, ShaderModuleDescriptor, ShaderSource, TextureFormat, VertexState,
|
RenderPipelineDescriptor, ShaderModuleDescriptor, ShaderSource, TextureFormat, VertexState,
|
||||||
};
|
};
|
||||||
@@ -69,6 +69,7 @@ impl TargetPointPipeline {
|
|||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
println!("TargetPointPipeline created");
|
||||||
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
let render_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
@@ -176,7 +177,6 @@ fn generate_sphere(precision: usize) -> (Vec<ModelVertex>, Vec<u32>) {
|
|||||||
x.2.into_inner() as f32,
|
x.2.into_inner() as f32,
|
||||||
1.0,
|
1.0,
|
||||||
],
|
],
|
||||||
tex_coords: [0.0, 0.0],
|
|
||||||
normal: [0.0, 0.0, 0.0],
|
normal: [0.0, 0.0, 0.0],
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@@ -45,17 +45,14 @@ impl RenderedMesh {
|
|||||||
out.extend_from_slice(&[
|
out.extend_from_slice(&[
|
||||||
ModelVertex {
|
ModelVertex {
|
||||||
position: [a.x, a.y, a.z, 1.0],
|
position: [a.x, a.y, a.z, 1.0],
|
||||||
tex_coords: [0.0, 0.0],
|
|
||||||
normal: normal.into(),
|
normal: normal.into(),
|
||||||
},
|
},
|
||||||
ModelVertex {
|
ModelVertex {
|
||||||
position: [b.x, b.y, b.z, 1.0],
|
position: [b.x, b.y, b.z, 1.0],
|
||||||
tex_coords: [0.0, 0.0],
|
|
||||||
normal: normal.into(),
|
normal: normal.into(),
|
||||||
},
|
},
|
||||||
ModelVertex {
|
ModelVertex {
|
||||||
position: [c.x, c.y, c.z, 1.0],
|
position: [c.x, c.y, c.z, 1.0],
|
||||||
tex_coords: [0.0, 0.0],
|
|
||||||
normal: normal.into(),
|
normal: normal.into(),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@@ -11,25 +11,18 @@ struct Context {
|
|||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
@builtin(position)
|
@builtin(position)
|
||||||
camera_position: vec4<f32>,
|
|
||||||
@location(0)
|
|
||||||
position: vec4<f32>,
|
position: vec4<f32>,
|
||||||
@location(1)
|
@location(1)
|
||||||
tex_coord: vec2<f32>,
|
|
||||||
@location(2)
|
|
||||||
normal: vec3<f32>,
|
normal: vec3<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vert(
|
fn vert(
|
||||||
@location(0) position: vec4<f32>,
|
@location(0) position: vec4<f32>,
|
||||||
@location(1) tex_coord: vec2<f32>,
|
@location(1) normal: vec3<f32>,
|
||||||
@location(2) normal: vec3<f32>,
|
|
||||||
) -> VertexOutput {
|
) -> VertexOutput {
|
||||||
var out: VertexOutput;
|
var out: VertexOutput;
|
||||||
out.camera_position = context.transform * position;
|
|
||||||
out.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);
|
out.normal = normalize((context.model_transform * vec4(normal, 0.0)).xyz);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@@ -9,25 +9,18 @@ struct Context {
|
|||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
@builtin(position)
|
@builtin(position)
|
||||||
camera_position: vec4<f32>,
|
|
||||||
@location(0)
|
|
||||||
position: vec4<f32>,
|
position: vec4<f32>,
|
||||||
@location(1)
|
@location(1)
|
||||||
tex_coord: vec2<f32>,
|
|
||||||
@location(2)
|
|
||||||
normal: vec3<f32>,
|
normal: vec3<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vert(
|
fn vert(
|
||||||
@location(0) position: vec4<f32>,
|
@location(0) position: vec4<f32>,
|
||||||
@location(1) tex_coord: vec2<f32>,
|
@location(1) normal: vec3<f32>,
|
||||||
@location(2) normal: vec3<f32>,
|
|
||||||
) -> VertexOutput {
|
) -> VertexOutput {
|
||||||
var out: VertexOutput;
|
var out: VertexOutput;
|
||||||
out.camera_position = position;
|
|
||||||
out.position = position;
|
out.position = position;
|
||||||
out.tex_coord = tex_coord;
|
|
||||||
out.normal = normal;
|
out.normal = normal;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@@ -7,25 +7,18 @@ struct Context {
|
|||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
@builtin(position)
|
@builtin(position)
|
||||||
camera_position: vec4<f32>,
|
|
||||||
@location(0)
|
|
||||||
position: vec4<f32>,
|
position: vec4<f32>,
|
||||||
@location(1)
|
@location(0)
|
||||||
tex_coord: vec2<f32>,
|
|
||||||
@location(2)
|
|
||||||
normal: vec3<f32>,
|
normal: vec3<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vert(
|
fn vert(
|
||||||
@location(0) position: vec4<f32>,
|
@location(0) position: vec4<f32>,
|
||||||
@location(1) tex_coord: vec2<f32>,
|
@location(1) normal: vec3<f32>,
|
||||||
@location(2) normal: vec3<f32>,
|
|
||||||
) -> VertexOutput {
|
) -> VertexOutput {
|
||||||
var out: VertexOutput;
|
var out: VertexOutput;
|
||||||
out.camera_position = context.transform * position;
|
out.position = context.transform * position;
|
||||||
out.position = position;
|
|
||||||
out.tex_coord = tex_coord;
|
|
||||||
out.normal = normal;
|
out.normal = normal;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user