How can I tilt the near plane of camera?

I tried CalculateObliqueMatrix but didn’t got the correct result and also in the docs it says that this is used to skew the frustum and not the near plane…
I want the frustum to be the same, just tilt the near plane…

My hunch is that it’s not possible without also tilting the far plane by the same amount. In a 3x3 linear transformation you have 3 basis vectors. How would you orient those 3 basis vectors to get that?

You could do your own clipping after the fact. If you leave the camera near plane to your minimum value, you could add this code to your fragment shader to create the effect shown in the picture:

float depth = input.vertex.z;
    float clipY = input.vertex.y; // varies 0-1

    // define your min and max near planes
    float minNearPlane = 1.0f;
    float maxNearPlane = 1.5f;

    // determine your cutoff based on y level
    cutoff = lerp(minNearPlane, maxNearPlane, clipY);

    // clips if depth is less than cuttoff
    clip(depth - cutoff);

This may give you issues if you want to know if the object is being clipped on the scripting side, but it should render as expected

Good idea @JohnE4D . Haven’t thought of that.

You can actually achieve the same much easier with SV_ClipDistance and SV_CullDistance in the vertex shader.

This will give you a gap at the bottom of the screen, though. You can see that geometry is cut off.

If you don’t want that, you could probably also modify the vertex z coordinate in clip space in the vertex shader.