ssloy / tinyraytracer

A brief computer graphics / rendering course
https://github.com/ssloy/tinyraytracer/wiki
5k stars 333 forks source link

Tinyraytracer in Python #16

Open masscry opened 5 years ago

masscry commented 5 years ago

Hello!

Thank you for very interesting materials!

I ported most of code to Python (except bunny rendering...).

python-tinyraytracer It is a bit dirty and not very pythonic, but it works and produces same results.

out

ssloy commented 5 years ago

Good job, thank you for sharing! One minor comment:

in this place i'd put spherical coordinates instead:

x = int((math.atan2(norm_dir.z, norm_dir, x)/(2*math.pi) + 0.5)*env_width)
y = int(math.acos(norm_dir.y)/math.pi*env_height)
masscry commented 5 years ago

Nice! That is much better!

out

I used environment map in low resolution, so background becomes too blocky without filtering.

masscry commented 5 years ago

Rendering time skyrocketed (~30 minutes) with duck mesh on scene, but with bounding box I got reasonable ~2 minutes per draw.

out

ssloy commented 5 years ago

Yup, exponential complexity. I give this in my lectures to motivate for the rasterization technique.

I guess that Python makes it a little bit more expensive, C++ implementation takes a couple of minutes without the bounding box.