Rendering Debug View

Note: The built-in rendering debugging feature is only available for materials using the Surface Shader framework**.

By selecting the corresponding debug mode in the upper-right corner of the scene preview window in the editor, you can view the model, materials, lighting and other computational data on the same screen, and quickly locate the problem when the rendering effect is abnormal.

debug-view

To facilitate pixel-by-pixel comparison, we use full-screen debugging instead of picture-in-picture display, which allows us to quickly switch between different data in the same screen to locate rendering errors, and to use the color picker to explore the pixel-specific values.

In addition, Surface Shader has a built-in Irrational Number Visualization feature, so once some pixels appear to have abnormal Red(255, 0, 51) and Green(0, 255, 51) alternately blink, then the rendering calculation of these pixels appears irrational, please use the single debug mode to check the model tangent or other related data.

The rendering debugging functions are subdivided into the following three categories.

1. Common Options

Debugging options that are in effect in either single or combined mode, including:

NameFunctionDebugging Tips
Lighting with Base ColorCheck to show normal material illumination, check off to show the effect of white mold pure illumination.You can see the effect of AO, GI and other indirect light related effects more obviously.
CSM Layer ColorationCascading shadows are stained layer by layer from near to far, distributed as reddish, greenish, bluish, and yellowish, with no staining in areas beyond the shadows.Allows you to view and confirm the fineness of the scene shadows.
If three or four layers accounted for too little shading is too fine, should increase the shading visible distance.
If the ratio of one or two layers is too small, it means that the shadows are too coarse and the visible distance of shadows should be reduced.

2. Single mode

The debugging focus is on a particular piece of data that needs to be tested, and the entire scenario visualizes this data output.

The debuggable data includes four major categories.

I. Primitive Model Info

NameFunctionDescription and debugging tipsDependencies
Vertex ColorsVertex ColorsMust check USE VERTEX COLOR in material
World NormalWorld Normal
World TangentWorld TangentIf there are irrational numbers or unusual lighting effects in the calculation you can focus on checking here, if it is black then the model tangent is not turned on but normal mapping or anisotropy is turned on.Exclusion cannot be selected in the model’s tangent settings
Must have USE NORMAL MAP or IS ANISOTROPY checked in the material
World PositionVisualize vertex coordinates (no scaling)RGB channels display the XYZ axis coordinate data.
You can judge the difference of world space axis by color, and the model size by light and dark.
Mirrored NormalShow normal map flip reuse markersTo improve normal map utilization, some symmetric models (e.g., faces) will only bake half of the normals and reuse the data in the normal map using mirror markers for the other half.
If the value of this marker does not change at all on the model, it may cause the normals of the other half of the model to show unusual effects such as bump flip.
Must check USE NORMAL MAP in the material
Front Face ColorationDisplay front or back facesWith the default single-sided model, the normals are not automatically distinguished and the light and dark seen on the front and back sides of the model are the same.
When a single-sided model uses a double-sided material, it automatically distinguishes between the front and back normals, and the light and dark seen on the front and back sides of the model are different.
The mark is white for the front side of the model and black for the reverse side. It can be used to check the light and darkness of the single-sided model.
UV0Display the First UV
UV1Display the second UVMust be checked in the material HAS SECOND UV
Lighting MAP UVDisplay the lighting mAP UVIf the light mapping effect is not correct, you can turn on this option and compare the general area of the light mapping to check the error.Must bake scenes
Projection Depth ZDisplay (0-1 non-linear variation) depthToo far away of the far clip plane will result in a large depth value in the near field.
Linear Depth WDisplay (0-1 linear variation) depthToo far away of the far clip plane will result in a large depth value in the near field

II. Primary Material Info

NameFunctionDescription and debugging tipsDependencies
World Space Pixel NormalsYou can compare with the corresponding vertex data to see if the effect of normal mapping is correct
World Space Pixel Tangent/BinormalsCan compare with corresponding vertex data to see if normal mapping affects it correctlyCannot be selected for exclusion in the model’s tangent settings
Must have USE NORMAL MAP or IS ANISOTROPY checked in the material
Base Color
Diffuse ColorBase colors affecting diffuse illumination calculated from natural colors and other material data
Specular ColorThe base color affecting specular reflective lighting calculated from intrinsic color and other material data
OpacitySmaller means more transparentMust have Alpha Blend enabled in the material
Metallic
Roughness
Specular IntensityDisplay the multiplication of non-metallic reference mirror reflectance F0If the specular is black, please check if this field is set to 0.

