当前位置:网站首页>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
边栏推荐
- matplotlib 笔记: contourf & contour
- Ionic4 drag the ion reorder group component to change the item order
- scratch绘制正方形 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月
- [机缘参悟-34]:光锥之内皆命运
- Gd32 RT thread RTC driver function
- Skill combing [email protected] voice module +stm32+nfc
- The performance of arm's new CPU has been improved by 22%, up to 12 cores can be combined, and the GPU is first equipped with hardware optical tracking. Netizen: the gap with apple is growing
- Anhui "requirements for design depth of Hefei fabricated building construction drawing review" was printed and distributed; Hebei Hengshui city adjusts the pre-sale license standard for prefabricated
- JS FAQs
- Voir le changement technologique à travers la Légion Huawei (5): Smart Park
猜你喜欢

电化学氧气传感器寿命、工作原理及应用介绍

在IPhone12的推理延迟仅为1.6 ms!Snap等详析Transformer结构延迟,并用NAS搜出移动设备的高效网络结构...

7 大轻量易用的工具,给开发者减压提效,助力企业敏捷上云 | Techo Day 精彩回顾...

I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly

文件共享服务器

MySQL export SQL script file

科普达人丨漫画图解什么是eRDMA?

深潜Kotlin协程(十六):Channel

Review of mathematical knowledge: curve integral of the second type

20万奖金池!【阿里安全 × ICDM 2022】大规模电商图上的风险商品检测赛火热报名中!...
随机推荐
Skill combing [email protected] control a dog's running on OLED
go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
小程序中读取腾讯文档的表格数据
Sarsa笔记
Dow Jones Industrial Average
The AOV function of R language was used for repeated measures ANOVA (one intra group factor and one inter group factor) and interaction Plot function and boxplot to visualize the interaction
【STL源码剖析】迭代器
Kernel linked list (general linked list) "list.h" simple version and individual comments
59 websites programmers need to know
再测云原生数据库性能:PolarDB依旧最强,TDSQL-C、GaussDB变化不大
LVGL 8.2 Simple Drop down list
Double-DQN笔记
微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条...
Remember the experience of an internship. It is necessary to go to the pit (I)
蚂蚁金服笔试题:需求文档有什么可以量化的【杭州多测师】【杭州多测师_王sir】...
Q-Learning笔记
【Rust日报】2021-01-23 几个新库发布
【Rust每周一库】num-bigint - 大整数
Machine learning interview preparation (I) KNN
断路器HystrixCircuitBreaker