Voxelers/mcthings

Research Ray Tracing

acs opened this issue · 11 comments

acs commented

OpenGL is for rastering, so, what about ray tracing? AMD implement it using shaders (GLSL?)

For voxels, ray tracing is the way to go to render with solid internals reflected?

https://github.com/dannyfritz/awesome-ray-tracing

APIs: https://github.com/dannyfritz/awesome-ray-tracing#apis

http://www.realtimerendering.com/ Several books about Ray Tracing. I will take a look to find the most interesting one for leaning.

Hardware implementing it:

acs commented

http://www.realtimerendering.com/raytracinggems/ Advanced Ray Tracing, but with introductory chapters, slides, videos ... and pretty recent, from 2019. Let's take a look. https://developer.nvidia.com/video/GDC-19/RAYTRACINGGEMS Too much advanced yet I have read now all slides and I can understand now a good portion of the contents. Advancing!

acs commented

I would love to follow this one, but I need to recover my C++ skills and I need a full weekend: https://github.com/RayTracing/raytracing.github.io Right now, I want to understand the key elements in Ray Tracing.

acs commented

Let's try this one: http://www.realtimerendering.com/raytracing/An-Introduction-to-Ray-Tracing-The-Morgan-Kaufmann-Series-in-Computer-Graphics-.pdf

It is the original one from 1989. But it has been updated in 2019 to the 1.3 version. And it is CC-by.

«This book is a revised and edited version of reference material prepared for an intensive one-day course on ray tracing» So probably it is whay I am looking for now!

I am reading this book and at least, the introduction chapter, it is what I was searching for.

acs commented

Ok, let's focus in https://excamera.com/sphinx/article-ray.html to test the ray tracer and maybe, create our own version.

Forked at: https://github.com/acs/raytrace

Let's start with the slower and simpler version: https://gist.github.com/rossant/6046463 Which in the repository is https://github.com/acs/raytrace/blob/master/raytracing.py

acs commented

In order to understand ray tracing and to implement it, it is key to understand the different types of lights that exist:

https://www.iu.edu.jo/files/FacultyIT/slides_it/ComputerGraphics/lecture%207.pdf

  • Emitted
  • Ambient
  • Diffuse
  • Specular

In the ray tracer sample, the last three are used. The objects don't emit light in this scene (and in general).

It seems that in the example, the https://en.wikipedia.org/wiki/Phong_reflection_model is used to describe how light is reflected in the objects. So how the objects appears in the scene.

The key logic is how the color of each pixel is defined:

    # Start computing the color.
    col_ray = ambient
    # Lambert shading (diffuse).
    col_ray += obj.get('diffuse_c', diffuse_c) * max(np.dot(N, toL), 0) * color
    # Blinn-Phong shading (specular).
    col_ray += obj.get('specular_c', specular_c) * max(np.dot(N, normalize(toL + toO)), 0) ** specular_k * color_light

And it is pretty natural: the color of each pixels is the sum of ambient light, diffuse light and specular light. Ambient is the same for all visible voxels of the scene. But diffuse and specular are computed using two algorithms.

So for each ray hitting a voxel we compute its color using this method.

acs commented

A pretty cool introduction, with a good balance between introducing basic concepts and explaining the whole thing: https://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-ray-tracing/adding-reflection-and-refraction (at least for my current vision of ray tracing).

And https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection describe a minimal ray tracer!