当前位置:网站首页>Unity VR resource flash surface in scene
Unity VR resource flash surface in scene
2022-07-06 01:17:00 【The way of growth】
In the use of VR When , Seeing the scene with a helmet will cause the problem of flashing , One of the reasons for the flash is Camera Of Clipping Planes The value of is too small , And we will Clipping Planes After increasing the value of , The handle will be invisible again , So we create two cameras , A camera is dedicated to rendering handles . Another rendering
Code : First create two cameras
private static void InitVRCamera()
{
var eye = CreateCameraEye();
eye.transform.SetParent(vrCmaeraPrent);
var gamePadEye = CreateCameraGamepadEye();
gamePadEye.transform.SetParent(vrCmaeraPrent);
}
When rendering, pass layer To distinguish rendering
// Lord VR The camera
private static GameObject CreateCameraEye()
{
var createCameraEye = new GameObject("Camera (eye)")
{
tag = "MainCamera"
};
var camera = createCameraEye.AddComponent<Camera>();
camera.clearFlags = CameraClearFlags.Skybox;
camera.backgroundColor = new Color32(49, 77, 121, 5);
camera.useOcclusionCulling = false;
camera.orthographic = false;
camera.nearClipPlane = 0.5f;
camera.farClipPlane = 100000000;
camera.depth = -1;
camera.useOcclusionCulling = true;
camera.allowHDR = false;
camera.stereoTargetEye = StereoTargetEyeMask.Both;
camera.cullingMask = Layer.SceneVRCullingMask;
createCameraEye.AddComponent<FlareLayer>();
createCameraEye.AddComponent<SteamVR_Camera>();
GameObject earsGameObject = CreateCameraEars();
earsGameObject.transform.SetParent(createCameraEye.transform);
var collider = createCameraEye.AddComponent<CapsuleCollider>();
collider.radius = .5f;
collider.height = 2;
var rigidbody = createCameraEye.AddComponent<Rigidbody>();
rigidbody.useGravity = false;
rigidbody.isKinematic = true;
return createCameraEye;
}
// Render handle camera
private static GameObject CreateCameraGamepadEye()
{
var gamepadGameObject = new GameObject("CameraGamePad (eye)");
var gamepadCamera = gamepadGameObject.AddComponent<Camera>();
gamepadCamera.nearClipPlane = 0.01f;
gamepadCamera.farClipPlane = 5f;
gamepadCamera.cullingMask = Layer.VRGamepadCullingMask; // Render handle only layer
gamepadCamera.depth = 5;
gamepadCamera.clearFlags = CameraClearFlags.Depth;
return gamepadGameObject;
}
This can effectively solve part of the flash surface problem
边栏推荐
猜你喜欢
vSphere实现虚拟机迁移
IP storage and query in MySQL
Dedecms plug-in free SEO plug-in summary
Mathematical modeling learning from scratch (2): Tools
The growth path of test / development programmers, the problem of thinking about the overall situation
servlet(1)
Exciting, 2022 open atom global open source summit registration is hot
KDD 2022 | EEG AI helps diagnose epilepsy
Docker compose配置MySQL并实现远程连接
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
随机推荐
Zhuhai laboratory ventilation system construction and installation instructions
CocoaPods could not find compatible versions for pod 'Firebase/CoreOnly'
Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
KDD 2022 | EEG AI helps diagnose epilepsy
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
The growth path of test / development programmers, the problem of thinking about the overall situation
Cglib dynamic agent -- example / principle
Loop structure of program (for loop)
After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?
Intensive learning weekly, issue 52: depth cuprl, distspectrl & double deep q-network
Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
Four commonly used techniques for anti aliasing
Zhuhai's waste gas treatment scheme was exposed
Logstash clear sincedb_ Path upload records and retransmit log data
Live video source code, realize local storage of search history
Recursive method converts ordered array into binary search tree
Xunrui CMS plug-in automatically collects fake original free plug-ins
Hundreds of lines of code to implement a JSON parser
Pbootcms plug-in automatically collects fake original free plug-ins
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition