Forum Discussion
MikeFesta
12 years agoExplorer
Scale the scene or the camera?
I'm working on my game for the VR Jam (Domino Dash) and trying to figure out the best way to get the camera to scale.
My scene is set up for the default camera scale to work as an overhead camera with a view of the game board for placing dominos. After placement, I want the player to be able to switch to an action camera, putting them on the game board with giant dominos.
With the default camera scaling, the near clipping plane is too large and the eye spacing prevents a sense of scale. My temporary solution has been to scale all of my models by 10x, but it seems like there should be a better way. Anyone have any ideas?
My scene is set up for the default camera scale to work as an overhead camera with a view of the game board for placing dominos. After placement, I want the player to be able to switch to an action camera, putting them on the game board with giant dominos.
With the default camera scaling, the near clipping plane is too large and the eye spacing prevents a sense of scale. My temporary solution has been to scale all of my models by 10x, but it seems like there should be a better way. Anyone have any ideas?
12 Replies
Replies have been turned off for this discussion
- drashHeroic ExplorerNot claiming to be an expert, but here's what I've observed.
When there is close-up detail, I've had to scale up that nearby geometry just like you did to avoid clipping. But, if you really wanted to leave all the scale alone, you could just have a "near camera" whose near clip plane is very small and the far clipping plane is also pretty small (just large enough to get all the nearby geometry that's distinct from everything else beyond it, like a cockpit vs everything you see outside the window). There seems to be a minimum value for the near clip plane so that might not always work and you'll have to scale up your geometry after all. And, the smaller you make your near clip plane, the more you'll run into z-fighting and flickering shadow issues if your far clip plane isn't also made much smaller -- so it may be a lot more graphically stable to simply scale things up as you did.
It really just depends on the situation!
And, if you happen to also rescale the OVRCameraController itself, don't forget to rescale the IPD too. - sh0v0rProtegeAs Drash mentioned, just adjust your Clipping planes to suite, you could alter these depending on the mode (Overview/ Action)
Aside from the clipping issues the simplest thing is to dynamically alter the IPD.
Make it smaller to increase scale, make it larger to decrease scale.
Adjusting the IPD will not affect image quality, it will simply change the perception of scale. - cyberealityGrand ChampionI would be careful with scaling to make sure the IPD of the camera is correct. Otherwise you could create an uncomfortable experience for users. It would be best if you could leave the OVRCameras alone and scale your scene to the proper units. You should also be able to alter the near/far clipping planes if necessary. You will need to make a quick change to OVRCameraController.cs around line 106.
// Set the near and far clip plane for both cameras
[SerializeField]
private float nearClipPlane = 0.15f;
public float NearClipPlane
{
get{return nearClipPlane;}
set{nearClipPlane = value; UpdateCamerasDirtyFlag = true;}
}
[SerializeField]
private float farClipPlane = 1000.0f;
public float FarClipPlane
{
get{return farClipPlane;}
set{farClipPlane = value; UpdateCamerasDirtyFlag = true;}
}
What I have added is the "[SerializeField]" above the private declarations. This will allow the adjustment of the near/far plane to take effect (otherwise it goes to default when you press play).
Hope that helps. - MikeFestaExplorerThanks guys. I'll try some of the suggestions tomorrow. Today I discovered a problem with dynamically scaling my scene, the unity terrain can't be scaled for some reason :? . I'll probably scale everything up to the "action cam" size and then scaling up for the "overview cam" by adjusting the IPD.
I tried changing the camera controller class, but I'll have to check that I have the latest SDK, because those variables were on line 87/88 for me and were already public.
OVRCameraController.cs, lines 87-88
public float NearClipPlane = 0.15f;
public float FarClipPlane = 1000.0f - DarkJamesHonored GuestHi I tried using cyberreality's code, and the Near clip plane seems to stay at the level I set it.
However if I run my game with Maximize on Play enabled, the Inspector tells me all the near clip plane variables are correct, but if I move my virtual hand close to my face it clips as though I hadn't changed the variables from 0.15f!
If I "minimize" then re-maximize it seems to fix it... Any ideas whether that's an issue with the OVR stuff or is that an issue with Unity (or possibly my PC)? Thanks for the help!
EDIT: Also I get the clipping still when I build (both windowed and fullscreen) - boone188Honored Guest
"DarkJames" wrote:
Hi I tried using cyberreality's code, and the Near clip plane seems to stay at the level I set it.
However if I run my game with Maximize on Play enabled, the Inspector tells me all the near clip plane variables are correct, but if I move my virtual hand close to my face it clips as though I hadn't changed the variables from 0.15f!
If I "minimize" then re-maximize it seems to fix it... Any ideas whether that's an issue with the OVR stuff or is that an issue with Unity (or possibly my PC)? Thanks for the help!
EDIT: Also I get the clipping still when I build (both windowed and fullscreen)
Are you changing the NearClipPlane using the editor, or through code? - DarkJamesHonored GuestI'm doing it through the editor at the moment, but I'd also tried doing it through code before.
- boone188Honored Guest
"DarkJames" wrote:
I'm doing it through the editor at the moment, but I'd also tried doing it through code before.
I verified that this is an issue. I'm working on a fix right now. - boone188Honored GuestTo fix this issue, you will need to modify the ConfigureCamera() method of the OVRCameraController to be:
bool ConfigureCamera(ref Camera camera, float distOffset, float perspOffset, float eyePositionOffset)
{
Vector3 PerspOffset = Vector3.zero;
Vector3 EyePosition = EyeCenterPosition;
// Vertical FOV
camera.fieldOfView = VerticalFOV;
// Aspect ratio
camera.aspect = AspectRatio;
// Centre of lens correction
camera.GetComponent<OVRLensCorrection>()._Center.x = distOffset;
ConfigureCameraLensCorrection(ref camera);
// Clip Planes
camera.nearClipPlane = NearClipPlane;
camera.farClipPlane = FarClipPlane;
// Perspective offset for image
PerspOffset.x = perspOffset;
camera.GetComponent<OVRCamera>().SetPerspectiveOffset(ref PerspOffset);
// Set camera variables that pertain to the neck and eye position
// NOTE: We will want to add a scale vlue here in the event that the player
// grows or shrinks in the world. This keeps head modelling behaviour
// accurate
camera.GetComponent<OVRCamera>().NeckPosition = NeckPosition;
EyePosition.x = eyePositionOffset;
camera.GetComponent<OVRCamera>().EyePosition = EyePosition;
// Background color
camera.backgroundColor = BackgroundColor;
return true;
}
The difference here is that the clip planes are set before the SetPerspectiveOffset() call. - owenwpExpert ProtegeScaling your scene is usually not really feasible once you have physics involved. Even if you special case everything so that the units stay consistent and none of your constraints break, most physics engines are tuned to keep the numeric precision highest for smallish objects at a 1 unit = 1 meter scale. So significant changes will affect the accuracy of your simulation, sometimes by a lot.
What I do is apply the world scale of the camera object to the IPD and the neck offset. This way shrinking the player by half also moves the eyes closer together by half. Since stereo disparity is the only way we can measure the size of an object without either having a reference or moving our heads, this will create the effect you want.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 8 months ago
- 10 months ago
- 2 years ago