summaryrefslogtreecommitdiff
path: root/src/shaders/unlit.c
blob: 0b92c8cab486ff08a8fc3cb9c087e4a8209a3fa1 (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
28
29
30
31
32
33
#include "common/core.h"

/*uniforms*/
#define object2world UM4(0)
#define light        UV3(0)
#define maintex      UTEX(0)

/*varyings*/
#define rough reg_num_00

static void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* clipcoord) {
	static Vec4 p; p.xyz = in->vertex->position; p.w = 1;
	internal_mat4_mulvec4(uniforms->mvp, &p, clipcoord);
	Vec4 normal = { 
		in->vertex->normal.x,
		in->vertex->normal.y,
		in->vertex->normal.z,
		1
	};
	Vec4 worldnormal; internal_mat4_mulvec4(object2world, &normal, &worldnormal);
	internal_vec3_normalize(light, light);
	*reg_num_00 = 1 - internal_vec3_dot(&worldnormal, light);
}

static bool frag(UniformCollection* uniforms, Color32* color) {
	internal_vec3_normalize(light, light);
	return 1;
}

Program ssr_built_in_shader_unlit = { 
	vert, frag,
	VARYING_NUM_00
};