Shader Documentation on GLState

I’m trying to figure out the following states in Unity.

worldI - matWorldInverse
worldIT - matWorldInverseTranspose
viewInv - matViewInverse
world - matWorld

I have the Unity docs:

The forum docs:
http://forum.unity3d.com/viewtopic.php?t=7586

And the UnityCG.cginc itself.

I’m pretty much guessing here. It would be nice to have a simple translation matrix from those who already know the mapping.

This has a little documentation, but it doesn’t exactly map to what I’m asking for.

http://unity3d.com/support/documentation/Components/SL-BuiltinStateInPrograms.html

RenderMonkey has a list of predefined states and I’m wondering how they map to the Unity engine.

A table would be perfect for this.

Getting shaders to look right is hard enough without guessing the mappings.

See the attached image.

109394--4188--$rendermanmatrices_640.jpg

These pages: Builtin state and Builtin values list the available variables that have their values filled automatically.

So:

  • worldI probably means “inverse of the world matrix”. That would be world-to-local matrix “_World2Object”.
  • worldIT - there’s no predefined variable for that. There is inverse transpose of world*view matrix, “glstate.matrix.invtrans.modelview[0]”.
  • viewInv seems like that would be inverse of the view matrix. So that would be camera-to-world matrix. There’s no built-in property for that, you’ll have to manually set it from some script.
  • world - probably “_Object2World”.

I didn’t actually need to use viewI because the shader was trying to get the camera eye into object space and there was already a variable for that. “_ObjectSpaceCameraPos”