SlideShare a Scribd company logo
Shader, TheShader, The
UnknownUnknown
at UnityWTB - by @doppioslash - 26/03/2016at UnityWTB - by @doppioslash - 26/03/2016
Hi, I'mHi, I'm
Claudia DoppioslashClaudia Doppioslash
@doppioslash@doppioslash
FunctionalFunctional
ProgrammerProgrammer
GameDevGameDev &&
Shader Programmer onShader Programmer on
CyberCook (iPad&VR)CyberCook (iPad&VR)
I writeI write
www.shadercat.comwww.shadercat.com
A site about Shaders, Rust,A site about Shaders, Rust,
and Graphics Programmingand Graphics Programming
@shadercat
Why make your ownWhy make your own
custom shader(s)?custom shader(s)?
Why make your own custom shader(s)?Why make your own custom shader(s)?
Unity 5 has got a pretty decent default shader system
Why make your own custom shader(s)?Why make your own custom shader(s)?
But!But!
Why make your own custom shader(s)?Why make your own custom shader(s)?
Journey's look was not achieved with a standard shader.
Why make your own custom shader(s)?Why make your own custom shader(s)?
Optimise for a specificOptimise for a specific
target platformtarget platform
(Like VR)(Like VR)
Why make your own custom shader(s)?Why make your own custom shader(s)?
more work
needs thought
needs time from the artists
needs to study those Graphics papers!
Drawbacks:Drawbacks:
So what is aSo what is a
shader?shader?
So what is a shader?So what is a shader?
"A piece of code that runs on"A piece of code that runs on
the GPU, takes vertices,the GPU, takes vertices,
textures, and other data,textures, and other data,
and returns pixel colours"and returns pixel colours"
So what is a shader?So what is a shader?
PipelinePipeline
scene -> objects with the same material ->scene -> objects with the same material ->
So what is a shader?So what is a shader?
PipelinePipeline
drawcall -> list of vertices & other info ->drawcall -> list of vertices & other info ->
So what is a shader?So what is a shader?
PipelinePipeline
vertex shader -> fragment + interpolated data ->vertex shader -> fragment + interpolated data ->
So what is a shader?So what is a shader?
PipelinePipeline
fragment shader (lighting) -> final pixel colorfragment shader (lighting) -> final pixel color
(An aside)(An aside)
Renderer TypesRenderer Types
Renderer TypesRenderer Types
-> (See )GDC 2016
Forward
Deferred
Forward+
Object Space
Renderer TypesRenderer Types
ForwardForward
Shading happens at each object's raster timeShading happens at each object's raster time
One pass for each lightOne pass for each light
Expensive when many lightsExpensive when many lights
But good support for complex lightingBut good support for complex lighting
Unity supports itUnity supports it
Renderer TypesRenderer Types
DeferredDeferred
Shading happens last, onceShading happens last, once
First rasterises the objects data into 2d buffersFirst rasterises the objects data into 2d buffers
Cheap when many lightsCheap when many lights
Limited support for complex lightingLimited support for complex lighting
Unity supports itUnity supports it
Unity Shaders BasicUnity Shaders Basic
Unity Shaders BasicUnity Shaders Basic
Each material has aEach material has a
shader assignedshader assigned
Unity Shaders BasicUnity Shaders Basic
The language is CgThe language is Cg
(NVIDIA) + ShaderLab(NVIDIA) + ShaderLab
Unity Shaders BasicUnity Shaders Basic
Pre-filled templatesPre-filled templates
Unity Shaders BasicUnity Shaders Basic
Surface Shaders give you:Surface Shaders give you:
easier normal mapping
helper functions
add passes for forward renderer
Occasionally it's in the way.Occasionally it's in the way.
But!But!
Unity Shaders BasicUnity Shaders Basic
Surface ShadersSurface Shaders
AnatomyAnatomy
Unity Shaders BasicUnity Shaders Basic
Properties:Properties:
We can also build custom inspector editors
Unity Shaders BasicUnity Shaders Basic
Properties Custom InspectorProperties Custom Inspector
Unity Shaders BasicUnity Shaders Basic
SubshaderSubshader
Unity Shaders BasicUnity Shaders Basic
StructsStructs
Unity Shaders BasicUnity Shaders Basic
StructsStructs
limited slots
data from the various phases has to go
through them
Unity Shaders BasicUnity Shaders Basic
Surf functionSurf function
Unity Shaders BasicUnity Shaders Basic
custom lighting functioncustom lighting function
use the naming convention
Lighting<name>
Unity Shaders BasicUnity Shaders Basic
(optional) custom vertex shader(optional) custom vertex shader
Unity Shaders BasicUnity Shaders Basic
The Standard shaderThe Standard shader
implementation can beimplementation can be downloadeddownloaded
Unity Shaders BasicUnity Shaders Basic
The include files are important toThe include files are important to
interoperate with Unity shadows/lightmapsinteroperate with Unity shadows/lightmaps
Pre-PBS principlesPre-PBS principles
Non-PBS principlesNon-PBS principles
In the olden days...In the olden days...
diffuse
specular
normal
texture BRDF lookup
fresnel
we lacked ALU power to do complex lightingwe lacked ALU power to do complex lighting
Parts of the shaderParts of the shader
Diffuse = dot(N,L)Diffuse = dot(N,L)
lacks a model of the surface behaviourslacks a model of the surface behaviours
it can give back more light than it receivesit can give back more light than it receives
dot product of the Normal and Light directionsdot product of the Normal and Light directions
Parts of the shaderParts of the shader
Diffuse = dot(N,L)Diffuse = dot(N,L)
Parts of the shaderParts of the shader
Normal MappingNormal Mapping
is still largely the sameis still largely the same
a way to add cheap detail with one texturea way to add cheap detail with one texture
Parts of the shaderParts of the shader
SpecularSpecular
depends just on direction and specular mapdepends just on direction and specular map
no concept of Roughnessno concept of Roughness
Specular Power :/Specular Power :/
PBS principlesPBS principles
PBS principlesPBS principles
LinearLinear
[ref: ]The importance of being linear
PBS principlesPBS principles
LinearLinear
[ref: ]Linear-Space Lighting (i.e. Gamma)
PBS principlesPBS principles
LinearLinear
PBS principlesPBS principles
LinearLinear
mobile toLinear
mobile toGamma
PBS principlesPBS principles
HDRHDR
PBS principlesPBS principles
HDRHDR
Many operators for Tone MappingMany operators for Tone Mapping
[Ref: ]filmicgames.com
Reinhard
plain linear &
exposure adjustment
PBS principlesPBS principles
The Rendering EquationThe Rendering Equation
[Ref: ]@levork
(using only 1000 most used English words)
PBS principlesPBS principles
The Rendering EquationThe Rendering Equation
[Ref: ]Raytracing Lecture
PBS principlesPBS principles
Microfacet theoryMicrofacet theory
Introduces a good explanation of RoughnessIntroduces a good explanation of Roughness
Surfaces have micro-facetsSurfaces have micro-facets
each reflect light according to its normaleach reflect light according to its normal
PBS principlesPBS principles
Microfacet theoryMicrofacet theory
[Ref: ]Moving Frostbite to PBR
In a picture
PBS principlesPBS principles
Energy conservationEnergy conservation
More intense highlight are smallerMore intense highlight are smaller
Less intense are largerLess intense are larger
Can't reflect more light than receivedCan't reflect more light than received
PBS principlesPBS principles
Area LightsArea Lights
Sadly no realtime support in UnitySadly no realtime support in Unity
More expensive but more realisticMore expensive but more realistic
PBS principlesPBS principles
More accurate BRDFsMore accurate BRDFs
Oren Nayar
Cook Torrance
Ashikhmin Shirley
and many more...
PBS principlesPBS principles
Indirect lightIndirect light
Prefiltered CubeMapsPrefiltered CubeMaps
Global IlluminationGlobal Illumination
Physically Based ProcessPhysically Based Process
Normal Process:Normal Process:
fail and no idea whyfail and no idea why
Physically Based ProcessPhysically Based Process
You've got nothing to compare with except
your own imagination.
And small errors can pile up unseen
PB Process:PB Process:
fail and know why/wherefail and know why/where
by comparing with refby comparing with ref
Physically Based ProcessPhysically Based Process
PB Process:PB Process:
same settings will work withsame settings will work with
different lighting conditionsdifferent lighting conditions
Physically Based ProcessPhysically Based Process
Different BRDFsDifferent BRDFs
for Different surfacesfor Different surfaces
LambertLambert
Different BRDFsDifferent BRDFs
Diffuse onlyDiffuse only
PlainestPlainest
Very cheapVery cheap
Ok for matte plastic surfacesOk for matte plastic surfaces
Oren NayarOren Nayar
Different BRDFsDifferent BRDFs
Adds a roughness modelAdds a roughness model
Diffuse onlyDiffuse only
Pretty decent for skin, clothPretty decent for skin, cloth
(even not using Subsurface(even not using Subsurface
Scattering)Scattering)
BlinnBlinn
Different BRDFsDifferent BRDFs
plasticplastic
with energy conservation it's a viable choicewith energy conservation it's a viable choice
Cook TorranceCook Torrance
Different BRDFsDifferent BRDFs
flexible, good all aroundflexible, good all around
there are better BRDFs for metalthere are better BRDFs for metal
A great specularA great specular
Ashikhmin ShirleyAshikhmin Shirley
Different BRDFsDifferent BRDFs
Excellent for metalExcellent for metal
AnisotropicAnisotropic
As an extra layer for wet surfacesAs an extra layer for wet surfaces
DisneyDisney
Different BRDFsDifferent BRDFs
onesize fits allonesize fits all
maybe easier for artists but not as flexiblemaybe easier for artists but not as flexible
they chose to keep the fewest parametersthey chose to keep the fewest parameters
possiblepossible
Drawbacks to choosingDrawbacks to choosing
unusual BRDFs:unusual BRDFs:
BRDFs window shoppingBRDFs window shopping
Indirect lighting calculation can be trickyIndirect lighting calculation can be tricky
But using one for a more common BRDF couldBut using one for a more common BRDF could
work okwork ok
Artist facing decisionsArtist facing decisions
Artist facing decisionsArtist facing decisions
more configurability meansmore configurability means
more confusing for the artistmore confusing for the artist
need to figure out whichneed to figure out which
parameters are less relevantparameters are less relevant
Unity Frame DebuggerUnity Frame Debugger
BRDF DemonstrationBRDF Demonstration
Let's shade some heads in Unity...Let's shade some heads in Unity...
ConclusionConclusion
Now you have the basics to tackleNow you have the basics to tackle
making your own custom lightingmaking your own custom lighting
system.system.
ReferencesReferences
Find them at:
www.shadercat.com/unity-wtb-talk-shader-the-unknown/
That's all folks!That's all folks!
@doppioslash @shadercat
See you on twitter :)

