Why does this RayMarcher doesn't work with 3D Textures?

Hi,
so I try to use the RayMarcher, which is shown in [here][1].

I use the basic code from the first sample (opacity only).
The only difference is, that I don’t use a 2D Flipbook, but a real Volume Texture which is available sind 4.20 (You can create it from a flipbook, but I also implemented a Factory which imports my raw 3D data, both methods show this bug). When using his flipbook approach, everything is fine. But when I use the Volume Texture I get weird artifacts.

Here is the custom Material Node Code which I use to compute the Emissive Color:

float accumdist = 0;
float3 localCamVec = normalize(mul(Parameters.CameraVector, Primitive.WorldToLocal));
float StepSize = 1 / MaxSteps;

for(int i = 0; i < MaxSteps; i++)
{
float3 satPos = saturate(CurPos);

float curSample = Tex.SampleLevel(TexSampler, satPos, 0).r;

accumdist += curSample * StepSize;
CurPos += -localCamVec * StepSize;
}

return accumdist;

CurPos is BoundingBoxBased_0-1_UVW.

The following artifact is visible:

You can see the stripes which are emitting from the ball.
Another one from the side:

I used Opaque instead of Additive blending so you can see it better. It also goes in the depth.

I have no idea what is wrong since it works with the flipbook. I think maybe it is a bug with Sampling of the new Volume Textures? This also occurs with different Volume Textures.

Most likely you are hitting volume limits and as your texture coordinates are saturated, when you are hitting a plane of the bounding box, your raymarch continues with 2 coordinates out of 3 incrementing, resulting in said artifacts.
Either pre-calculate exit point and adjust step number accordingly or check if you are still inside the volume at every step.

Thanks, your answer brought me on the right track. I thought this can’t be the problem because I also used his code where he precalculates the Step count. But the article didn’t show that the StepSize has to be precalculated too, otherwise a modified step count doesn’t do anything, because the ray marcher code will always fit the step size to a ray length of 1. The flipbook approach also showed artifacts with other volumes that are more box-like. Those start to repeat when the ray goes beneath the volume.