summaryrefslogtreecommitdiff
path: root/src/shaders/common.c
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-12-15 00:39:18 +0800
committerchai <chaifix@163.com>2019-12-15 00:39:18 +0800
commit749bbc6a54e50c297ab49d9e515a3679651d1461 (patch)
tree097bbe044332e816aa481db1a4e325b8d3f63b0d /src/shaders/common.c
parent3f44877edfe4c301b258d522bcb4e8d9b6e92382 (diff)
*misc
Diffstat (limited to 'src/shaders/common.c')
-rw-r--r--src/shaders/common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/shaders/common.c b/src/shaders/common.c
new file mode 100644
index 0000000..f36e272
--- /dev/null
+++ b/src/shaders/common.c
@@ -0,0 +1,21 @@
+#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;
+}