当前位置:网站首页>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
边栏推荐
- Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
- Five challenges of ads-npu chip architecture design
- JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
- ubantu 查看cudnn和cuda的版本
- 2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
- ORA-00030
- JVM_ 15_ Concepts related to garbage collection
- Questions about database: (5) query the barcode, location and reader number of each book in the inventory table
- Recommended areas - ways to explore users' future interests
- Threedposetracker project resolution
猜你喜欢
BiShe - College Student Association Management System Based on SSM
Yii console method call, Yii console scheduled task
现货白银的一般操作方法
Daily practice - February 13, 2022
servlet(1)
关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
Idea sets the default line break for global newly created files
Ubantu check cudnn and CUDA versions
Intensive learning weekly, issue 52: depth cuprl, distspectrl & double deep q-network
3D模型格式汇总
随机推荐
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
2020.2.13
2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
How to extract MP3 audio from MP4 video files?
MySQL learning notes 2
Hcip---ipv6 experiment
Five challenges of ads-npu chip architecture design
BiShe - College Student Association Management System Based on SSM
Mathematical modeling learning from scratch (2): Tools
What is the most suitable book for programmers to engage in open source?
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
Redis' cache penetration, cache breakdown, cache avalanche
Idea sets the default line break for global newly created files
关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
激动人心,2022开放原子全球开源峰会报名火热开启
Cve-2017-11882 reappearance
[Arduino syntax - structure]
Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
程序员成长第九篇:真实项目中的注意事项