How to access inverse view matrix in a shader?
Asked Answered
S

2

0

Hi, I’m writing a shader and would like to write my own billboarding, for this I need the inverse view matrix, I’m not sure if unity will let me have this information however.

Is there anyone with shader experience who can give me a hand? Thanks

Sall answered 8/7, 2023 at 7:45 Comment(0)
S
0

I did a research and I guess that Unity3d does not give you the inverse view matrix, but it gives you the UNITY_MATRIX_V that you can access in your shader, just transpose the upper 3x3 matrix and negate the translation vector to get the inverse.

Slesvig answered 8/7, 2023 at 7:45 Comment(3)

If you are trying to transform vertices in modelview/world matrix into local space of the object I guess you can use _World2Object.

Slesvig

No problem in doing it, cg programs have access to a function called transpose that you can use.

Slesvig

Awesome I'll give it a go :)

Sall
M
0

If you come here in 2023 like I did, there is now UNITY_MATRIX_I_V that you can use :wink:

Millennial answered 17/4, 2024 at 14:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.