Global ilumination

This commit is contained in:
Krzosa Karol
2022-02-20 20:49:55 +01:00
parent 03777764b7
commit 4b6cd41c01
3 changed files with 69 additions and 60 deletions

19
math.h
View File

@@ -28,6 +28,12 @@ Vec4 vec4(Vec3 a, float b) {
return result;
}
FUNCTION
Vec3 vec3(float x, float y, float z) {
Vec3 result = { x,y,z };
return result;
}
FUNCTION
Mat4 make_matrix_identity() {
Mat4 result = {
@@ -259,6 +265,19 @@ Vec3 cross(Vec3 a, Vec3 b) {
return result;
}
FUNCTION
float length(Vec3 a) {
float result = sqrt(a.x*a.x + a.y*a.y + a.z*a.z);
return result;
}
FUNCTION
Vec3 normalize(Vec3 a) {
float len = length(a);
Vec3 result = {a.x/len, a.y/len, a.z/len};
return result;
}
FUNCTION
U32 color_to_u32argb(Vec4 a) {
uint8_t r8 = (uint8_t)(a.r * 255.f);