Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
JaggerWolf's avatar
JaggerWolf
Expert Protege
11 years ago

Things moving in distance???

So I was playing around making a level in unity last night for the first time with the Rift - I noticed trees in the distance "Moving" along with my head movements?? Has anyone else noticed this? Is there a way to stop it from happening - I would lean forward....then would lean forward....I turn.....they turn, but only the ones off in the distance.

Thanks for the help - I am just starting to play with this.

6 Replies

Replies have been turned off for this discussion
  • weasel47's avatar
    weasel47
    Heroic Explorer
    This is a result of Unity's tree billboarding system. All distant trees use the same billboard, which gets re-rendered to match the camera angle. It doesn't look the best with the wide viewing angle of the Rift. You can increase the distance at which billboards are used to make the effect less noticeable, but that's a performance trade-off.
  • Thanks, Just wanted to make sure it wasn't some setting I was missing.
  • Yeah, I've seen this before. Not sure if there is a simple fix or not.
  • Instead of rotating every billboarded object to face the camera view direction, each individual billboard should calculate a facing vector that starts from the center of the camera and goes to the center of the object being billboarded. If this calculation were to be done on the CPU, it could get expensive, but in a shader, it'd be a trivial fix.

    That said, I'm fairly ignorant about how and where this is implemented in Unity 3D, so I couldn't really comment on where the fix would go in the code (especially tricky if this is in Unity's C++ code and not exposed to C# or the shader code).
  • It looks like the code that does this is in the file "Program Files (x86)\Unity x.x.x.x\Editor\Data\CGIncludes\SpeedTreeBillboardCommon.cginc"

    Specifically, this block:

    #ifdef BILLBOARD_FACE_CAMERA_POS
    float3 eyeVec = normalize(_WorldSpaceCameraPos - worldPos);
    float3 billboardTangent = normalize(float3(-eyeVec.z, 0, eyeVec.x)); // cross(eyeVec, {0,1,0})
    float3 billboardNormal = float3(billboardTangent.z, 0, -billboardTangent.x); // cross({0,1,0},billboardTangent)
    float3 angle = atan2(billboardNormal.z, billboardNormal.x); // signed angle between billboardNormal to {0,0,1}
    angle += angle < 0 ? 2 * UNITY_PI : 0;
    #else
    float3 billboardTangent = _BillboardTangent;
    float3 billboardNormal = _BillboardNormal;
    float angle = _CameraXZAngle;
    #endif


    I'm not sure how you get Unity to pick-up changes to it, nor what precisely the change should be, but would love to see this fixed.
  • We're working with Unity on better billboard behaviors for VR. It looks like changes are needed in the speedtree shaders as well as terrain detail objects. For now, I would disable billboarding on all grass and trees in the terrain settings and use mesh detail objects wherever you can.