summaryrefslogtreecommitdiff
path: root/src/shaders/common.c
blob: 3b58524039652fd771ceaf142d92aa9417099c08 (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
#include "common.h"

Vec3 normal_from_color(Color32 c32) {
	Vec3 normal = {
		c32.r * 2 - 1,
		c32.g * 2 - 1,
		c32.b * 2 - 1,
	};
	return normal;
}

Mat4 mat4(Vec4* c1, Vec4* c2, Vec4* c3, Vec4* c4);

Mat3 mat3(Vec3* c1, Vec3* c2, Vec3* c3) {
	Mat3 m = {
		c1->x,c1->y,c1->z,
		c2->x,c2->y,c2->z,
		c3->x,c3->y,c3->z,
	};
	return m;
}

Vec2 texsize(Texture* texture) {
	Vec2 size = {texture->width, texture->height};
	return size;
}