|
Post by ascotti on Jan 5, 2019 20:49:59 GMT
I've really had a great time reading the book and working on the raytracer, but from now on I'll have much less time to work on it so progress will be quite slower. I've put what I have on GitHub for anyone who wants to take a look: Funtracer page on GitHub
Here's a cheap trick that is very useful. A lot of .obj files come without normals and look like this: However, it is easy to generate normals at each vertex: just average the normals of all triangles that share that vertex. So all triangles can be made smooth: Simple but effective!
|
|
|
Post by Jamis on Jan 6, 2019 2:08:44 GMT
Neat trick! Thanks for sharing your code. I look forward to seeing how it looks in Go!
|
|
|
Post by accolon on Nov 14, 2019 11:05:11 GMT
How did you implement this? I tried, but my generated normals look really odd. What I did: 1. During OBJ parsing, build a list VN of all vertices V with an associated empty normal vector. 2. For each face F from the OBJ file, generate standard triangle shapes via fan triangulation, this also computes the triangle normals N as described in the book. 3. For each vertex A, B, C of the current triangle, add N to the normal vector of the respective vertex in VN. Keep count of the number of triangles that share this point. 4. Divide all normal vectors in VN by the number of the triangles shared by this point. 5. Generate smooth triangle shapes for all faces by using the vertex normals from VN. I also found this explanation, which is very similar to my approach: www.iquilezles.org/www/articles/normals/normals.htmThe author skips the division in step 4, since scalar division only reduces the vector length and the vectors are normalized anyway. However, something doesn't work out... EDIT: I also took a look at your code, but (ignoring my lack of knowledge concerning Go), I don't see any major differences.
|
|