This project is to showcase a list of Shader Techniques done in Unity.
Contains Examples that are meant to show off the technique only and not production ready.
Shaders Technique are Categorized into 5 category folders depending on their use and complexity
- Basic - Fundamental Shaders
- Common - Popular Shaders that you can find everywhere
- Uncommon - Specialized or Optimized Shaders
- Advanced - Complex, difficult to understand or Uber Shaders
- PostProcessing - Shaders targeting 2D, Screen or 2D Sprites
Each Shader Technique are presented in Unity either as the following
- Built-In (BI)
- Shader - Legacy format using Cg
- ShaderGraph - Added support for BI for compatibility reasons
- Universal Render Pipeline (URP)
- Shader - Current format using HLSL
- ShaderGraph - Recommanded Shader workflow
- High Definition Render Pipeline (HDRP)
- ShaderGraph - Advanced Shader workflow
- Lerp - Basic Blends between two colors
- NdotL - Basic Lighting of Lambertian diffuse model
- PlainColor - Basic Color output
- TangentToWorld - Matrix construction for calculating WorldNormals
- Texturing - Basic Texturing
- WorldPos - World Position Calculation
Blur
Blur on a texture by taking samples of the surounding/neighbouring pixels and calculating the weighted average
-
BoxBlur
3x3 Samples with equal weights
-
GaussianBlur
3x3 Samples with Gaussian weights
-
HorizontalBlur/VerticalBlur
1x9/9x1 Samples with equal weights
Color
-
ColorAdjustment
-
Desaturate
Desaturate the image by converting to luminance value using common luma formulas (e.g Rec. 601)
-
DirectHueShift
Modify Color's Hue,Saturation,Brightness uing Rodrigues’ rotation formula
-
HSVShift
Modify Color's Hue,Saturation,Brightness by converting RGB to HSV color space
-
YIQShift
Modify Color's Hue,Saturation,Brightness by converting RGB to YIQ color space
-
ColorBanding
Round/Clamp colors to the nearest N interval which results in a banding effect
- Optionaly to include a Ramp Texture to determine the color for each interval
- Used in Toon shading
-
ColorBlending
-
ColorBleed
Mix in colors depending on a threshold
-
ColorBorder
Set Color on the Border edge of an object uvs.
-
ColorRim
Adds Color based on the surface normals to the camera
- Uses the "Fresnel" or "NdotV"
Cutoff
Selectively Use of Clip/Discard/AlphaClipping to not draw certain parts of the object
-
CutoffAxis
Draw parts of the object within a selected axis and range in the world
-
CutoffBox
Draw parts of the object within a Box Bounds(AABB) in the world
-
CutoffPlane
Draw parts of the object that are on either side of a Plane in the world
-
HorizontalSlice
Draw object with equal horizontal gaps as like being sliced in parts
Dissolve
Hide/Reveal objects by making parts of the object transparent or gone and using a DissolveMap for detail
-
DissolveByDistance
Dissolve objects based on distance from a point
-
HardDissolve
Dissolve object using a dissolve texture for opaque objects
-
SoftDissolve
Dissolve object using a dissolve texture for transparent objects
FlatShading
Flatshading or Faceted Shadding is a Stylized effect to having each face of the mesh to be of the same color.
-
Using DDXY
Use partial derivative ddx, ddy to use as normals instead of using interpolated normals for fragment shader
-
Using Geometry shader
Use geometry shader to manually calculate and store the normals of a face instead of using interpolated normals for fragment shader
FlowMap
Use of a special Texture "FlowMap" to shift UVs to give a appearance of water flowing
- A Special Lerp Technique is used to loop the FlowMap and blend seemlessly over time
GerstnerWater
Well known shader to do vertex displacement using the Gerstner wave equations for ocean/water wave movement
NormalBlending (Detail Normal Map)
Technique to combine/blend two normals together. Usually for one detailed normal map and a base normal map
-
Reoriented (RNM)
Technique described by Colin Barré-Brisebois and Stephen Hill in blog
Reorient one detail normal so it follows a base normal map
Unity has a build-in Reoreinted Normal Blend Node in Shader Graph that uses a tweaked version of this
-
Simple
Technique documented In Unreal Engine UDK/UDK
Unity has a build-in Reoreinted Normal Blend Node in Shader Graph that uses this
-
WhiteOut
Technique described by Christopher Oat in "SIGGRAPH 2007 chapter 4 - Animated Wrinkle Maps" Ruby "Whiteout"
Outline
Easy Technique to create an outline around the visible parts of the model.
Two pass shader which first draws a slightly larger model and then draw normally on top.
Have some issue when another object with the same shader or transparent object overlap due to being on the transparent renderqueue and draw order.
ReflectionRefraction
TODO
Silhouette
Easy Technique to create Silhouette of parts of object when is occluded by another
Two pass shader, one draws the blocked part, one draws normally
Have Some issues when objects overlapped
>TextureChannelSelect
Select Red, Green or Blue channel of the texture using dot product. Normally use for rgb masks
TextureSplatting
Use of a special "Splat" Texture to have different parts of the model to use different texture in one material. Common used for terrain.
-
Gray
Use of a gray scale "Splat Texture"
-
RGBA
Use of a RGBA "Splat Texture" to support max 4 different texture.
-
RGBABlend
RGBA but blends properly when "Splat Texture" channels overlaps
UVScrolling
Common technique to animate the appearance of the object by updating uvs.
VertexDisplacement
Common technique to make object move by updating the position in vertex shader.
Wireframe
Common Debug/Test shader to show the triangle edges of the object.
-
WireframeBary
Use of Geometry shader to add in barycentric coordinates and using the coordinates to find nearest edge to create outlines.
-
WireframeDist
Use of Geometry shader to calculate distance to nearest edge and using the distance to create outlines at the smallest distance.
Blur
Blur on a texture by taking samples of the surounding/neighbouring pixels and calculating the weighted average
-
BoxBlur
3x3 Samples with equal weights
-
GaussianBlur
3x3 Samples with Gaussian weights
-
HorizontalBlur/VerticalBlur
1x9/9x1 Samples with equal weights
Color
-
ColorAdjustment
-
Desaturate
Desaturate the image by converting to luminance value using common luma formulas (e.g Rec. 601)
-
DirectHueShift
Modify Color's Hue,Saturation,Brightness uing Rodrigues’ rotation formula
-
HSVShift
Modify Color's Hue,Saturation,Brightness by converting RGB to HSV color space
-
YIQShift
Modify Color's Hue,Saturation,Brightness by converting RGB to YIQ color space
-
-
ColorBanding
Round/Clamp colors to the nearest N interval which results in a banding effect
- Optionaly to include a Ramp Texture to determine the color for each interval
- Used in Toon shading
-
ColorBlending
-
ColorBleed
Mix in colors depending on a threshold
-
-
ColorBorder
Set Color on the Border edge of an object uvs.
-
ColorRim
Adds Color based on the surface normals to the camera
- Uses the "Fresnel" or "NdotV"
Cutoff
Selectively Use of Clip/Discard/AlphaClipping to not draw certain parts of the object
-
CutoffAxis
Draw parts of the object within a selected axis and range in the world
-
CutoffBox
Draw parts of the object within a Box Bounds(AABB) in the world
-
CutoffPlane
Draw parts of the object that are on either side of a Plane in the world
-
HorizontalSlice
Draw object with equal horizontal gaps as like being sliced in parts
Dissolve
Hide/Reveal objects by making parts of the object transparent or gone and using a DissolveMap for detail
-
DissolveByDistance
Dissolve objects based on distance from a point
-
HardDissolve
Dissolve object using a dissolve texture for opaque objects
-
SoftDissolve
Dissolve object using a dissolve texture for transparent objects
FlatShading
Flatshading or Faceted Shadding is a Stylized effect to having each face of the mesh to be of the same color.
-
Using DDXY
Use partial derivative ddx, ddy to use as normals instead of using interpolated normals for fragment shader
-
Using Geometry shader
Use geometry shader to manually calculate and store the normals of a face instead of using interpolated normals for fragment shader
FlowMap
Use of a special Texture "FlowMap" to shift UVs to give a appearance of water flowing
- A Special Lerp Technique is used to loop the FlowMap and blend seemlessly over time
GerstnerWater
Well known shader to do vertex displacement using the Gerstner wave equations for ocean/water wave movement
NormalBlending (Detail Normal Map)
Technique to combine/blend two normals together. Usually for one detailed normal map and a base normal map
-
Reoriented (RNM)
Technique described by Colin Barré-Brisebois and Stephen Hill in blog
Reorient one detail normal so it follows a base normal map
Unity has a build-in Reoreinted Normal Blend Node in Shader Graph that uses a tweaked version of this
-
Simple
Technique documented In Unreal Engine UDK/UDK
Unity has a build-in Reoreinted Normal Blend Node in Shader Graph that uses this
-
WhiteOut
Technique described by Christopher Oat in "SIGGRAPH 2007 chapter 4 - Animated Wrinkle Maps" Ruby "Whiteout"
Outline
Easy Technique to create an outline around the visible parts of the model.
Two pass shader which first draws a slightly larger model and then draw normally on top.
Have some issue when another object with the same shader or transparent object overlap due to being on the transparent renderqueue and draw order.
ReflectionRefraction
TODO
Silhouette
Easy Technique to create Silhouette of parts of object when is occluded by another
Two pass shader, one draws the blocked part, one draws normally
Have Some issues when objects overlapped
>TextureChannelSelect
Select Red, Green or Blue channel of the texture using dot product. Normally use for rgb masks
TextureSplatting
Use of a special "Splat" Texture to have different parts of the model to use different texture in one material. Common used for terrain.
-
Gray
Use of a gray scale "Splat Texture"
-
RGBA
Use of a RGBA "Splat Texture" to support max 4 different texture.
-
RGBABlend
RGBA but blends properly when "Splat Texture" channels overlaps
UVScrolling
Common technique to animate the appearance of the object by updating uvs.
VertexDisplacement
Common technique to make object move by updating the position in vertex shader.
Wireframe
Common Debug/Test shader to show the triangle edges of the object.
-
WireframeBary
Use of Geometry shader to add in barycentric coordinates and using the coordinates to find nearest edge to create outlines.
-
WireframeDist
Use of Geometry shader to calculate distance to nearest edge and using the distance to create outlines at the smallest distance.
CelShading
Very popular cartoon/anime non-photorealistic rendering.
- Usually done by combination of Outline + ColorBanding Shader
Explode
TODO
Foil
Foil effect similar to the holofoil in Trading Card Games
InteriorMapping
Popular technique for faking rooms in buildings instead of modeling actual rooms
-
Use of a specially prepared exterior texture and interior cube map.
-
Additional work is done to have Rooms are randomized in look
CelShading
Very popular cartoon/anime non-photorealistic rendering.
- Usually done by combination of Outline + ColorBanding Shader
Explode
TODO
Foil
Foil effect similar to the holofoil in Trading Card Games
InteriorMapping
Popular technique for faking rooms in buildings instead of modeling actual rooms
-
Use of a specially prepared exterior texture and interior cube map.
-
Additional work is done to have Rooms are randomized in look
StochasticTexturing
Techniques to fix repeated patterns/artifacts when using texture tilling, mimaps on large surfaces
- HexTilling
Segment the uvs into 3 Hexagonal groups and rotate each group to produce non-repeating patterns
Tessellation
Special use inserting more vertices into the mesh. Usually as a pre-step to add more details when viewing the object very close.
-
TessellationBasic
Standard tessalation by use of Hull and Domain Shader
-
TessellationDisplacement
Use of tessllation and do vertex displacement using a height/displacement map to add more details to a low poly plane/object
Usually use for terrains.
StochasticTexturing
Techniques to fix repeated patterns/artifacts when using texture tilling, mimaps on large surfaces
- HexTilling
Segment the uvs into 3 Hexagonal groups and rotate each group to produce non-repeating patterns
Tessellation
Special use inserting more vertices into the mesh. Usually as a pre-step to add more details when viewing the object very close.
-
TessellationBasic
Standard tessalation by use of Hull and Domain Shader
-
TessellationDisplacement
Use of tessllation and do vertex displacement using a height/displacement map to add more details to a low poly plane/object
Usually use for terrains.
PostProcessing Shaders are a group of shaders that is normally done on top of the final rendered scene.
Includes old & new ways of postprocessing in unity
- MonoBehaviour.OnRenderImage [Old]
- HDRP Custom Pass Volume [New]
Bloom
Simulation the Camera Effect of having bright lights glow/bleed with nearby colors due to short exposure time.
Technique is done by bluring bright regions and layering it on the original image
LensRain
Simulation the Camera Effect of having rain streaking down on the lens.
Technique Usually Includes the folowing effect combined
- Static Droplets
- Water Streaks
Outline
Technique to create an outline around the visible parts of the model.
Post-Processing version of Outline is done using different techniques
-
OutlineDepth
Use Depth Buffer to detect edges and create outline
-
OutlineNormal
Use World Normals to detect edges and create outline
Pixelate
Styleized effect to have parts or the whole image appear at low-resolution
Technique us usually done by downsampling and then upscale.
ScreenBlur
Simulation the Camera Effect of having parts of the image streatched out due to fast motion of camera.
Technique is usually done by combining the neighbouring pixel (samples/tap) and average them up (based on weights)
-
BoxBlur9Tap
Sample 9 nearest neighbour pixel and apply Avergae weights
-
BoxBlurGaussian9Tap
Sample 9 nearest neighbour pixel and apply Gaussian weights
-
ConeBlur4Tap
Sample 4 nearest diagonal neighbour pixel and apply Average weights
-
DownResBlur
Simple blur effect as a result of downsampling the image/Screen.
-
RadialBlurGaussian9Tap
Sample 9 neighbour pixel around a circle and apply Gaussian weights
ScreenDistortion
Popular Effect to bend or warp the screen by use of distortion maps to shift and move UVs of the screen
ScreenTransition
Simple Effect to mask the screen using a special transition texture, normally used before transitioning to a new scene or area.
UnderwaterScreen
Special effect to transform the screen to appear as a camera being submerge underwater.
VHSFilter
Stylied effect to give the screen/image the look as seen from an old CRT displays.