-
-
Save gaplegth/42b61d8320c3c7cdb607635827dd952a to your computer and use it in GitHub Desktop.
UNITY_MATRIX_IT_MV[] Vectors in Shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UNITY_MATRIX_IT_MV[0].xyz = ??? | |
UNITY_MATRIX_IT_MV[1].xyz = Camera Up | |
UNITY_MATRIX_IT_MV[2].xyz = Camera Forward | |
float3 forward = -normalize(UNITY_MATRIX_V._m20_m21_m22); | |
float3 up = normalize(UNITY_MATRIX_V._m10_m11_m12); | |
float3 right = normalize(UNITY_MATRIX_V._m00_m01_m02); | |
float3 cameraUp = unity_CameraInvProjection[1].xyz; | |
float3 camRight = cross(unity_CameraInvProjection[2].xyz, cameraUp); | |
float3 cameraForward = cross(cameraUp, camRight); | |
Camera right direction = UNITY_MATRIX_V[0].xyz = mul((float3x3)UNITY_MATRIX_V,float3(1,0,0)); | |
Camera up direction = UNITY_MATRIX_V[1].xyz = mul((float3x3)UNITY_MATRIX_V,float3(0,1,0)); | |
Camera forward direction = UNITY_MATRIX_V[2].xyz = mul((float3x3)UNITY_MATRIX_V,float3(0,0,1)); | |
Camera position = _WorldSpaceCameraPos = mul(UNITY_MATRIX_V,float4(0,0,0,1)).xyz; | |
//http://forum.unity3d.com/threads/get-main-camera-up-direction.189947/#post-1297952 | |
// camera right | |
float3 right = cross(cameraUp, cameraForward); | |
// ?? | |
float4 objWorldPos=float4(_Object2World._m03,_Object2World._m13,_Object2World._m23, 1); | |
// references | |
// http://makegamessa.com/discussion/3368/facing-billboards-shader-in-unity | |
// http://www.codinglabs.net/article_world_view_projection_matrix.aspx | |
// http://answers.unity3d.com/questions/557922/rotate-a-mesh-on-world-y-axis-using-a-cg-vertex-sh.html | |
// scaling http://forum.unity3d.com/threads/scaling-in-the-vertex-shader.197815/ | |
// billboarding http://forum.unity3d.com/threads/leaf-card-billboards-camera-facing-matrix.186667/#post-1278929 | |
// http://forum.unity3d.com/threads/stream-out-for-geometry-shader.179377/ | |
// https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html | |
// https://forum.unity.com/threads/standard-surface-shader-billboard.513060/#post-3359378 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment