feat: barycentric interpolation for normals

This commit is contained in:
2025-11-22 12:08:18 +01:00
parent 9a8b1fb5c1
commit 0c94bf1df2
3 changed files with 83 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ class Rendertarget {
Rendertarget(int width, int height) : width(width), height(height) {
pixels = new decimal[width * height * 3];
depth = new decimal[width * height];
}
void set(int x, int y, vec3 val) {
@@ -25,8 +26,17 @@ class Rendertarget {
(*val)[i] = pixels[start + i];
}
}
decimal getDepth(int x, int y) { return depth[width * y + x]; }
void setDepth(int x, int y, decimal val) { depth[width * y + x] = val; }
void clearDepth() {
for (int i = 0; i < width * height; i++) {
depth[i].i = std::numeric_limits<int32_t>::max();
}
}
decimal *pixels;
decimal *depth;
};
#endif