Harbor

branch main
showing the latest snapshot on main
varying_test.luma 775 B · Plain text
shader/tests/shaders/varying_test.luma 0644 Raw
-- Test @varying struct: shared between vertex output and fragment input
-- Fragment input should strip @builtin(position)
-- Uses auto-location and auto-binding

struct VertexInput
	position: vec3
	uv: vec2
end

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

struct FragmentOutput
	color: vec4
end

struct Uniforms
	mvp: mat4
end

uniform uniforms: Uniforms

@entry(vertex)
function vs_main(input: VertexInput) -> Interpolated
	let clip_pos = uniforms.mvp * vec4(input.position, 1.0)
	return Interpolated {
		position = clip_pos,
		uv = input.uv,
		normal = vec3(0.0, 1.0, 0.0),
	}
end

@entry(fragment)
function fs_main(input: Interpolated) -> FragmentOutput
	return FragmentOutput {
		color = vec4(input.uv, 0.0, 1.0),
	}
end