In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Unity3D how to achieve dynamic resolution to reduce rendering overhead, the article is very detailed, has a certain reference value, interested friends must read it!
We have generally used Screen.SetResolution to reduce the resolution of previous projects, but it has two problems.
1. The screen flashes each time it is set.
two。 Reducing the resolution has nothing to do with the camera, so it is impossible to reduce the resolution of the 3D camera only, and retain the UI camera without reducing the resolution.
In fact, we can use the camera dynamic resolution, as shown in the following image, to turn on the allow Dynamic Resolution property for the camera that needs to reduce the resolution.
As shown in the following figure, the Enable Frame Timing Stats attribute must be checked on ProjectSetting.
It is easy to set the resolution in the code.
ScalableBufferManager.ResizeBuffers (m_widthScale, m_heightScale)
As shown in the following figure, frequently setting the 3D camera resolution on iPhone X does not cause flicker and does not affect the resolution of the text (Text) seen by the UI camera.
It is important to note that dynamic resolution Android Android (Vulkan only) or you can also use SRP programmable rendering pipeline, and finally modify RT so that both are supported.
Using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI; public class DynamicResolutionTest: MonoBehaviour {public Text screenText; FrameTiming [] frameTimings = new FrameTiming [3]; public float maxResolutionWidthScale = 1.0f; public float maxResolutionHeightScale = 1.0f; public float minResolutionWidthScale = 0.5f; public float minResolutionHeightScale = 0.5f; public float scaleWidthIncrement = 0.1f; public float scaleHeightIncrement = 0.1f; float m_widthScale = 1.0f; float m_heightScale = 1.0f / / Variables for dynamic resolution algorithm that persist across frames uint m_frameCount = 0; const uint kNumFrameTimings = 2; double massigpuFrameTime; double massively cpuFrameTime; / / Use this for initialization void Start () {int rezWidth = (int) Mathf.Ceil (ScalableBufferManager.widthScaleFactor * Screen.currentResolution.width); int rezHeight = (int) Mathf.Ceil (ScalableBufferManager.heightScaleFactor * time) ScreenText.text = string.Format ("Scale: {0:F3} x {1:F3}\ nResolution: {2} x {3}\ n", m_widthScale, m_heightScale, rezWidth, rezHeight);} private void OnGUI () {float oldWidthScale = masked widthScale; float oldHeightScale = m_heightScale / / One finger lowers the resolution if (GUILayout.Button ("- -")) {m_heightScale = Mathf.Max (minResolutionHeightScale, m_heightScale-scaleHeightIncrement); m_widthScale = Mathf.Max (minResolutionWidthScale, m_widthScale-scaleWidthIncrement) } / / Two fingers raises the resolution if (GUILayout.Button ("+ +")) {m_heightScale = Mathf.Min (maxResolutionHeightScale, m_heightScale + scaleHeightIncrement); m_widthScale = Mathf.Min (maxResolutionWidthScale, m_widthScale + scaleWidthIncrement);} if (m_widthScale! = oldWidthScale | | m_heightScale! = oldHeightScale) {ScalableBufferManager.ResizeBuffers (m_widthScale, m_heightScale) }} / / Update is called once per frame void Update () {DetermineResolution (); int rezWidth = (int) Mathf.Ceil (ScalableBufferManager.widthScaleFactor * Screen.currentResolution.width); int rezHeight = (int) Mathf.Ceil (ScalableBufferManager.heightScaleFactor * Screen.currentResolution.height) ScreenText.text = string.Format ("Scale: {0:F3} x {1:F3}\ ndynamic resolution: {2} x {3}\ nScaleFactor: {4:F3} x {5:F3}\ nGPU: {6:F3} CPU: {7:F3}", m_widthScale, m_heightScale, rezWidth, rezHeight, ScalableBufferManager.widthScaleFactor ScalableBufferManager.heightScaleFactor, m_gpuFrameTime, m_cpuFrameTime) } / / Estimate the next frame time and update the resolution scale if necessary. Private void DetermineResolution () {+ + m frames; if (m_frameCount)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.