当前位置:网站首页>The precision problem of depth texture in unity shader - stepping pit - BRP pipeline (there is no solution, it is recommended to replace URP)
The precision problem of depth texture in unity shader - stepping pit - BRP pipeline (there is no solution, it is recommended to replace URP)
2022-06-30 10:53:00 【Jave. Lin】
List of articles
Environmental Science
Unity: 2018.2.11f1
Pipeline: BRP
Platform : Android
Graphics API : OpenGL ES 3/+
Color Space : Linear
problem
Some mobile devices GPU The accuracy is relatively low , Abnormal display that will lead to poor accuracy performance
( Originally wanted to use RenderDoc, Snapdragon Profiler To check the real machine FB The format of , But these two tools are becoming less and less awesome , There are fewer and fewer real machine frame grabbing tools available in the market , Basically, what can be used now is only RenderDoc Catch PC,Intel GPA Catch PC,Snapdragon Profiler Only some applications of Qualcomm models can be grasped : Must be turned on debuggable, read/write permission You have to open it to catch it , however Snapdragon Profiler very many BUG, often collapse 、 Flash back , or Unable to display Pixel History data , Now these big factories , Or are mainstream tools so awesome ?-_-!!!)
such as :
- Soft particles and opaque Content fade Excessive abnormality
- Water body and opaque Content depth fade Excessive abnormality
( After some testing , It can't be solved in the end , Fortunately, new projects in the future will use URP)
test Shader Part of the code
// depth gradient control foam
float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
float fragZ = i.projPos.z;
// return sceneZ;
// return fragZ;
float detalZ = sceneZ-fragZ;
return saturate(detalZ); // Here again :oppo, vivo Of low-end mobile phones , There will be a serious problem of precision loss , Lead to ,PC On and On low-end devices The effect varies greatly
test C#
// jave.lin : 2022/06/29
// test The color of water depth is too abnormal
// Later, it was located as yes : Depth accuracy problem
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
public class Test_WaterReflectionError_Script : MonoBehaviour {
public Text graphicsAPI_Text;
// jave.lin : Before my : Unity - Picture quality settings https://blog.csdn.net/linjf520/article/details/123546253
// The print listed in the article
public static string DumpSystemInfoByManualyPrint()
{
var list = new List<string>(
new string[]{
"SystemInfo:\n",
"\tbatteryLevel:" + SystemInfo.batteryLevel,
"\tbatteryStatus:" + SystemInfo.batteryStatus,
"\toperatingSystem:" + SystemInfo.operatingSystem,
"\toperatingSystemFamily:" + SystemInfo.operatingSystemFamily,
"\tprocessorType:" + SystemInfo.processorType,
"\tprocessorFrequency:" + SystemInfo.processorFrequency,
"\tprocessorCount:" + SystemInfo.processorCount,
"\tsystemMemorySize:" + SystemInfo.systemMemorySize,
"\tdeviceUniqueIdentifier:" + SystemInfo.deviceUniqueIdentifier,
"\tdeviceName:" + SystemInfo.deviceName,
"\tdeviceModel:" + SystemInfo.deviceModel,
"\tsupportsAccelerometer:" + SystemInfo.supportsAccelerometer,
"\tsupportsGyroscope:" + SystemInfo.supportsGyroscope,
"\tsupportsLocationService:" + SystemInfo.supportsLocationService,
"\tsupportsVibration:" + SystemInfo.supportsVibration,
"\tsupportsAudio:" + SystemInfo.supportsAudio,
"\tdeviceType:" + SystemInfo.deviceType,
"\tgraphicsMemorySize:" + SystemInfo.graphicsMemorySize,
"\tgraphicsDeviceName:" + SystemInfo.graphicsDeviceName,
"\tgraphicsDeviceVendor:" + SystemInfo.graphicsDeviceVendor,
"\tgraphicsDeviceID:" + SystemInfo.graphicsDeviceID,
"\tgraphicsDeviceVendorID:" + SystemInfo.graphicsDeviceVendorID,
"\tgraphicsDeviceType:" + SystemInfo.graphicsDeviceType,
"\tgraphicsUVStartsAtTop:" + SystemInfo.graphicsUVStartsAtTop,
"\tgraphicsDeviceVersion:" + SystemInfo.graphicsDeviceVersion,
"\tgraphicsShaderLevel:" + SystemInfo.graphicsShaderLevel,
"\tgraphicsMultiThreaded:" + SystemInfo.graphicsMultiThreaded,
"\tsupportsShadows:" + SystemInfo.supportsShadows,
"\tsupportsRawShadowDepthSampling:" + SystemInfo.supportsRawShadowDepthSampling,
"\tsupportsMotionVectors:" + SystemInfo.supportsMotionVectors,
"\tsupports3DTextures:" + SystemInfo.supports3DTextures,
"\tsupports2DArrayTextures:" + SystemInfo.supports2DArrayTextures,
"\tsupports3DRenderTextures:" + SystemInfo.supports3DRenderTextures,
"\tsupportsCubemapArrayTextures:" + SystemInfo.supportsCubemapArrayTextures,
"\tcopyTextureSupport:" + SystemInfo.copyTextureSupport,
"\tsupportsComputeShaders:" + SystemInfo.supportsComputeShaders,
"\tsupportsInstancing:" + SystemInfo.supportsInstancing,
"\tsupportsHardwareQuadTopology:" + SystemInfo.supportsHardwareQuadTopology,
"\tsupports32bitsIndexBuffer:" + SystemInfo.supports32bitsIndexBuffer,
"\tsupportsSparseTextures:" + SystemInfo.supportsSparseTextures,
"\tsupportedRenderTargetCount:" + SystemInfo.supportedRenderTargetCount,
"\tsupportsMultisampledTextures:" + SystemInfo.supportsMultisampledTextures,
"\tsupportsMultisampleAutoResolve:" + SystemInfo.supportsMultisampleAutoResolve,
"\tsupportsTextureWrapMirrorOnce:" + SystemInfo.supportsTextureWrapMirrorOnce,
"\tusesReversedZBuffer:" + SystemInfo.usesReversedZBuffer,
"\tnpotSupport:" + SystemInfo.npotSupport,
"\tmaxTextureSize:" + SystemInfo.maxTextureSize,
"\tmaxCubemapSize:" + SystemInfo.maxCubemapSize,
"\tsupportsAsyncCompute:" + SystemInfo.supportsAsyncCompute,
"\tsupportsAsyncGPUReadback:" + SystemInfo.supportsAsyncGPUReadback,
"\tsupportsMipStreaming:" + SystemInfo.supportsMipStreaming,
});
return string.Join("\n", list.ToArray());
}
// jave.lin : Now let's debug , Only part of it is needed
public static string MyDump()
{
var list = new List<string>(
new string[]{
"SystemInfo:\n",
"\toperatingSystem:" + SystemInfo.operatingSystem,
"\toperatingSystemFamily:" + SystemInfo.operatingSystemFamily,
"\tdeviceName:" + SystemInfo.deviceName,
"\tdeviceType:" + SystemInfo.deviceType,
"\tgraphicsMemorySize:" + SystemInfo.graphicsMemorySize,
"\tgraphicsDeviceName:" + SystemInfo.graphicsDeviceName,
"\tgraphicsDeviceVendor:" + SystemInfo.graphicsDeviceVendor,
"\tgraphicsDeviceType:" + SystemInfo.graphicsDeviceType,
"\tgraphicsDeviceVersion:" + SystemInfo.graphicsDeviceVersion,
"\tgraphicsShaderLevel:" + SystemInfo.graphicsShaderLevel,
"\tsupportsComputeShaders:" + SystemInfo.supportsComputeShaders,
"\tsupportsInstancing:" + SystemInfo.supportsInstancing,
"\tusesReversedZBuffer:" + SystemInfo.usesReversedZBuffer,
});
return string.Join("\n", list.ToArray());
}
// Use this for initialization
void Start () {
graphicsAPI_Text.text = MyDump();
}
}
Performance in each device
Unity Editing

In the night God Simulator

millet 10

OPPO A5
You can see OPPO A5 It shows an exception 
BRP There is no relevant solution in
After all BRP It is not recommended in the future
So this problem , Recommended or used URP
I wanted to see it project setting Medium graphics, quality Whether there is relevant depth precision setting , After some searching and project configuration searching , No relevant content was found
- goolgle : how to improve precision in unity shaderlab
And then in In official documents Cameras and depth textures Find some precision related instructions

Found configuration :
- ProjectSetting->Player->OtherSetting->Rendering - There's no correlation
- ProjectSetting->Player->OtherSetting->Resolution and Presentation - There's no correlation
- ProjectSetting->Graphics Next try to put all Tier Settings All set to the highest , Not good either.
- Shader Add :
#pragma fragmentoption ARB_precision_hint_nicestNot good either. - Shader Revision in China
_CameraDepthTexturebyfloatThe texture sampler settings are also not good , such as :uniform sampler2D_float _CameraDepthTexture;
URP There are solutions in
The question is In the early URP There are also , For example, this post :Android depth texture precision issue. - The Lord is to :Unity 2019.3.6f1 URP 7.2.1, stay URP:7.4.1 Repair the
Is probably :application layer , Yes _CameraDepthTexture Texture object format settings ( Precision setting )
also shader Precision declaration in
stay BRP There is no corresponding controllability in , This is in URP Can be controlled , therefore URP Can solve this problem
in addition , The high version of the unity I also saw :shader precision mode Set up
Here is :2022.1.4f1 The screenshots 
Cause these accuracy problems , Generally, it is also related to Camera Of Near section , Far section The difference between , The greater the difference , Then the more likely it is to have this problem
And this project before I came , The scale of their models and other related productions are abnormal , such as :500 scale,x,y,z
then Camera Of near plane, far plane Can only be set very large , such as :near : 0.1, far : 10000, Then the value of precision must be greatly limited
References
- Android depth texture precision issue. - The Lord is to :Unity 2019.3.6f1 URP 7.2.1, stay URP:7.4.1 Repair the
边栏推荐
- Voir le changement technologique à travers la Légion Huawei (5): Smart Park
- LVGL 8.2 re-coloring
- Machine learning interview preparation (I) KNN
- Skill sorting [email protected]+ Alibaba cloud +nbiot+dht11+bh1750+ soil moisture sensor +oled
- Input a decimal data, convert to 8, using the sequence stack
- 在 sCrypt 中实现高效的椭圆曲线点加法和乘法
- 数据库什么时候需要使用索引【杭州多测师】【杭州多测师_王sir】
- Viewing technological changes through Huawei Corps (V): smart Park
- pytorch 笔记 torch.nn.BatchNorm1d
- 安徽《合肥市装配式建筑施工图审查设计深度要求》印发;河北衡水市调整装配式建筑预售许可标准
猜你喜欢

Pytorch Notebook. Nn. Batchnorm1d

腾讯云数据库工程师能力认证重磅推出,各界共话人才培养难题

Pytorch notes torch nn. BatchNorm1d

19:00 p.m. tonight, knowledge empowerment phase 2 live broadcast - control panel interface design of openharmony smart home project

China will force a unified charging interface. If Apple does not bow its head, iPhone will be kicked out of the Chinese market

微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条...

List introduction

Qt之实现动效导航栏

ArcGIS Pro scripting tool (5) - delete duplicates after sorting

Voir le changement technologique à travers la Légion Huawei (5): Smart Park
随机推荐
历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并
煥發青春的戴爾和蘋果夾擊,兩大老牌PC企業極速衰敗
软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题
Agile Development: super easy to use bucket estimation system
内存逃逸分析
pytorch 笔记:validation ,model.eval V.S torch.no_grad
ArcGIS PRO + PS vectorized land use planning map
20万奖金池!【阿里安全 × ICDM 2022】大规模电商图上的风险商品检测赛火热报名中!...
安徽《合肥市装配式建筑施工图审查设计深度要求》印发;河北衡水市调整装配式建筑预售许可标准
Skill combing [email protected] intelligent instrument teaching aids based on 51 series single chip microcomputer
科普达人丨漫画图解什么是eRDMA?
时间复杂度与空间复杂度
LVGL 8.2 Simple Image button
超长干货 | Kubernetes命名空间详解
Turn to cartoon learning notes
Skill sorting [email protected]+adxl345+ Motor vibration + serial port output
机器学习面试准备(一)KNN
LVGL 8.2 Image
Mysql database foundation: views and variables
Gd32 RT thread flash driver function