Your thoughts on and comments to Volume Rendering in Unreal Engine 4.

RE:

First off, I wanted to say that I am using the 3D texture that you posted for testing and learning as I know that it is right when it looks like your post. I hope you dont mind. Further, I am unable to understand one of your snippets. I will explain below.

For everyone:

I have been trying to understand and create a prototype following the examples and posts here in this thread and some of the resources I have found online.
What I got so far is this:

9fcf8f48e7.jpg

Using 10 of these with manually input constants ranging from 0.1 to 1.0 gives me this:

This is just a texture applied to a cube so you can not go inside it. It is also orthogonal right now with no concept of a camera so all faces are the same. Once I fix that I might also fix the going inside problem simply by making it two sided.

Anyways, I have 2 major problems (for now).

First, how can I loop through all pixels in a shader? As far as I understand it, in volumetric rendering you calculate a ray for every pixel and you blend the interpolated value of each point between the volume bounds. I can send in the camera position relative to the box and the view direction using parameter sets. However, I have no idea how I can loop through all x*y pixels of the camera to calculate the ray direction which, in turn, can be used to calculate the entry and exit points of the volume for that ray. I might be misunderstanding something though.

Second, I am unable to understand the logic of the snippet below (and how to use it because of that):

I calculated one example ray as follows:

I get a lot of infinite values. The invert ray dir does not make sense. Should it not be a multiply with -1 as B? However, then both t0 and t1 become 0.

Is this because I chose a specific case? The Box Min and Box Max are two vectors defining the volume bounds, right?

By now I am just rambling so I will end it here, but my confusion is too **** high. :'^)