Harbor

branch main
showing the latest snapshot on main
group_old.luma 822 B · Plain text
gpu/shader/tests/equivalence/group_old.luma 0644 Raw
struct VertexOutput
	@builtin(position) position: vec4
	uv: vec2
end

struct Camera
	view_proj: mat4
	position: vec3
end

struct FragmentOutput
	color: vec4
end

struct Lighting
	direction: vec3
	color: vec3
	intensity: float
end

@group(0) uniform camera: Camera
@group(0) uniform lighting: Lighting
@group(1) uniform diffuse_tex: sampler2D
@group(1) uniform normal_tex: sampler2D

@entry(fragment)
function fs_main(input: VertexOutput) -> FragmentOutput
	let diffuse = sample(diffuse_tex, input.uv)
	let normal_sample = sample(normal_tex, input.uv)
	let n = normalize(normal_sample.xyz * 2.0 - vec3(1.0, 1.0, 1.0))
	let l = normalize(lighting.direction)
	let ndotl = max(dot(n, l), 0.0)
	let lit = diffuse.rgb * lighting.color * ndotl * lighting.intensity
	return FragmentOutput {
		color = vec4(lit, diffuse.a),
	}
end