More Related Content

PPTX
Cg shaders with Unity3D
PPTX
Shader Programming With Unity
PPTX
Writing shaders - YOU can do it!
PPT
CS 354 GPU Architecture
PDF
Deferred rendering in Dying Light
PDF
Smedberg niklas bringing_aaa_graphics
PDF
Rendering basics
PDF
Rendering Tech of Space Marine
Cg shaders with Unity3D
Shader Programming With Unity
Writing shaders - YOU can do it!
CS 354 GPU Architecture
Deferred rendering in Dying Light
Smedberg niklas bringing_aaa_graphics
Rendering basics
Rendering Tech of Space Marine

What's hot (20)

PPT
GDC 2012: Advanced Procedural Rendering in DX11
PPT
Real-time Shadowing Techniques: Shadow Volumes
PPT
The Unique Lighting of Mirror's Edge
PPTX
OpenGL Shading Language
PPT
CS 354 Programmable Shading
PPTX
A Bizarre Way to do Real-Time Lighting
PPTX
Substanceshanghaippt repacked
PDF
Uncharted3 effect technique
PPT
NVIDIA's OpenGL Functionality
PPT
CS 354 Vector Graphics & Path Rendering
PPT
GTC 2012: GPU-Accelerated Path Rendering
PPTX
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
PPT
GTC 2012: NVIDIA OpenGL in 2012
PDF
Clean architecture for shaders unite2019
PDF
Gdc 14 bringing unreal engine 4 to open_gl
PPT
CS 354 Introduction
PPT
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
PPTX
Hable John Uncharted2 Hdr Lighting
PDF
Epic_GDC2011_Samaritan
PDF
Rendering AAA-Quality Characters of Project A1
GDC 2012: Advanced Procedural Rendering in DX11
Real-time Shadowing Techniques: Shadow Volumes
The Unique Lighting of Mirror's Edge
OpenGL Shading Language
CS 354 Programmable Shading
A Bizarre Way to do Real-Time Lighting
Substanceshanghaippt repacked
Uncharted3 effect technique
NVIDIA's OpenGL Functionality
CS 354 Vector Graphics & Path Rendering
GTC 2012: GPU-Accelerated Path Rendering
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
GTC 2012: NVIDIA OpenGL in 2012
Clean architecture for shaders unite2019
Gdc 14 bringing unreal engine 4 to open_gl
CS 354 Introduction
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
Hable John Uncharted2 Hdr Lighting
Epic_GDC2011_Samaritan
Rendering AAA-Quality Characters of Project A1
Ad

