当前位置:网站首页>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
边栏推荐
- MYSQL---查询成绩为前5名的学生
- ubantu 查看cudnn和cuda的版本
- 面试必刷算法TOP101之回溯篇 TOP34
- Overview of Zhuhai purification laboratory construction details
- 在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
- Some features of ECMAScript
- 毕设-基于SSM高校学生社团管理系统
- Hundreds of lines of code to implement a JSON parser
- JVM_ 15_ Concepts related to garbage collection
- SPIR-V初窺
猜你喜欢

Installation and use of esxi

MATLB|实时机会约束决策及其在电力系统中的应用
![[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction](/img/b4/3d46a33fa780e5fb32bbfe5ab26a7f.jpg)
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction

有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀

Exciting, 2022 open atom global open source summit registration is hot

About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)

MySQL learning notes 2

cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】

Daily practice - February 13, 2022

ThreeDPoseTracker项目解析
随机推荐
Programmer growth Chapter 9: precautions in real projects
Cf:h. maximum and [bit operation practice + K operations + maximum and]
Finding the nearest common ancestor of binary tree by recursion
SPIR-V初窥
Live video source code, realize local storage of search history
Tcpdump: monitor network traffic
A preliminary study of geojson
JVM_ 15_ Concepts related to garbage collection
servlet(1)
cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
DOM introduction
Cannot resolve symbol error
How to extract MP3 audio from MP4 video files?
95后CV工程师晒出工资单,狠补了这个,真香...
Condition and AQS principle
Recommended areas - ways to explore users' future interests
C language programming (Chapter 6 functions)
有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀
ADS-NPU芯片架构设计的五大挑战
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction