I’m trying to map the camera frustum into a 3D texture so i can access the world-space position of each thread in the compute shader.
I thought this should work when looking at the 3D texture as if it is in clip-space, then transforming it to world-space with the inversed projection- and worldTransform-matrices.

It works with the current near an far clip values, however when adjusting these the thing breaks.

Hey @Bart_Kipping, you were quite close! Few things that was causing weird issues:

you were writing out the maths for the matrix mults as color *= matrix but this will produce incorrect results because that expands to color = color * matrix, and the thing with matrix maths is the matrix ALWAYS goes to the left of the vector. This explains why going from NDC to projection space was producing weird results.

next was the viewspace multiply, first was the same issue as above, then the other thing was the 4th component of color (color.a) had some other values left over from the perspective matrix multiply.
when a vec4 represents a position, like it does in your file the 4th member must always be equal to 1. (for normals, it’s always 0) - so this was an easy fix, I just set color.a = 1 before doing the second matrix multiply.

Aha! Typical. I was aware of point two, forgot to implement it in this version. The thing about left - right is very helpful information and makes total sense when thinking of the stuff i read about matrix multiplication.

Thanks a lot for helping me out @lucasm ! Crunched my brain on it.