29 lines
744 B
WebGPU Shading Language
29 lines
744 B
WebGPU Shading Language
#import bevy_pbr::{
|
|
forward_io::VertexOutput,
|
|
mesh_view_bindings::view,
|
|
}
|
|
|
|
struct OutlineMaterial {
|
|
color: vec4<f32>,
|
|
rim_power: f32,
|
|
rim_mix: f32,
|
|
pass_kind: u32,
|
|
}
|
|
|
|
@group(#{MATERIAL_BIND_GROUP}) @binding(0)
|
|
var<uniform> material: OutlineMaterial;
|
|
|
|
@fragment
|
|
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
|
let world_normal = normalize(in.world_normal);
|
|
let view_dir = normalize(view.world_position.xyz - in.world_position.xyz);
|
|
let fresnel = pow(1.0 - saturate(dot(world_normal, view_dir)), material.rim_power);
|
|
|
|
var alpha = fresnel * material.rim_mix;
|
|
if material.pass_kind == 1u {
|
|
alpha *= 0.8;
|
|
}
|
|
|
|
return vec4(material.color.rgb, material.color.a * saturate(alpha));
|
|
}
|