I use below code work on mobile protrait, but if set to landscape-left, it can’t set right texture on 3d model. i try change P(projection) degree, but also have problem
Code:
// get MVP matrix
Matrix4x4 P = GL.GetGPUProjectionMatrix(Camera.main.projectionMatrix, false);
Matrix4x4 V = Camera.main.worldToCameraMatrix;
// use plane to get texcoords for target
Matrix4x4 M = mPlane.GetComponent<MeshRenderer>().localToWorldMatrix;
Matrix4x4 MVP = P * V * M;
ShadeLab:
// calculate new uv in camera image
float4 uvTmp;
uvTmp = mul(_MATRIX_MVP, float4(IN.uv_MainTex.x-0.5f,IN.uv_MainTex.y-0.5f,0,1));
uvTmp.x = uvTmp.x/uvTmp.w;
uvTmp.y = uvTmp.y/uvTmp.w;
uvTmp.z = uvTmp.z/uvTmp.w;
// some swap for different coordinate system
uvTmp.x = (uvTmp.x + 1)/2.0f;
uvTmp.y = (uvTmp.y + 1)/2.0f;
IN.uv_MainTex.x = ((1-uvTmp.y)-0.5f)*_xScale+0.5f;
IN.uv_MainTex.y = ((1-uvTmp.x)-0.5f)*_yScale+0.5f;
i have two question:
1.whether we change the P(projection) can adapter the lanscape-left
2.if the first can’t solve, how can i change the shader
(Don’t let this issuse dead. balabala…)