feat: vertex colors
This commit is contained in:
@@ -11,6 +11,7 @@ struct polygon {
|
||||
|
||||
decimal bounding[4]; // min x, max x, min y, max y
|
||||
vec3 normals[3];
|
||||
vec3 colors[3];
|
||||
|
||||
polygon(const vec3 &v1, const vec3 &v2, const vec3 &v3)
|
||||
: points{v1, v2, v3}, delta{} {}
|
||||
@@ -84,6 +85,11 @@ struct polygon {
|
||||
return result.normalize();
|
||||
}
|
||||
|
||||
vec3 calcColor(vec3 barycentrics) {
|
||||
return colors[0] * barycentrics[0] + colors[1] * barycentrics[1] +
|
||||
colors[2] * barycentrics[2];
|
||||
}
|
||||
|
||||
decimal calcDepth(vec3 barycentrics) {
|
||||
return points[0].z() * barycentrics[0] +
|
||||
points[1].z() * barycentrics[1] +
|
||||
|
||||
Reference in New Issue
Block a user