41 lines
750 B
C
41 lines
750 B
C
#pragma once
|
|
|
|
#include "tuples.h"
|
|
#include "lights.h"
|
|
#include "patterns.h"
|
|
#include "math.h"
|
|
|
|
struct material {
|
|
float ambient;
|
|
float diffuse;
|
|
float specular;
|
|
float shininess;
|
|
bool has_pattern;
|
|
union {
|
|
struct tuple color;
|
|
struct pattern pattern;
|
|
};
|
|
};
|
|
|
|
inline static struct material material()
|
|
{
|
|
return (struct material){
|
|
0.1f,
|
|
0.9f,
|
|
0.9f,
|
|
200.0f,
|
|
.has_pattern = false,
|
|
.color = color(1.0f, 1.0f, 1.0f),
|
|
};
|
|
}
|
|
|
|
inline static bool material_equal(struct material a, struct material b)
|
|
{
|
|
return
|
|
tuple_equal(a.color, b.color) &&
|
|
float_equal(a.ambient, b.ambient) &&
|
|
float_equal(a.diffuse, b.diffuse) &&
|
|
float_equal(a.specular, b.specular) &&
|
|
float_equal(a.shininess, b.shininess);
|
|
}
|