当前位置:网站首页>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
边栏推荐
猜你喜欢
DOM introduction
Dede collection plug-in free collection release push plug-in
SSH login is stuck and disconnected
Recommended areas - ways to explore users' future interests
MCU realizes OTA online upgrade process through UART
After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
Idea sets the default line break for global newly created files
Recoverable fuse characteristic test
How to extract MP3 audio from MP4 video files?
随机推荐
logstash清除sincedb_path上传记录,重传日志数据
ubantu 查看cudnn和cuda的版本
General operation method of spot Silver
Fibonacci number
Unity | 实现面部驱动的两种方式
Yii console method call, Yii console scheduled task
A preliminary study of geojson
黄金价格走势k线图如何看?
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction
Use of crawler manual 02 requests
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
RAID disk redundancy queue
Recommended areas - ways to explore users' future interests
Cf:h. maximum and [bit operation practice + K operations + maximum and]
Logstash clear sincedb_ Path upload records and retransmit log data
What is the most suitable book for programmers to engage in open source?
IP storage and query in MySQL
Recursive method to realize the insertion operation in binary search tree
Is chaozhaojin safe? Will it lose its principal
False breakthroughs in the trend of London Silver