danielepanozzo / cg-old

44 stars 16 forks source link

[Assignment 1.4] Rendering triangular meshes #80

Closed LihengGong closed 5 years ago

LihengGong commented 5 years ago

I can see in the data file that there are 1000 triangular meshes.

If my understanding of the ray tracing algorithm is correct, for each generated ray, we have to compute whether this ray intersects with each of these 1000 meshes.
And if there is indeed an intersection, we need to computer the coordinate of that point.

That means if we're computing 1000 * 1000 rays, there would be 1000 * 1000 * 1000 iterations of computation(and some of these iterations would involve linear equation solving)?

wwylele commented 5 years ago

yes my program did this. The run time is not that bad.

munircontractor commented 5 years ago

It takes me ~22 mins on my laptop with both meshes loaded in. 800 800 2003 * 2 loops. 800 x 800 pixels, 2000 triangle meshes + 3 spheres and 2 light sources. Is that close to what others are seeing? Just trying to figure out if need to optimize further.

wwylele commented 5 years ago

My run time and pc spec for comparison: 2 light sources + 5 spheres + 2 meshs with everything until parallelization. It took 9 minutes to render. CPU is i7-8750H (base frequency 2.2GHz)

Edit: additional info: I kept the colPivHouseHolder and didn't bother changing it.

munircontractor commented 5 years ago

Thanks. I replaced the colPivHouseholder with the explicit solution and it runs under 5 mins (without shadows and reflections) now. I didn't think it'd make such a huge difference. Guess this can be a PSA for others.

LihengGong commented 5 years ago

Thanks. Rendering the bunny is pretty slow, while rendering the bumpy cube is a little bit faster. I'll try to integrate TBB to speed up the execution.