49 lines
988 B
Plaintext
49 lines
988 B
Plaintext
|
|
#[set(everything)]
|
|
const my_texture: tex2d;
|
|
|
|
#[set(everything)]
|
|
const my_texture_sampler: sampler;
|
|
|
|
#[set(everything)]
|
|
const constants: {
|
|
WVP: float4x4;
|
|
};
|
|
|
|
struct vert_in {
|
|
pos: float4;
|
|
nor: float2;
|
|
tex: float2;
|
|
}
|
|
|
|
struct vert_out {
|
|
pos: float4;
|
|
nor: float3;
|
|
tex: float2;
|
|
}
|
|
|
|
|
|
fun mesh_vert(input: vert_in): vert_out {
|
|
var output: vert_out;
|
|
output.nor = float3(input.nor.xy, input.pos.w);
|
|
output.tex = input.tex;
|
|
output.pos = constants.WVP * float4(input.pos.xyz, 1.0);
|
|
return output;
|
|
}
|
|
|
|
fun mesh_frag(input: vert_out): float4 {
|
|
var l: float3 = float3(0.5, 0.0, 0.5);
|
|
var base_color: float3 = float3(1.0, 1.0, 1.0); // sample(my_texture, my_texture_sampler, input.tex).rgb;
|
|
var ambient: float3 = base_color * 0.5;
|
|
var n: float3 = normalize(input.nor);
|
|
var dotnl: float = max(dot(n, l), 0.0);
|
|
var diffuse: float3 = dotnl * base_color;
|
|
return float4(ambient + diffuse, 1.0);
|
|
}
|
|
|
|
#[pipe]
|
|
struct pipe {
|
|
vertex = mesh_vert;
|
|
fragment = mesh_frag;
|
|
}
|