Compare commits

..

3 Commits

3 changed files with 7 additions and 5 deletions

View File

@ -45,9 +45,9 @@ int main(void) {
.ambient = 0.3f, .ambient = 0.3f,
.diffuse = 1.5f, .diffuse = 1.5f,
.specular = 2.0f, .specular = 2.0f,
// .ambient = 0.0f, // .ambient = 1.0f,
// .diffuse = 0.0f, // .diffuse = 0.0f,
// .specular = 2.0f, // .specular = 0.0f,
.shininess = 1.5f, .shininess = 1.5f,
}; };
obj.material = material; obj.material = material;

View File

@ -195,7 +195,7 @@ internal TriangleBBox get_triangle_bbox(const Image *img,
internal V3f get_barycentric_coords(V3f a, V3f b, V3f c, V3f p) { internal V3f get_barycentric_coords(V3f a, V3f b, V3f c, V3f p) {
V3f s[2]; V3f s[2];
for (int i = 2; i--;) { for (u64 i = 0; i < 2; ++i) {
s[i].x = c.elements[i] - a.elements[i]; s[i].x = c.elements[i] - a.elements[i];
s[i].y = b.elements[i] - a.elements[i]; s[i].y = b.elements[i] - a.elements[i];
s[i].z = a.elements[i] - p.elements[i]; s[i].z = a.elements[i] - p.elements[i];
@ -206,7 +206,7 @@ internal V3f get_barycentric_coords(V3f a, V3f b, V3f c, V3f p) {
return (V3f){-1.0f, 1.0f, 1.0f}; return (V3f){-1.0f, 1.0f, 1.0f};
} }
return (V3f){1.f - (u.x + u.y) / u.z, u.y / u.z, u.x / u.z}; return (V3f){1.0f - (u.x + u.y) / u.z, u.y / u.z, u.x / u.z};
} }
internal V3f get_viewport_vertex(const V3f *vertex, const Image *img) { internal V3f get_viewport_vertex(const V3f *vertex, const Image *img) {

View File

@ -5,6 +5,8 @@
#include "typed_list.h" #include "typed_list.h"
#include <math.h> #include <math.h>
#define V3_ELEM_COUNT 3
typedef struct i64x2 V2i; typedef struct i64x2 V2i;
struct i64x2 { struct i64x2 {
i64 x; i64 x;
@ -32,7 +34,7 @@ struct f32x2 {
typedef struct f32x3 V3f; typedef struct f32x3 V3f;
struct f32x3 { struct f32x3 {
union { union {
f32 elements[3]; f32 elements[V3_ELEM_COUNT];
struct { struct {
union { union {
f32 x; f32 x;