当前位置:网站首页>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 notes: contour & Contour
- 【Rust每周一库】num-bigint - 大整数
- ionic4 ion-reorder-group组件拖拽改变item顺序
- Foresniffer tutorial: extracting data
- 吴恩达2022机器学习专项课测评来了!
- 智能DNA分子纳米机器人模型来了
- Kernel linked list (general linked list) "list.h" simple version and individual comments
- Mysql database foundation: constraint and identification columns
- Pycharm项目使用pyinstalle打包过程中问题及解决方案
- Collectors.toMap应用
猜你喜欢
[email protected] voice module +stm32+nfc"/>Skill combing [email protected] voice module +stm32+nfc

Pytorch notes torch nn. BatchNorm1d

Auto SEG loss: automatic loss function design
![[STL source code analysis] container (to be supplemented)](/img/69/0c6e0e8ecb3ebc8c9b8503f5a8b4e5.jpg)
[STL source code analysis] container (to be supplemented)

Mysql database foundation: constraint and identification columns

焕发青春的戴尔和苹果夹击,两大老牌PC企业极速衰败
![[STL source code analysis] iterator](/img/e8/7c69cf6e96ecfa053494397a21eff0.jpg)
[STL source code analysis] iterator

List介绍

Use keil5 software to simulate and debug gd32f305 from 0

ArcGIS Pro scripting tool (5) - delete duplicates after sorting
随机推荐
断路器HystrixCircuitBreaker
JS FAQs
[机缘参悟-34]:光锥之内皆命运
Review of mathematical knowledge: curve integral of the second type
TypeScript–es5中的类,继承,静态方法
深潜Kotlin协程(十六):Channel
Q-Learning笔记
透过华为军团看科技之变(五):智慧园区
【Proteus仿真】Arduino UNO LED模拟交通灯
LVGL 8.2图片缩放及旋转
I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly
Collectors. Tomap application
What is erdma as illustrated by Coptic cartoon?
Qt之实现QQ天气预报窗体翻转效果
中国将强制统一充电接口,苹果如不低头,iPhone将被踢出中国市场
LVGL 8.2 Checkboxes as radio buttons
Skill combing [email protected] somatosensory manipulator
电商两位大佬花边新闻刷屏,代表电商回归正常,将有利于实体经济
【深度学习】深度学习检测小目标常用方法
经典面试题:负责的模块,针对这些功能点你是怎么设计测试用例的?【杭州多测师】【杭州多测师_王sir】...