mstdn.io is one of the many independent Mastodon servers you can use to participate in the fediverse.

Administered by:

Server stats:

368
active users

@penguin42 That's what I want to learn.

I'm familiar with the "naive" algorithm, in which you iterate over each pixel on the screen, casting a ray through it and testing for intersections with every object in the scene.

Once you know the intersection, you cast rays towards every light source in the scene, testing for intersections with objects that could occlude the light. Semi-transparent and reflective materials require recursion (with limits).

It's very simple... but too slow.

@penguin42 The schoolbook algorithm has uneven per pixel workload, making parallelization ontothousands of compute units inefficient.

Furthermore, computing the intersections requires access to the entire scene. Efficient data structures tend to be trees of bounding boxes, with recursive lookups.

Some old RT algorithms switched the two nested loops: the outer loop iterates over each triangle in the scene, and the inner one tests for intersections with screen pixels.

The advantage is that you only need to consider the pixels within the projection of the triangle.

You can also completely cull triangles completely occluded by other triangles in front of them.

I don't know whether this improved algorithm is actually a win for scenes with millions of triangles.

@penguin42

Back to the hardware RT: for a long time, GPUs could dispatch the parallel execution of short functions (historically called shaders). Each instance gets constants such as texture data and variables such as transformed coordinates. The output of these functions can be used to paint pixels on the screen or intermediate buffers.

@penguin42

With this, we reached the boundaries of my hands-on knowledge of accelerated rendering.

This is a little program I wrote a few years ago to learn the basics of GLSL shaders:
github.com/codewiz/mandelwow

(it's also the very first code I wrote in , please forgive the poor style).

@penguin42

The first step to understanding real-time involves a leap to , which generalizes the old rendering model to enable building parallel, multi-pass pipelines using low-level primitives such as command buffers, queues, etc.

I've been reading a few introductory guides, and this is the official one:
github.com/KhronosGroup/Vulkan

@penguin42

GitHubGitHub - KhronosGroup/Vulkan-Guide: One stop shop for getting started with the Vulkan APIOne stop shop for getting started with the Vulkan API - GitHub - KhronosGroup/Vulkan-Guide: One stop shop for getting started with the Vulkan API

The vendor-neutral ray tracing acceleration emerges from the composition of several building blocks, such as VK_KHR_ray_query:
registry.khronos.org/vulkan/sp

You can guess from the number of contributors that standardization took considerable effort. The API must support a variety of use-cases, including hybrid rendering.

Ray queries are the simplest of two available techniques, in which SPIRV shaders can cast arbitrary rays and get back a (distance sorted?) list of hits.

@penguin42

registry.khronos.orgVK_KHR_ray_query(3)
Bernie

The more advanced technique is used in the screenshot at the beginning of this thread: Ray Tracing Pipelines.

This extension is present in , but still flag-guarded for the RADV driver. It crashed my RDNA3 card until last week 😅

AFAICT, the RT pipeline takes away control of the core algorithm, calling shaders attached to surfaces in the scene when they're hit.

This diagram shows that ray generation is still performed by a user-defined shader:

@penguin42