Viewers also liked (20)

PPT
Geometry Shader-based Bump Mapping Setup
PPTX
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
PDF
Shaders in Unity by Zoel
PPT
Shadow Volumes on Programmable Graphics Hardware
PPT
CS 354 Project 2 and Compression
PDF
Unity advanced computer graphics week 02
PPTX
An Introduction to Writing Custom Unity Shaders!
PPTX
Shader model 5 0 and compute shader
PDF
Game Programming 12 - Shaders
PDF
Unity Surface Shader for Artist 01
PPTX
Spark Data Streaming Pipeline
PPTX
Pixel shaders
PDF
Big Data Logging Pipeline with Apache Spark and Kafka
PDF
Email Classifier using Spark 1.3 Mlib / ML Pipeline
PPT
OpenGL 3.2 and More
ODP
PDF
유니티 게임 그래픽스 아트 개발 사례 분석
PPTX
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
PDF
Unity Surface Shader for Artist 02
PDF
Play RICOH THETA 360 Videos in Unity Shanyuan Teng
Geometry Shader-based Bump Mapping Setup
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Shaders in Unity by Zoel
Shadow Volumes on Programmable Graphics Hardware
CS 354 Project 2 and Compression
Unity advanced computer graphics week 02
An Introduction to Writing Custom Unity Shaders!
Shader model 5 0 and compute shader
Game Programming 12 - Shaders
Unity Surface Shader for Artist 01
Spark Data Streaming Pipeline
Pixel shaders
Big Data Logging Pipeline with Apache Spark and Kafka
Email Classifier using Spark 1.3 Mlib / ML Pipeline
OpenGL 3.2 and More
유니티 게임 그래픽스 아트 개발 사례 분석
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Unity Surface Shader for Artist 02
Play RICOH THETA 360 Videos in Unity Shanyuan Teng
Ad

