Custom Mesh FOV

Hi ,

Thanks very much for having a look - unfortunately that is not the issue (the weapon’s location and rotation is set exactly equal to the camera’s). I get the same behaviour with a direct copy paste of your original code.

The code shown in my screenshot is just part of me going through each line and checking if I find any obvious zeroes.

I get the following when using the exact code you pasted (except for a hardcoded WeaponFOV of 100).

Hi,

Sorry, it is very hard to tell from my end. As long as you understand the theory behind code, you have to go through the code line by line to find out the reason on you own. Good luck. :slight_smile:

Thanks in any case for having a look .

I’ve managed to (sort of) fix the problem on my side. I’ve reverted to the first solution and moved the CalcScene view from the GetRenderMatrix() to the TickComponent() function (moved from render to game thread) and I then store the required matrices on the component for when GetRenderMatrix() needs them. There does seem to be some delay using this method, as I assume the Render and Game threads don’t tick exactly at the same rate. In any case, code below:

Attaching code via file.

Phheeeeeeeeew, finally I’ve found the problem!

Ok, so I debugged through every value of every line of code of the original as well as the newest one, and the problem was simply this line in the newer version:

float MinZ = 3.0f;

This line defines the near clipping plane. I changed this to 5 and now everything is perfectly fine.

Again, , thanks a million for sharing your code. It is much appreciated!

I recently tried this code in 4.15, I wanted to do a quick test with mesh-specific FOV. In case somebody wants a more up-to-date version, here are some things I had to change:

MinZ should be your NearClippingDistance as staticvoidlol mentioned, but yours might not be 5, so make sure it’s correct.

The members used in FViewMatrices are now private, and there’s no real use to go through that class at all, so I replaced the final math in GetViewMatrices with:

FMatrix ProjMatrix = ProjectionData.ProjectionMatrix;
FMatrix InvProjectionMatrix = ProjMatrix.Inverse(); 
FMatrix InvViewMatrix = FTranslationMatrix(-viewMatrix.GetOrigin()) * viewMatrix.RemoveTranslation().GetTransposed();
invViewProjectionMatrix = InvProjectionMatrix * InvViewMatrix;

Hello everyone! I’m just wondering if anyone have this working in Unreal 5? It seems like something has been changed in projection matrices, we’ve got strange behaviour with rotation of camera around Y(pitch). In previous (4.27) version it worked fine.

I’m just trying to fix this issue in UE 5.2. Have you managed to discover what’s causing it yet?

Long story short, do not attempt this in UE5 as Epic made some changes that essentially prevent this from working. Heavy engine modifications would be required to get this sorted. Go for the shader solution instead.