Harbor

branch main
showing the latest snapshot on main
spec_constant.msl 1.1 KB · Plain text
shader/tests/golden/spec_constant.msl 0644 Raw
#include <metal_stdlib>
using namespace metal;

constant int NUM_LIGHTS [[function_constant(0)]];
constant float BRIGHTNESS [[function_constant(1)]];
constant bool USE_GAMMA [[function_constant(2)]];

struct Uniforms {
	float3 base_color;
	float ambient;
};

struct _vs_main_Input {
	float3 position [[attribute(0)]];
};

struct VertexOutput {
	float4 position [[position]];
};

struct _fs_main_Input {
	float4 frag_coord [[user(locn0)]];
};

struct _fs_main_Output {
	float4 color [[user(locn0)]];
};

vertex VertexOutput vs_main(_vs_main_Input input [[stage_in]]) {
	VertexOutput __luma_output;
	__luma_output.position = float4(input.position, 1.0);
	return __luma_output;
}

fragment _fs_main_Output fs_main(_fs_main_Input input [[stage_in]],
	constant Uniforms& uniforms [[buffer(0)]]) {
	_fs_main_Output __luma_output;
	float3 color = (uniforms.base_color * uniforms.ambient);
	int i = 0;
	while ((i < NUM_LIGHTS)) {
		color = (color + float3(0.1, 0.1, 0.1));
		i = (i + 1);
	}
	color = (color * BRIGHTNESS);
	__luma_output.color = float4(color, 1.0);
	return __luma_output;
}