Cleanup model shader
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
@group(0) @binding(0) var<uniform> context: Context;
|
@group(0) @binding(0) var<uniform> context: Context;
|
||||||
|
|
||||||
|
const STYLE_NORMAL: u32 = 0;
|
||||||
|
const STYLE_RANDOM: u32 = 1;
|
||||||
|
const STYLE_RENDERD: u32 = 2;
|
||||||
|
|
||||||
struct Context {
|
struct Context {
|
||||||
transform: mat4x4<f32>,
|
transform: mat4x4<f32>,
|
||||||
model_transform: mat4x4<f32>,
|
model_transform: mat4x4<f32>,
|
||||||
@@ -40,12 +44,15 @@ fn frag(in: VertexOutput) -> @location(0) vec4<f32> {
|
|||||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if context.render_style == 0 {
|
switch context.render_style {
|
||||||
|
case STYLE_NORMAL: {
|
||||||
return vec4<f32>(normal, 1.0);
|
return vec4<f32>(normal, 1.0);
|
||||||
} else if context.render_style == 1 {
|
}
|
||||||
|
case STYLE_RANDOM: {
|
||||||
seed = in.vertex_index;
|
seed = in.vertex_index;
|
||||||
return vec4f(rand(), rand(), rand(), 1.0);
|
return vec4f(rand(), rand(), rand(), 1.0);
|
||||||
} else {
|
}
|
||||||
|
case STYLE_RENDERD: {
|
||||||
let camera_direction = normalize(context.camera_position + context.camera_target);
|
let camera_direction = normalize(context.camera_position + context.camera_target);
|
||||||
|
|
||||||
let diffuse = max(dot(normal, camera_direction), 0.0);
|
let diffuse = max(dot(normal, camera_direction), 0.0);
|
||||||
@@ -56,6 +63,10 @@ fn frag(in: VertexOutput) -> @location(0) vec4<f32> {
|
|||||||
let intensity = (diffuse + specular + 0.1) * context.model_color.rgb;
|
let intensity = (diffuse + specular + 0.1) * context.model_color.rgb;
|
||||||
return vec4<f32>(intensity, context.model_color.a);
|
return vec4<f32>(intensity, context.model_color.a);
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
return vec4<f32>(0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn outside_build_volume(pos: vec3<f32>) -> bool {
|
fn outside_build_volume(pos: vec3<f32>) -> bool {
|
||||||
|
Reference in New Issue
Block a user