Similar to Shaders - Claudia Doppioslash - Unity With the Best (20)

PDF
Abalanche - Unity Shader Graph #1: Shader & PBR Materials
PPT
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
PDF
Shaders in Unity
PDF
[UniteKorea2013] The Unity Rendering Pipeline
PPTX
Shaders & Standard Shader In Unity
PDF
Unite2014: Mastering Physically Based Shading in Unity 5
PPT
Gpu presentation
PPTX
Around the World in 80 Shaders
PDF
Deferred shading
PPT
Star Ocean 4 - Flexible Shader Managment and Post-processing
PDF
Shader editor
PDF
Physically Based Shading - Realtime Rendering CH9
PDF
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
PDF
SPU Shaders
PPTX
Real-time lightmap baking
PPT
Far cry 3
PPTX
Develop2012 deferred sanchez_stachowiak
PPTX
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
PPT
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
PPTX
XR graphics in Unity: delivering the best AR/VR experiences – Unite Copenhage...
Abalanche - Unity Shader Graph #1: Shader & PBR Materials
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
Shaders in Unity
[UniteKorea2013] The Unity Rendering Pipeline
Shaders & Standard Shader In Unity
Unite2014: Mastering Physically Based Shading in Unity 5
Gpu presentation
Around the World in 80 Shaders
Deferred shading
Star Ocean 4 - Flexible Shader Managment and Post-processing
Shader editor
Physically Based Shading - Realtime Rendering CH9
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
SPU Shaders
Real-time lightmap baking
Far cry 3
Develop2012 deferred sanchez_stachowiak
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
XR graphics in Unity: delivering the best AR/VR experiences – Unite Copenhage...

