feat: vertex colors

This commit is contained in:
2025-11-29 10:07:59 +01:00
parent 0c94bf1df2
commit efbde487cc
5 changed files with 15 additions and 6 deletions

View File

@@ -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] +