Post by godzil on Mar 11, 2020 12:00:41 GMT
I'm getting something weird with the smooth triangles, and I can't determine if it is normal on not.
Here is a scene I have made using the high poly teapot in green in the back and two low poly teapot in the front:
Up so far everything looks Ok, both in the front used a modified version of the low poly teapot file that does not have normal vectors.
Now I use the original low poly instead so they use smooth triangles:
That's where the shading looks a bit weird.
Some of the shadow are a bit weird, but as it is low poly I can accept that, where it is weird is like on the left teapot, if you look where the specular happen on it, on the bottom right face in it,the shading does not match at all like if on the top left vertex, the normal would not be the same as on the other faces that share that point.
It's a bit difficult to know which vertex of the teapot this one is, but I doubt that it would have such an issue.
We can see similar problems on the right teapot at the bottom.
I don't have a reference scene/output that I could use to check mine here, I don't think I've made a big mistake while parsing the OBJ file, nor with the shading algorythm for the smooth triangles, I've check the book and mine numerous time with nothing that seems incorrect.
Here is a description of the scene if someone is interested to check his render against mine (it is a streamed version of the actual C++ code that build the scene, I've removed what is not relevant
/* Add lights */
Light light1 = Light(POINT_LIGHT, Point(50, 100, 20), Colour(.5, .5, .5));
Light light2 = Light(POINT_LIGHT, Point(2, 50, 100), Colour(.5, .5, .5));
/* ----------------------------- */
/* Floor */
Material planesMaterial = Material();
CheckersPattern checkered = CheckersPattern(Colour(0.35, 0.35, 0.35), Colour(0.4, 0.4, 0.4));
planesMaterial.pattern = &checkered;
planesMaterial.ambient = 1;
planesMaterial.diffuse = 0;
planesMaterial.specular = 0;
Plane p = Plane();
p.setMaterial(planesMaterial);
p.material.reflective = 0.1;
Plane p2 = Plane();
p2.setTransform(translation(0, 0, -10) * rotationX(M_PI/2));
p2.setMaterial(planesMaterial);
Material lowPoly = Material();
lowPoly.colour = Colour(1, 0.3, 0.2);
lowPoly.shininess = 5;
lowPoly.specular = 0.4;
OBJFile teapot = OBJFile("teapot-low.obj");
teapot.setTransform(translation(7, 0, 3) * rotationY(M_PI*23/22) * rotationX(-M_PI/2) * scaling(0.3, 0.3, 0.3));
teapot.setMaterial(lowPoly);
OBJFile teapot2 = OBJFile("teapot-low.obj");
teapot2.setTransform(translation(-7, 0, 3) * rotationY(-M_PI*46/22) * rotationX(-M_PI/2) * scaling(0.3, 0.3, 0.3));
teapot2.setMaterial(lowPoly);;
Material highPoly = Material();
highPoly.colour = Colour(0.3, 1, 0.2);
highPoly.shininess = 5;
highPoly.specular = 0.4;
highPoly.reflective = 0.5;
OBJFile teapot3= OBJFile("teapot.obj");
teapot3.setTransform(translation(0, 0, -5) * rotationY(-M_PI) * rotationX(-M_PI/2) * scaling(0.4, 0.4, 0.4));
teapot3.setMaterial(highPoly);
/* ----------------------------- */
/* Set the camera */
Camera camera = Camera(1000, 500, M_PI/2);
camera.setTransform(viewTransform(Point(0, 7, 13),
Point(0, 1, 0),
Vector(0, 1, 0)));