当前位置:网站首页>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
边栏推荐
- BiShe - College Student Association Management System Based on SSM
- RAID disk redundancy queue
- Obstacle detection
- JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
- [Arduino syntax - structure]
- Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
- Use of crawler manual 02 requests
- 基於DVWA的文件上傳漏洞測試
- 黄金价格走势k线图如何看?
- DD's command
猜你喜欢

测试/开发程序员的成长路线,全局思考问题的问题......

2020.2.13

黄金价格走势k线图如何看?

037 PHP login, registration, message, personal Center Design

基於DVWA的文件上傳漏洞測試

ORA-00030

Threedposetracker project resolution

基于DVWA的文件上传漏洞测试

Unity | two ways to realize facial drive

About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
随机推荐
ADS-NPU芯片架构设计的五大挑战
ubantu 查看cudnn和cuda的版本
普通人下场全球贸易,新一轮结构性机会浮出水面
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
Kotlin core programming - algebraic data types and pattern matching (3)
BiShe - College Student Association Management System Based on SSM
Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem
Idea sets the default line break for global newly created files
Hcip---ipv6 experiment
Questions about database: (5) query the barcode, location and reader number of each book in the inventory table
Mathematical modeling learning from scratch (2): Tools
Nmap: network detection tool and security / port scanner
Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
激动人心,2022开放原子全球开源峰会报名火热开启
MYSQL---查询成绩为前5名的学生
直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
面试必刷算法TOP101之回溯篇 TOP34
Cve-2017-11882 reappearance
Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
Leetcode 剑指 Offer 59 - II. 队列的最大值