debug physics models visually
This commit is contained in:
@ -86,6 +86,29 @@ fn vs_entity_texture(
|
||||
return result;
|
||||
}
|
||||
|
||||
@group(1)
|
||||
@binding(0)
|
||||
var<uniform> model_instance: ModelInstance;
|
||||
|
||||
struct DebugEntityOutput {
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(1) normal: vec3<f32>,
|
||||
@location(2) view: vec3<f32>,
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_debug(
|
||||
@location(0) pos: vec3<f32>,
|
||||
@location(1) normal: vec3<f32>,
|
||||
) -> DebugEntityOutput {
|
||||
var position: vec4<f32> = model_instance.transform * vec4<f32>(pos, 1.0);
|
||||
var result: DebugEntityOutput;
|
||||
result.normal = model_instance.normal_transform * normal;
|
||||
result.view = position.xyz - camera.view_inv[3].xyz;//col(3)
|
||||
result.position = camera.proj * camera.view * position;
|
||||
return result;
|
||||
}
|
||||
|
||||
//group 2 is the skybox texture
|
||||
@group(1)
|
||||
@binding(0)
|
||||
@ -110,3 +133,8 @@ fn fs_entity_texture(vertex: EntityOutputTexture) -> @location(0) vec4<f32> {
|
||||
let reflected_color = textureSample(cube_texture, cube_sampler, reflected).rgb;
|
||||
return mix(vec4<f32>(vec3<f32>(0.05) + 0.2 * reflected_color,1.0),mix(vertex.model_color,vec4<f32>(fragment_color.rgb,1.0),fragment_color.a),0.5+0.5*abs(d));
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_debug(vertex: DebugEntityOutput) -> @location(0) vec4<f32> {
|
||||
return model_instance.color;
|
||||
}
|
||||
|
Reference in New Issue
Block a user