Skip to content

Shaders created in unity for learning and experimenting purposes

Notifications You must be signed in to change notification settings

etopuz/ShaderNotes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Hole Mechanic From Donut County

StencilMask Shader

StencilBlocked Shader

See Full Stencil Shader Codes

Experiment_003 Kaleidoscope Effect

Kaleidoscope Effect

Kaleidoscope Shader

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

Simple Health Bar Simple Health Bar Shader

Experiment_005.2 Fancy Health Bar

Fancy Health Bar Fancy Health Bar Shader

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 Holmér'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

Fresnel Effect

Fresnel Shader

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

Gradient Effect

Gradient Shader

See Full Gradient Effect Shader Codes

Experiment_010 UV Distortion Effect

UV Distortion Effect

UV Distortion Shader

See Full UV Distortion Effect Shader Codes