MatCap Material Capture. It is to capture the material on a texture. And represent it to the model.(https://digitalrune.github.io/DigitalRune-Documentation/html/9a8c8b37-b996-477a-aeab-5d92714be3ca.htm)
The general procedure is: (https://forum.unity.com/threads/writing-a-matcap-shader.518949/)
convert the object space normal to view space. remap it to (0,1) use it as UV to sample matcap texture. Ben Golus’ implementation: https://gist.github.com/bgolus/02e37cd76568520e20219dc51653ceaahttps://twitter.com/bgolus/status/1487224443688554497?s=20&t=-4eC1dOBkMmIMLR5-9QloQhttps://forum.unity.com/threads/getting-normals-relative-to-camera-view.452631/
Unity Lighting Optimization source: https://unity.com/how-to/advanced/optimize-lighting-mobile-games
UV channels
One set of UV channels is enough, because metallic, occlusion, and smoothness value from the texture usually stores in the same place....
Vertex Animation Vertex offset achieves the wind animation of tree leaves. By specifying the vertex color, vertex shader can use lerp to filter the animation on a certain part of the mesh. For example, only leaves will wave by painting all leaves’ color red.
URP Sample Texture
https://forum.unity.com/threads/writing-shaders-urp-texture2d-sampler.1000782/
TEXTURE2D()translates the texture to the target API’s native type. GLES2 is sampler2D and others are Texture2D.
Maintenance pow() vs. sqrt()
After compile pow(a, b) in shader, the code will become exp2(log2(a) * b )...
SRP Batcher + OpenGL bug:
https://forum.unity.com/threads/srp-batcher-does-not-work-with-opengles3.1095937/
Shadow Cascade
Unity Doc: https://docs.unity3d.com/Manual/shadow-cascades.html Cat Like Coding: https://catlikecoding.com/unity/tutorials/scriptable-render-pipeline/directional-shadows/
Shadow map pixels close to the Camera look enlarged and chunky to those farther away. Unity solves this problem by splitting the frustum area int otwo zones based on the distance from the camera, and use two separate shadow map. The resolution of each map is staged reduced.
It also increased Drawcall: https://forum.unity.com/threads/unity-draw-5-4-introducing-more-draw-calls.426185/
Outline https://alexanderameye.github.io/notes/rendering-outlines/...
Unity URP _MainLightShadowParams
x: shadowStrength y: 1.0 = soft shadow, 0.0 = otherwise z: 1/ fade distance w: 1- start fade Anti-Aliasing What is AA: https://www.youtube.com/watch?v=hqi0114mwtY
How to do AA? There’re two types of AA. One is to increase the sample rate, that means to render the scene in a higher resolution and sample down it to the target resolution to smooth the line. Two is to blur the edge or contrast, known as Post AA or Post Processing ....
Compute Shader It transfers some computation from CPU to GPU by HLSL code. Hence the name has “compute” and “shader”.
References:
Getting Started with Compute Shaders in Unity: https://www.youtube.com/watch?v=BrZ4pWwkpto Coding Adventure: Compute Shaders: https://www.youtube.com/watch?v=9RHGLZLUuwc&list=LL2T54R7-vJmcMBzcaTL_oBw GPU Ray Tracing in Unity: http://three-eyed-games.com/2018/05/03/gpu-ray-tracing-in-unity-part-1/ Unity Documentation: https://docs.unity3d.com/Manual/class-ComputeShader.html
Compute Shader are programs that run on the graphic card, outside of the normal rendering pipeline. It works on:
Android: OpenGL ES 3.1, iOS: Metal Compute Shader Assets...