You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Check if we're in VR, if we are set the camera's position to between
//the two eyes. This avoids bad stereo effects where the sprite is aiming
//at each eye at the same time. Otherwise just use the normal camera pos.
#if UNITY_SINGLE_PASS_STEREO
float4 cameraPos = float4((unity_StereoWorldSpaceCameraPos[0] + unity_StereoWorldSpaceCameraPos[1])*0.5, 1);
#else
float4 cameraPos = float4(_WorldSpaceCameraPos,1);
#endif
float4 center = mul(unity_ObjectToWorld, float4(_rotPos.xyz, 1));
cameraPos.xyz -= center.xyz;
//cameraPos = mul(unity_WorldToObject, cameraPos);
float len = distance(float2(0,0) , cameraPos.xz);
//Length of the hypotenuse of the triangle formed by the camera's
//objectspace pos, the origin, and the projection of the camera on
//to the xz plane
float hyp = distance(float3(0, 0, 0), cameraPos.xyz);
// rotate the vertices along the X-axis to face the Camera
float cosa = len/hyp;
float sina = (-cameraPos.y)/hyp;
float4x4 R = float4x4(
1, 0, 0, 0,
0, cosa, -sina, 0,
0, sina, cosa, 0,
0, 0, 0, 1);
pos = mul(R, pos);
//Rotate the vertices around the y-axis
cosa = (cameraPos.z)/len;
sina = (cameraPos.x)/len;
R = float4x4(
cosa, 0, sina, 0,
0, 1, 0, 0,
-sina, 0, cosa, 0,
0, 0, 0, 1);
pos = mul(R, pos);
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: