Spheres
Created 2015-01-09T07:13:26.468Z, last edited 2015-01-09T12:43:17.062Z

Spheres
Lots of shiny spheres is a staple of ray traced images :)
One of the features of AnimRay's templated code approach is that it gives you complete control over layout of the memory of the scene. This and the multi-coloured spheres image below are a test to see how memory layout affects performance.
For the coloured spheres version the memory layout for each sphere roughly corresponds to:
- four doubles for the x/y/z location of the sphere centre.
- one double for the glossiness or reflectivity
- three doubles for the RGB colour.
This is a total of 64 bytes per sphere (eight doubles times eight bytes). There's no complex spacial optimisation, so the ray tracer simply goes through these in order tracking which is the first to hit any given ray.
The question I had was whether this was memory or CPU constrained. The spheres are all held in a contiguous memory block which means that the data should be being pulled from RAM at the maximum memory bandwidth. If the intersection calculation is fast enough this would lead the code to become memory rather than CPU bound.
This means that the data needed is halved and it should run faster if memory bandwidth is the problem. This makes the assumption that the CPU isn't smart enough to skip the embedded colour information, a question I have no idea how to answer. In any case there is no difference in performance between the two versions which means that either the CPU is smart enough to skip data it knows the code won't read, or (far more likely to my mind) the ray/sphere intersection calculation is simply too slow and we are in fact CPU bound.
Other sizes
© 2002-2025 Kirit & Tai Sælensminde. All forum posts are copyright their respective authors.
Licensed under a Creative Commons License. Non-commercial use is fine so long as you provide attribution.