Visulize mesh outside of build volume
This commit is contained in:
1
TODO.md
1
TODO.md
@@ -93,3 +93,4 @@
|
||||
- [ ] Dont fail to load an stl without normals
|
||||
- [ ] GPU accalration for post processing effect?
|
||||
- [ ] Fix requiring viewport to be visible to render preview image
|
||||
- [x] Visulize mesh outside of bounging box
|
||||
|
@@ -32,6 +32,7 @@ pub struct ModelPipeline {
|
||||
struct ModelUniforms {
|
||||
transform: Matrix4<f32>,
|
||||
model_transform: Matrix4<f32>,
|
||||
build_volume: Vector3<f32>,
|
||||
model_color: Vector4<f32>,
|
||||
camera_position: Vector3<f32>,
|
||||
camera_target: Vector3<f32>,
|
||||
@@ -111,6 +112,7 @@ impl ModelPipeline {
|
||||
let uniforms = ModelUniforms {
|
||||
transform: resources.transform * model_transform,
|
||||
model_transform,
|
||||
build_volume: resources.bed_size,
|
||||
model_color: model.color.to_normalized_gamma_f32().into(),
|
||||
camera_position: resources.camera.position(),
|
||||
camera_target: resources.camera.target,
|
||||
|
@@ -3,6 +3,7 @@
|
||||
struct Context {
|
||||
transform: mat4x4<f32>,
|
||||
model_transform: mat4x4<f32>,
|
||||
build_volume: vec3<f32>,
|
||||
model_color: vec4<f32>,
|
||||
camera_position: vec3<f32>,
|
||||
camera_target: vec3<f32>,
|
||||
@@ -35,6 +36,10 @@ fn frag(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let dx = dpdx(in.world_position);
|
||||
let normal = normalize(cross(dy, dx));
|
||||
|
||||
if outside_build_volume(in.world_position) {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
if context.render_style == 0 {
|
||||
return vec4<f32>(normal, 1.0);
|
||||
} else {
|
||||
@@ -49,3 +54,10 @@ fn frag(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(intensity, context.model_color.a);
|
||||
}
|
||||
}
|
||||
|
||||
fn outside_build_volume(pos: vec3<f32>) -> bool {
|
||||
let build = context.build_volume / 2.0;
|
||||
return pos.x < -build.x || pos.x > build.x
|
||||
|| pos.y < -build.y || pos.y > build.y
|
||||
|| pos.z < 0.0 || pos.x > context.build_volume.z;
|
||||
}
|
||||
|
Reference in New Issue
Block a user