60 lines
1.3 KiB
Plaintext
60 lines
1.3 KiB
Plaintext
[nzsl_version("1.0")]
|
|
module;
|
|
|
|
import InstanceData from Engine.InstanceData;
|
|
import ViewerData from Engine.ViewerData;
|
|
|
|
[layout(std140)]
|
|
struct MaterialSettings
|
|
{
|
|
[tag("AlphaTestThreshold")]
|
|
AlphaThreshold: f32,
|
|
|
|
[tag("BaseColor")]
|
|
BaseColor: vec4[f32]
|
|
}
|
|
|
|
[tag("Material")]
|
|
external
|
|
{
|
|
[tag("Settings"), binding(0)] settings: uniform[MaterialSettings],
|
|
[tag("BaseColorMap"), binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
|
[tag("AlphaMap"), binding(2)] MaterialAlphaMap: sampler2D[f32],
|
|
}
|
|
|
|
[tag("Engine")]
|
|
external
|
|
{
|
|
[tag("TextureOverlay"), binding(3)] TextureOverlay: sampler2D[f32],
|
|
[tag("InstanceData"), binding(4)] instanceData: uniform[InstanceData],
|
|
[tag("ViewerData"), binding(5)] viewerData: uniform[ViewerData],
|
|
}
|
|
|
|
struct InputData
|
|
{
|
|
[location(0)] pos: vec3[f32],
|
|
[location(1)] normal: vec3[f32],
|
|
[location(2)] uv: vec2[f32]
|
|
}
|
|
|
|
struct OutputData
|
|
{
|
|
[location(0)] normal: vec3[f32],
|
|
[location(1)] uv: vec2[f32],
|
|
[location(2)] pos: vec3[f32],
|
|
[builtin(position)] position: vec4[f32]
|
|
}
|
|
|
|
[entry(vert)]
|
|
fn main(input: InputData) -> OutputData
|
|
{
|
|
let worldPos = instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
|
|
|
let output: OutputData;
|
|
output.uv = input.uv;
|
|
output.normal = input.normal;
|
|
output.pos = worldPos.xyz;
|
|
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
|
return output;
|
|
}
|