Global ilumination
This commit is contained in:
19
math.h
19
math.h
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user