III. Lighting Info

NameFunctionDescription and debugging tipsDependencies
Direct Diffuse
Direct Specular
Direct LightingDirect Diffuse + Direct Specular
Ambient Diffuse
Ambient Specular
Ambient LightingAmbient Diffuse + Ambient Specular
EmissiveDisplay the emissive in the material
Light MapDisplay baked lightmap RGB colorsMust bake scenes
ShadowsShow shadows of directional light, spot light, point lightShadows must be enabled in the scene’s Inspector panel and light sources, and objects enabled to receive shadows
Ambient OcclusionShow the color of AO map in the material and real-time AO

IV. Misc Info

NameFunctionDescription and debugging tipsDependencies
FogDisplay the fog effect factor, the larger it is, the denser the fog isFog effect must be enabled in the scene’s Inspector panel

3. Render Composite Options

The debugging focus is on the overall rendering performance, and each module can be blocked or turned on, with modules unrelated to each other, to see how different modules affect each other’s rendering effects.

Single mode has higher priority than the composite mode, If you want to use the composite mode, you must check No single mode.

Including:

NameFunctionDescription and debugging tipsCategory
Direct DiffuseEnable/Disable Direct Light DiffuseAffect Directional, Spot, and Point LightLighting
Direct SpecularEnable/Disable Direct Light Specular ReflectionAffect Directional, Spot, and Point LightLighting
Ambient DiffuseEnable/Disable Ambient Light DiffuseInfluence SkylightLighting
Ambient SpecularEnable/Disable Ambient Light Specular ReflectionInfluence SkylightLighting
EmissiveEnable/Disable EmissiveIf some objects are too bright or exposed, try to turn off this option is not set in the material unnecessary self-illuminationLighting
Light MapEnable/Disable Baking LightAffect BakingLight
ShadowsEnable/Disable Direct Light ShadowsAffect Live Directional Light / Spot Light / Spot Light Shadows and Baked Directional Light ShadowsLighting
Ambient OcclusionEnable/Disable Ambient OcclusionInfluence SkylightLight
Normal MapEnable/Disable Normal MapIf the lighting is unusually scattered, try turning this option off to see if the normal map is scrambling at the wrong intensity.
If the lighting effect is wrong or appears irrational, try turning this option off to see if the model is not tangential
Materials
FogEnable/Disable fog effectIf the scene color is abnormally gray, try turning off this option to see if the fog parameter is not set properlyEnvironment
Tone MappingEnable/Disable Tone MappingIf the scene color is too different from the original material, try to turn off this option to see if it is normal, indicating that UseHDR should not be checked in the scene panelColor Space
Gamma CorrectionEnable/Disable Gamma CorrectionIf the scene is unusually colorful and dark, try turning off this option to see if it is normal, indicating that the mapping resources may have been gamma corrected multiple timesColor Space

4. Advanced Usage

  1. Manual inserting vertex shader outputs and fragment shader inputs: with the new varying property introduced in the Surface Shader framework, vertex shader outputs and fragment shader inputs can be accessed in particular Surface Functions.
  2. Surface Shader and legacy shader codes can be used in the same render loop as long as the varying vertex data are kept consistent between the two.

Public function libraries

The library headers can be found under assets -> internal -> chunks -> common folder in different categories.

The functions in the library do not depend on any internal data (engine related uniform, mapping, etc.) and can be used directly as tool functions.

Surface already automatically contains common public function headers internally, which can be classified according to type as:

Folder NameFunction Usage
colorcolor-related functions (color space, tonemapping, etc.)
dataData-related functions (compression and decompression, etc.)
debugDebug View-related functions
effectScene effect-related functions (water, fog, etc.)
lightinglighting-related features (brdf, bsdf, attenuation, baking, etc.)
mathmath library (coordinate transformation, numerical determination and operation, etc.)
meshmodel-related functions (material conversion, model animation, etc.)
shadowshadow-related functions (pcf, hcs, etc.)
texturemapping-related functions (sampling, mip calculation, etc.)