feat: optimized triangle testing
This commit is contained in:
14
renderer.hpp
14
renderer.hpp
@@ -84,15 +84,18 @@ class Renderer {
|
||||
vec3 pos = vec3(testP.bounding[0], testP.bounding[2], 0.0);
|
||||
for (int x = startX; x < endX; x++) {
|
||||
for (int y = startY; y < endY; y++) {
|
||||
|
||||
testP.calcBarycentric(pos);
|
||||
|
||||
if (testP.contains(pos)) {
|
||||
if (testP.small)
|
||||
continue;
|
||||
vec3 factors = testP.calcBarycentric(pos);
|
||||
decimal depth = testP.calcDepth(factors);
|
||||
|
||||
decimal depth = testP.calcDepth();
|
||||
if (depth < target->getDepth(x, y)) {
|
||||
// std::cout << factors << std::endl;
|
||||
vec3 normal = testP.calcNormal(factors);
|
||||
vec3 color = testP.calcColor(factors);
|
||||
vec3 normal = testP.calcNormal();
|
||||
vec3 color = testP.calcColor();
|
||||
decimal lightFac =
|
||||
std::max(normal * (-sunDir), decimal(0.0)) +
|
||||
decimal(0.5);
|
||||
@@ -106,7 +109,8 @@ class Renderer {
|
||||
// target->set(x, y,
|
||||
// (normal + vec3(1.0, 1.0, 1.0)) *
|
||||
// decimal(120.0));
|
||||
// target->set(x, y, factors * decimal(200.0));
|
||||
// target->set(x, y,
|
||||
// testP.barycentrics * decimal(200.0));
|
||||
// if (!factors.isSmall())
|
||||
// target->set(x, y, vec3(0., 255.0, 0.));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user