summaryrefslogtreecommitdiff
path: root/src/shaders/unlit.c
blob: 7ff44971399a56bb27685855e38fb1b6037e9e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "common_header.h"

#define light UV3(0)
#define maintex TEX(0)

#define vert_color reg_v4_00

static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) {
	static Vec4 p; p.xyz = in->vertex->position; p.w = 1;
	mat4_applytovec4(uniforms->mvp, &p, clipcoord);
	color_tocolor32(in->vertex->color, vert_color);
}

static bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color* color) {
	vec3_normalize(light, light);
	vec3_normalize(&in->normal, &in->normal);
	float strongness = vec3_dot(light, &in->normal);
	vec3_scale(vert_color, 1 - clamp(strongness, 0, 1), vert_color);
	*color = color32_tocolor(vert_color);
	
	return 1;
}

Program ssr_built_in_shader_unlit = { 
	vert, frag,
	VARYING_V4_00
};