Re:Ray Tracing in pure CMake
by xyzzy_plugh on Saturday January 09, 2021 @08:40AM
(#25700236)
I refuse to even look at this. I've seen ray tracing in a PDF before but this is too far.
[ Parent
| on HN ]
Let me tell you one detail: since cmake doesn't have floats, they use fixed point arithmetic. LOOK AT IT. You know you want too!
function(sqrt x res)
div_by_2(${x} guess)
foreach(counter RANGE 4)
if(${guess} EQUAL 0)
set("${res}" 0 PARENT_SCOPE)
return()
endif()
div(${x} ${guess} tmp)
add(${tmp} ${guess} tmp)
div_by_2(${tmp} guess)
endforeach()
set("${res}" "${guess}" PARENT_SCOPE)
endfunction()IMO, this isn’t that impressive. Turns out that CMake has a scripting language that can be used to implement a ray tracer, and do that multi-threaded. The model being rendered also is hard-coded in the ray tracer.
I expected a monstrosity that had multiple targets for every pixel (“ray arriving at (x,y)”, “ray arriving at (x,y) after one bounce”, etc), with some magic to merge all the outputs of the last bounce into an image, say by generating a huge html table, with each cell having a different background color.
> The model being rendered also is hard-coded in the ray tracer.
This is true - but there's no reason why it couldn't be modified to read in a scene description. It's more a proof of concept than anything else.