Mapgen4-3: unity shader 获得相机朝向
shader里面相机朝向
- 视图空间 到 世界空间 unity_CameraToWorld
- 前朝向
1
float3 forward = mul(unity_CameraToWorld, float4(0,0,1,1)).xyz;
- 右朝向
1
float3 forward = mul(unity_CameraToWorld, float4(1,0,0,1)).xyz;
- 上朝向
1
float3 forward = mul(unity_CameraToWorld, float4(0,1,0,1)).xyz;
- 前朝向
- 视图空间 到 本地空间 UNITY_MATRIX_IT_MV
- 前朝向
1
float3 forward = mul(UNITY_MATRIX_IT_MV, float4(0,0,1,1)).xyz;
- 右朝向
1
float3 forward = mul(UNITY_MATRIX_IT_MV, float4(1,0,0,1)).xyz;
- 上朝向
1
float3 forward = mul(UNITY_MATRIX_IT_MV, float4(0,1,0,1)).xyz;
- 前朝向