More from BeMyApp (20)

PPTX
Introduction to epid
PDF
Introduction ciot workshop premeetup
PPTX
Présentation des APIs cognitives IBM Watson
PDF
Crédit Agricole S.A. Personae et Parcours
PDF
Cisco Paris DevNet Hackathon slideshow - Intro
PPTX
Tumeurs Neuroendocrines : une vue d'ensemble
PPTX
Building your first game in Unity 3d by Sarah Sexton
PDF
Using intel's real sense to create games with natural user interfaces justi...
PPTX
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
PPTX
Audio Mixer in Unity5 - Andy Touch
PDF
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
PDF
Tools to Save Time
PDF
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
PDF
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
PPTX
[IoT World Forum Webinar] Review of CMX Cisco technology
PDF
HP Helion Episode 6: Cloud Foundry Summit Recap
PDF
Webinar UI/UX by Francesco Marcellino
PDF
HP Helion Webinar #5 - Security Beyond Firewalls
PDF
HP Helion Webinar #4 - Open stack the magic pill
PDF
HP Helion European Webinar Series ,Webinar #3
Introduction to epid
Introduction ciot workshop premeetup
Présentation des APIs cognitives IBM Watson
Crédit Agricole S.A. Personae et Parcours
Cisco Paris DevNet Hackathon slideshow - Intro
Tumeurs Neuroendocrines : une vue d'ensemble
Building your first game in Unity 3d by Sarah Sexton
Using intel's real sense to create games with natural user interfaces justi...
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Audio Mixer in Unity5 - Andy Touch
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
Tools to Save Time
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[IoT World Forum Webinar] Review of CMX Cisco technology
HP Helion Episode 6: Cloud Foundry Summit Recap
Webinar UI/UX by Francesco Marcellino
HP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #4 - Open stack the magic pill
HP Helion European Webinar Series ,Webinar #3

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
Teaching material agriculture food technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Modernizing your data center with Dell and AMD
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
MYSQL Presentation for SQL database connectivity
Spectral efficient network and resource selection model in 5G networks
Teaching material agriculture food technology
Network Security Unit 5.pdf for BCA BBA.
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
“AI and Expert System Decision Support & Business Intelligence Systems”
Modernizing your data center with Dell and AMD
Building Integrated photovoltaic BIPV_UPV.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction

Shaders - Claudia Doppioslash - Unity With the Best