(I am new to Computer Graphics in general)
I am learning how to ray trace from a book called ''Peter Shirley - Ray Tracing in One Weekend''. In the book, the code is written in C++. I have intermediate-advanced level understanding of good ol' C, but I've never written even simple programs in C++. I don't pretend to understand everything the code says in the book. But, that is the fun part -- figuring it out.
But, for ray tracing, even C is slow. And writing GLSL fragment shaders is fast, even on my potato PC. And GLSL is closer to C than to C++. So, I'm trying to follow through the book using GLSL. But, GLSL has many limitations and I was hoping if you could teach me how to get around those limitations.
Pointers. GLSL doesn't have pointers. In the book, there is a function
bool hit_sphere(const vec3& center, float radius, const ray& r)
I believe that ''address of'' operator just points to the variable that is passed when the function is called. Without pointers, how to call a function by reference in GLSL?Late binding. In the book, every object is a class which exposes an interface function called
hit
which returns if a ray hits the object. How does one implement that in GLSL structs?