I implemented CSM, and relied on the linear projection of the orthographic matrix. I am trying to implement cube pointlights now (using a 4:2 2D texture) and I have realized perspective projection uses a non-linear depth.

Should I use a fragment shader to tweak the depth, or should I tweak the shadow z coordinate when objects are rendered? What is the equation to convert a linear depth from 0.0 to 1.0 into the depth perspective projection uses?

What is the relation with linear depth and CSM?
Yes, orthographics projection gives linear depth.
It’s just a matter at looking at how a vertex gets transformed into window space.

Not sure what you are calculating. It looks like you want to transform a vertex to clip space.

CSM uses orthographic projection, which is why I did not have a problem with this until point lights.

The far light range is 10.

The near light range is 0.1.

The fragment distance is 7.5.

The shadowmap I rendered uses perspective projection, because it is a point light.

I want to take the values above and calculate a non-linear depth value that can be used with shadow2D() in this depth map. I do not want to use a matrix and shadow2DProj() because there are too many places it could potentially go wrong.

I have the shadowmap x and y coords calculated correctly. I can draw the shadowmap texture on the scene and it lines up with geometry. I just need the shadow z coord.