- Home /

**Question**by daviddessens · Apr 30, 2020 at 06:36 PM · mathgeometryprojectionprojection-matrixtransformation

# Inverse projection vertex shader

Hello , i'm working on some piece of code to create some volumetric 3dtexture mapped to the frustum of a camera. To create that volumetric texture i multiply some position vector with the inverse projection matrix. So my frustum and geometry inside become a normalized cube. This work so far if the model is inside frustum , but if vertices are far outisdes the frustum and cross the "eye view plane" my model got distorted. here is my code to transform position.

float4 Local = mul(mul(Projection,View),float4(WorldPos,1.0));

Local.xyz /=Local.w;

I believe the Local.w become 0 / negative or infinite at the point where vertices cross the eye view plane and then the model is not correct anymore. i tried a few things by checking if Local.w is equal 0 or smaller than 0 ... but nothing really worked for me atm. I would like to find a solution to keep the mesh inside my normalized frustum always correct. How to deal with this vertices crossing the eye view plane ? Here is a litle drawing of my problem , after applying inverse projection transform to my vector A and C are always correct , but i can't find a way to preserve B position after it cross the eye plane. I'm working with shader/compute shader .

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.