Harbor

branch main
showing the latest snapshot on main
basic_vertex.luma 670 B · Plain text
gpu/shader/tests/shaders/basic_vertex.luma 0644 Raw
-- Basic vertex shader test
-- Uses auto-location numbering and auto-binding

struct VertexInput
	position: vec3
	normal: vec3
	uv: vec2
end

@varying
struct VertexOutput
	@builtin(position) position: vec4
	uv: vec2
	normal: vec3
end

struct Uniforms
	model: mat4
	view_proj: mat4
	normal_mat: mat4
end

uniform uniforms: Uniforms

@entry(vertex)
function transform(input: VertexInput) -> VertexOutput
	let pos = input.position
	let world_pos = uniforms.model * vec4(pos, 1.0)
	let clip_pos = uniforms.view_proj * world_pos

	return VertexOutput {
		position = clip_pos,
		uv = input.uv,
		normal = normalize((uniforms.normal_mat * vec4(input.normal, 0.0)).xyz),
	}
end