Speaking of that, I just recently made a Box Intersection material function that should be in for 4.14. There is also a LineBoxIntersection function in common.usf that you can use, but I found that I did not like how it was clamping the time result to be 0-1 since I prefer to have a unit vector ray cast and return time in world space.
Interestingly, even though I based this off of the code function mentioned above, doing it as material nodes saved a few instructions somehow (yay compiler magic)
It may seem a bit excessive to use the distance between entry/exit to return the distance inside (rather than just t1 - t0), but I compared the two and the compiler makes them both the same anyways so its just dropping out the extra instructions.
@dpenney, that is pretty cool that you were able to write to the volume textures in code. For those curious how to do that without any code and using a 2d 'pseudo volume texture', all you need is the 4.13 preview build and the "draw material to render target" blueprint node. Then you need a material that samples the 3d space like a flipbook, like so:
You would then just hook up the result of that snippet as the Position to the noise node or some other 3d position sampling function.
0-1 UVs are used since the 'draw material to Render Target" node uses 0-1 UVs for the canvas material.
“Num Cells Per Side” is the number of frames on one side of the flipbook. Ideally that value will be the cuberoot of your texture dimension.
Then to read that texture as a 3d texture you simply do a “1d to 2d index” conversion using the local Z position as the index. You can also just use the Flipbook material function and use Z as the phase. Note that “1d to 2d index” is the exact opposite of the “2d to 1d index” used to encode. Math!