Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

How are some games getting such "buttery" crosshairs?

ThisisdanzoThisisdanzo Posts: 37
Brain Burst
edited May 2015 in VR Jam 2015
I used Unity 5.0.0p2 / OVR Mobile SDK 0.5.1. Shaders are all Mobile/VertexLit (Only Directional Lights) with lightmaps, camera renders 30 batches/50ktris (with both cams on), and I am getting 50-58 fps. My crosshair jutters as the camera rotates, but I'm seeing many projects with no perceptible shaking in the UI.

HOW AND WHY? I can definitely do more optimization, but I'm just worried it's a Unity 5 issue.
Galaxy Grapple - GearVR, no gamepad


  • JaninaWoodsJaninaWoods Posts: 35
    I don't know how other devs did it, but I attached an invisible reference object to the camera, which rotates with it - then have the crosshair graphic follow its position and rotation via a Vector3.Lerp. This assures that the position update is always smooth and never jumps, because even if the reference object jumps, the graphic will always lerp behind. ^_^

    Probably not the best performance option, but it has worked for me so far.
    Check out my 2013 VRJam finalist game: http://shinyvr.com/
  • spinaljackspinaljack Posts: 347 Oculus Start Member
    The jumpyness is probably caused by the async time warp (which rotates the image based on head movement between frames)

    Even though you see the world as still head tracking the actual frame hasn't been updated and so your cross hair stays where it was in the image the last time it got updated

    The only fix for that is to maintain 60fps constantly
  • mbzdmvpmbzdmvp Posts: 65
    Hiro Protagonist
    Yes, lerping is the way to go!

    Here's my script if you're interested:
    public class UICrosshair : MonoBehaviour {
    	public static UICrosshair instance;
    	void Awake(){
    	public void UpdatePosition(RaycastHit hit){
    		Vector3 targetPosition= hit.point;
    		Vector3 targetPositionDirection = targetPosition - transform.position;
    		transform.position += targetPositionDirection * 10f*Time.deltaTime;
    		Vector3 targetForward=hit.transform.forward;
    		Vector3 targetForwardDirection=targetForward-transform.forward;
    		transform.forward += targetForwardDirection * 10f*Time.deltaTime;

    Assuming you are using a Raycast just send the hit variable.
    VR Jam 2015: Inside The Human Body
    Forum Post: viewtopic.php?f=77&t=23266
  • NilspferdNilspferd Posts: 51
    Although we removed the crosshair later from our game, we didn't have any issues with it. We just took the Example from the Oculus SDK and it worked like a charm. There is no Lerping in there as far as I know
  • ThisisdanzoThisisdanzo Posts: 37
    Brain Burst
    It seems that Lerping does indeed give the desired effect. Even at 60fps, the HUD was 1m from the Camera, which exaggerated the async judder when timewarp updated at a faster rate (though I thought it was locked at 60Hz?)
    Galaxy Grapple - GearVR, no gamepad
  • EMcNeillEMcNeill Posts: 158
    Maintaining 60fps is the most important thing, but even if you do that it will be a little choppy due to time warp, as explained above. Lerping can smooth it out, but it adds a bit of unnecessary lag as well.
Sign In or Register to comment.