ShaderNotes

Shaders created in unity for learning and experimenting purposes

Stars
0
Committers
2

Shaders And CG Notes On Unity

Experiments and notes based on different sources. This page shows the effects and key points of shaders created. Also for each experiment, there is a link to see full codes. Shaders are created in cg for now.

Sources

Assets

Many thanks to the creators of these valuable sources.

Experiments

Experiment_002 Stencil Shader

See Full Stencil Shader Codes

Experiment_003 Kaleidoscope Effect

See Full Kaleidoscope Effect Shader Codes

Note: Unity_Rotate_Degrees_float is a function written by Unity included in Shader Graph. The function rotates the value of input UV around a reference point defined by the input Center by the amount of input rotation. See in Shader Graph Manual

Experiment_004 Zoom Effect

Zoom Effect Kaleidoscope Shader See Full Zoom Effect Shader Codes

Experiment_005 Health Bar

Experiment_005.1 Simple Health Bar

Experiment_005.2 Fancy Health Bar

See Full Healthbar Shader Codes Note: My implementation for roundness and border is overcomplex. It can be easily made with SDF. Please watch this part from Freya Holmr's Shader Video if you'd like to see a clean implementation.

Experiment_006 Sprite Outline Effect

Sprite Outline Sprite Outline Shader See Full Sprite Outline Shader Codes

Experiment_007 Lighting

Lambertian Phong Lambertian Phong Shader See Full Lighting codes Note 1: _LightColor0, _WorldSpaceLightPos0 and _WorldSpaceCameraPos are built-in shader variables in Unity. See document here. Note 2: reflect is a cg function that returns the reflection vector given an incidence vector i and a normal vector n. See document here. Note 3: We used Tags{"LightMode" = "ForwardBase"} in code because we want to use Forward rendering. This rendering target is the default in Unity. See document here.

Experiment_008 Fresnel Effect

See Full Fresnel Effect Shader Codes

Note: This effect only works properly on rounded objects due to its nature. It is a popular technique used in many games.

Experiment_009 Gradient Effect

See Full Gradient Effect Shader Codes

Experiment_010 UV Distortion Effect

See Full UV Distortion Effect Shader Codes