Acerca de la demo anterior del Ray-Marching, el autor da una explicación en uno de los comentarios:
Usually you render objects with triangles, which get rasterized into pixels.
Here you do it the other way around checking for each pixel on screen if an objects is there.
For that you shoot a ray into the scene per pixel from the camera position.
Each ray then steps though the scene checking if it hits something.
If it does, it also check the direction the surface points at (normal vector) and can then apply shading.
In this case some color effects or fancy texturing.
The special part about raymarching compared to e.g. ray-tracing is the way objects are described.
Instead of meshes out of triangles, objects are just mathematical functions telling you how close you are to them (called SDFs).
Or in other words, if i give it a point in 3D space, it tells me how far away the closest point on the surface is.
So the raymarcher can then stop if the distance becomes small enough for me to consider it a hit.
Note that it has no idea where objects are, or even the direction, it can only check the distance.
A sphere for example can be described as:
"sqrt(x*x + y*y + z*z) - radius"
Where xyz are the position of the ray.
The special thing that makes raymarching "fast" is that instead of stepping the ray at small fixed steps,
you can always step by the amount the SDF returned.
Since you know that that distance is the closest thing to possibly hit.
But on N64 as you can imagine it is painfully slow, since there are many (looped) steps i have to do per pixel.
Lo que se está renderizando no es una malla de polígonos generada a partir de vértices en el espacio, sino formas geométricas descritas por fórmulas matemáticas. Por eso las formas son tan simples. A cambio la superficies son perfectamente curvas. Fijaos que no se notan segmentos en las aristas y que la iluminación es por píxel.
Pero la principal peculiaridad de la demo es que en lugar de montar la escena en la parte del espacio que puede ver la cámara y empezar a dibujar y descartar las formas que hay delante y detrás para dibujar la imagen final, lo que hace es lanzar un rayo desde la cámara por cada píxel de la pantalla y comprobar si choca con algo para poder dibujarlo. Cuando el rayo choca con la superficie luego tiene en cuenta la normal de esa superficie para aplicar texturas y otros efectos.
Se supone que esta forma de renderizado es rápida, pero en Nintendo 64 es lentísima supongo que por los problemas de fillrate que tiene la consola y que todo se hace secuencialmente y no es posible hacerlo en paralelo. Quizás alguien lo pueda explicar mejor.
Yeah i tried skip some of the calculations for repetition, but the issue i was running into was that it ironically increased cost.
One main difference to modern hardware is that the CPU/RSP are single core processors.
So each pixel/ray happens in sequence (well the RSP is vectorized, so some calculations can do 2 rays at once).
But adding one instruction per ray means i pay it per-pixel, whereas modern hardware / GPUs can offset the cost since you only pay it once per batch as they actually run in parallel.
Esto no se puede aplicar en juegos, pero el autor comenta que sí que se puede sacar partido a los skyboxes. Por lo que entiendo de la descripción son como cubemaps de 1024x512 píxeles de resolución. Supongo que RGBA16, como las texturas de la demo, pero eso no lo especifica.
Por comparar, el
skybox de los Zeldas está formado por medio cubo troceado en cuadrados para acoplar 93 texturas de 8 bits de profundidad de coloar de 32x32 píxeles de tamaño. Estas texturas se acoplan para formar una imagen de 512x192 píxeles.