RGB to Grayscale
dot(color.rgb, float3(0.298999995, 0.587000012, 0.114));
It’s a convenient way to write rather than multiply and add up every channel.
Tangent, Normal, Bitangent
Tangent is the U of the UV for both OpenGL and DirectX. Left to right, 0.0 to 1.0. The binormal is the V of the UV. OpenGL is bottom to top, and DirectX is top to bottom. Unity is +Y, OpenGL standard. Unreal is -Y, DirectX standard.
Unity use DirectX standard on window, so tangent.w component is always negative.
Built-in variables
_ScreenParams
- x: the width of the camera’s target texture in pixels
- y: the height of the camera’s target texture in pixels
- z: 1 + 1/wdith
- w: 1 + 1/height
Shader
Toggle allows me to enable or disable the shader keyword. If I don’t specify the keyword name, the toggle affects the shader with the name (uppercase property name)_ON
Sprite default’s PixelSnap is the example of not specifying the name.
https://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html
Sprite Renderer
Sprite Renderer uses MaterialPropertyBlock
to assign the sprite texture into the material (shader). This is why we can use different sprites on Sprite Renderer while just having a single material.