SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
The Unity Rendering Pipeline
Kuba Cupisz
(Tim Cooper)
Texthttp://is.gd/RenderingPipeline_UniteAsia13
Who am I?
• Kuba
• graphics programmer
• at Unity for... quite.some.time
• worked on small game projects before
Topics
What Unity is good/bad at
Built-in shaders
Shader combinations
Per material keywords
Lit shader replace
Endless runner with light probes
DX 11
Tessellation
Random writes
Volume textures
What is Unity good at
• Very flexible rendering pipeline
• vertex lit / forward / deferred
• custom shaders
• custom lighting models
• completely customizable
What is Unity bad at
• Very flexible rendering pipeline
• difficult to configure (so.many.options)
• Some parts are better maintained then others
• dual lightmaps in forward
• Default settings do not suit all projects
• very general, scale from mobile to high end
• aim your configuration at your target
Built-in shaders - good for
• Work with all rendering configurations
• forward / deferred, realtime lighting / lightmaps
• Support standard lighting models
• lambert / blinn-phong
• Work on all platforms
Built-in shaders - not good for
• Stylized games
• only provide ‘standard’ lighting models
• Super-performance
• if you know how your game will look, you can write more specific (faster) shaders
• Size
• always have many shader variants due to supporting many possible configurations
When to write your own?
• When the built-in shaders
• are not custom enough
• are not fast enough - don’t assume, profile!
• you know exactly how you want your game to be rendered
Shader combinations
• Compile variants of your shader
• to do different things based on keywords
• shader keywords are set globally
• can be overridden per material
Shader combinations
• Each line declares a set of defines
• only one per line can be active at a time
• Make sure you enable one, otherwise Unity will pick one for you
Shader combinations
#pragma multi_compile AAA BBB
• two variants
• one where AAA is defined
• another where BBB is defined (and AAA is not)
Shader combinations
#pragma multi_compile AAA BBB
#pragma multi_compile CCC
• two variants
• AAA CCC
• BBB CCC
Shader combinations
#pragma multi_compile AAA BBB
#pragma multi_compile CCC DDD
• four variants
• AAA CCC
• BBB CCC
• AAA DDD
• BBB DDD
Per material keywords
• Shader keywords property on a material
• array of strings
• each string a keyword
• Write a custom editor to make it easy to use
Material inspector
• Extend the MaterialEditor class
• Override OnInspectorGUI()
• remember to call base.OnInspectorGUI() !
Shader combinations example
• Surface shader
• 2 defines
• 1 for darken blend mode
• 1 for difference blend mode
• configured via material inspector
Shader combinations
• Applications
• switch the shaders in your scene via a keyword
• completely change the look of your game
• in the future
• one shader for: diffuse, specular, normal maps, etc.
Shader replace
• Objects normally get rendered with whatever material /shader is configured on
them
• Using shader replace you can swap out the shader
• still uses same material (so textures / properties will be the same as in the original
rendering)
• Sub-shader is selected based on tag-matching
Shader replace - Tags
• When setting a replacement shader, you can set the tag
• Camera.SetReplacementShader (Shader s, string tag)
• Camera.RenderWithShader (Shader s, string tag)
Shader replace - Tags
• No tag specified?
• all objects will be rendered with the replacement shader
• uses the first subshader of the replacement shader
Shader replace - Tags
• Tag set?
• the real object’s shader is queried for the tag value
• no matching tag?
• not rendered
• tag found?
• subshader from the replacement shader selected which matches the tag
Tags
• Builtin, e.g. RenderType:
• Opaque
• Transparent
• TransparentCutout
• etc.
• Custom
• whatever you want!
Lit-Shader replacement
• New in Unity 4.1
• Useful for
• scene view enhancement
• special effects
• How does it work?
• just like normal shader replace!
• but you can use shaders that have lighting passes (surface shaders!)
Endless runner with light probes
• The track is assembled from blocks
• Any block can be matched with any other block
• It’s not feasible to bake light probes for all the combinations of block setups
Endless runner with light probes
• Bake light probes for each block separately
• After baking, light probes are tetrahedralized
• When the player moves from one block to the other you want to switch to light
probes for the new block
• set Lightmapping.lightProbes
Smooth transition
• Just switching from one light probe set to another will give a pop
• Solution:
• make sure that start and end light probe positions have the same layout
• when loading the new probes, set the start probes in the new set to the end probes of the
previous set
Smooth transition
• Transition distance
• add another set of light probes relatively closely to the start probes to control the
transition distance
Baked data is not movable
• Loaded light probes will show up at the positions where they were baked
• in our case the blocks’ pivots are at (0,0,0)
• If you’d use player’s position to sample light probes you’d sample outside of the
volume defined by the probes -- not good
Baked data is not movable
• Luckily you can set lightProbeAnchor on the renderer to a transform of choice
• Parent the transform under the player
• Set local offset to -currentBlocksOffset on block change
DX 11
• Gives you more flexibility
• Allows for techniques that were impossible to do on the GPU before and not
feasible on the CPU
Tessellation
• What is tessellation
• subdivision of geometry
• adds more triangles
• by default in the same plane as the original triangle, so doesn’t add more detail yet
Tessellation
• To get more detail, tessellate and:
• displace by sampling a displacement texture, or
• use Phong tessellation
• inflates the geometry and smooths the silhouette
Tessellation with surface shaders
• Use tessellate:FunctionName modifier in the surface shader declaration
• float FunctionName () { return tessAmount; }
• built-in
• UnityDistanceBasedTess
• tessellate more close to the camera
• UnityEdgeLengthBasedTess
• tessellate big triangles more
Random writes
• Unordered Access View
• for RenderTextures or ComputeBuffers
• allows writing at any position within the buffer
Random writes
• RenderTexture
• generally stores colors
• bajilion different formats
• ARGB32, ARGBHalf, ARGBFloat, R(8|Half|Float), etc.
Random writes
• ComputeBuffer (StructuredBuffer in DX11)
• stores structs or simple types
• could be color, of course
• int, float, you name it
Random writes
• Create a ComputeBuffer from script
• provide the count and the stride (size of one element in bytes)
• Initialize the contents using SetData()
• Set the buffer for a material using SetBuffer()
Random writes
• In the shader declare the buffer as
• StructuredBuffer<your_data_type>
• random reads
• RWStructuredBuffer<your_data_type>
• random reads and writes
Random writes example
• Image analysis
• run a shader on the scene render
• analyze each pixel and write to an output buffer at a location of your choice
• you can also atomically increment the value
• InterlockedAdd()
• requires a buffer of ints or uints though
Volume textures
• You know how textures are normally in 2D?!
• Now they are in 3D!
• BOOM
Volume textures
• How does DX 11 come into play?
• you can fill the volume texture from a compute shader really quickly (do it each frame?)
Volume textures example
• Fills in the volume texture based on dispatch thread ID*
• combined thread and thread group index
* Read up on semantics on MSDN
Questions?
• Kuba @kubacupisz
• Tim @stramit
Appendix
Multiple render targets
• In the shader do:
• void frag(v2f i, out float4 Colour0 : COLOR0, out float4 Colour1 : COLOR1) or
• make the pixel shader return a color array or
• make the pixel shader return a struct with COLOR0...COLORn semantics
Multiple render targets
• In the script do: (javascript)
// rt1, rt2, rt3, rt4 are RenderTextures
// create an array of color buffers
var mrt4 : RenderBuffer[] = [ rt1.colorBuffer, rt2.colorBuffer, rt3.colorBuffer, rt4.colorBuffer ];
// set those color buffers and the depth buffer from the first render texture as the current target
Graphics.SetRenderTarget (mrt4, rt1.depthBuffer);
// draw your stuff!
[...]

Weitere ähnliche Inhalte

Was ist angesagt?

Unite2013-gavilan-pdf
Unite2013-gavilan-pdfUnite2013-gavilan-pdf
Unite2013-gavilan-pdfDavid Gavilan
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnGuerrilla
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法Unite2017Tokyo
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engineDaosheng Mu
 
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説Unity Technologies Japan K.K.
 
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張Unite2017Tokyo
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine ArchitectureAttila Jenei
 
GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11smashflt
 
Checkerboard Rendering in Dark Souls: Remastered by QLOC
Checkerboard Rendering in Dark Souls: Remastered by QLOCCheckerboard Rendering in Dark Souls: Remastered by QLOC
Checkerboard Rendering in Dark Souls: Remastered by QLOCQLOC
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingElectronic Arts / DICE
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesBryan Duggan
 
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsNick Pruehs
 
BSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSides Delhi
 
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...Electronic Arts / DICE
 
Star Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processingStar Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processingumsl snfrzb
 
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among ThievesState-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among ThievesNaughty Dog
 
Starling Deep Dive
Starling Deep DiveStarling Deep Dive
Starling Deep DiveLee Brimelow
 

Was ist angesagt? (18)

Unite2013-gavilan-pdf
Unite2013-gavilan-pdfUnite2013-gavilan-pdf
Unite2013-gavilan-pdf
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero Dawn
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
 
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine Architecture
 
GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11
 
Checkerboard Rendering in Dark Souls: Remastered by QLOC
Checkerboard Rendering in Dark Souls: Remastered by QLOCCheckerboard Rendering in Dark Souls: Remastered by QLOC
Checkerboard Rendering in Dark Souls: Remastered by QLOC
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game Engines
 
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
 
BSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOS
 
Hair in Tomb Raider
Hair in Tomb RaiderHair in Tomb Raider
Hair in Tomb Raider
 
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
 
Star Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processingStar Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processing
 
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among ThievesState-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
 
Starling Deep Dive
Starling Deep DiveStarling Deep Dive
Starling Deep Dive
 

Ähnlich wie [UniteKorea2013] The Unity Rendering Pipeline

Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Unity Technologies
 
Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performanceCodemotion
 
Develop2012 deferred sanchez_stachowiak
Develop2012 deferred sanchez_stachowiakDevelop2012 deferred sanchez_stachowiak
Develop2012 deferred sanchez_stachowiakMatt Filer
 
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unity Technologies
 
Adding more visuals without affecting performance
Adding more visuals without affecting performanceAdding more visuals without affecting performance
Adding more visuals without affecting performanceSt1X
 
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014Mary Chan
 
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptLighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptCharlesMatu2
 
OpenGL - Bringing the 3D World into the Android
OpenGL - Bringing the 3D World into the AndroidOpenGL - Bringing the 3D World into the Android
OpenGL - Bringing the 3D World into the AndroidDroidConTLV
 
Introduction to frameworks
Introduction to frameworksIntroduction to frameworks
Introduction to frameworksb164739
 
04. introduction to frameworks
04. introduction to frameworks04. introduction to frameworks
04. introduction to frameworksdipalsoul
 
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureHow we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureFelipe Lira
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesEpic Games China
 
The Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for RaiosThe Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for RaiosDietmar Hauser
 
Software Engineer- A unity 3d Game
Software Engineer- A unity 3d GameSoftware Engineer- A unity 3d Game
Software Engineer- A unity 3d GameIsfand yar Khan
 
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣Unity Technologies Japan K.K.
 
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張Unity Technologies Japan K.K.
 

Ähnlich wie [UniteKorea2013] The Unity Rendering Pipeline (20)

Deferred shading
Deferred shadingDeferred shading
Deferred shading
 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
 
Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performance
 
Develop2012 deferred sanchez_stachowiak
Develop2012 deferred sanchez_stachowiakDevelop2012 deferred sanchez_stachowiak
Develop2012 deferred sanchez_stachowiak
 
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
 
Adding more visuals without affecting performance
Adding more visuals without affecting performanceAdding more visuals without affecting performance
Adding more visuals without affecting performance
 
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
 
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.pptLighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
Lighting & Shading in OpenGL Non-Photorealistic Rendering.ppt
 
OpenGL - Bringing the 3D World into the Android
OpenGL - Bringing the 3D World into the AndroidOpenGL - Bringing the 3D World into the Android
OpenGL - Bringing the 3D World into the Android
 
Introduction to frameworks
Introduction to frameworksIntroduction to frameworks
Introduction to frameworks
 
04. introduction to frameworks
04. introduction to frameworks04. introduction to frameworks
04. introduction to frameworks
 
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureHow we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
 
The Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for RaiosThe Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for Raios
 
InfectNet Technical
InfectNet TechnicalInfectNet Technical
InfectNet Technical
 
Software Engineer- A unity 3d Game
Software Engineer- A unity 3d GameSoftware Engineer- A unity 3d Game
Software Engineer- A unity 3d Game
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
 
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
 
november29.ppt
november29.pptnovember29.ppt
november29.ppt
 

Mehr von William Hugo Yang

[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android content[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android contentWilliam Hugo Yang
 
[UniteKorea2013] Serialization in Depth
[UniteKorea2013] Serialization in Depth[UniteKorea2013] Serialization in Depth
[UniteKorea2013] Serialization in DepthWilliam Hugo Yang
 
[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in UnityWilliam Hugo Yang
 
[UniteKorea2013] Unity Hacks
[UniteKorea2013] Unity Hacks[UniteKorea2013] Unity Hacks
[UniteKorea2013] Unity HacksWilliam Hugo Yang
 
[UniteKorea2013] Butterfly Effect DX11
[UniteKorea2013] Butterfly Effect DX11[UniteKorea2013] Butterfly Effect DX11
[UniteKorea2013] Butterfly Effect DX11William Hugo Yang
 
[UniteKorea2013] Art tips and tricks
[UniteKorea2013] Art tips and tricks[UniteKorea2013] Art tips and tricks
[UniteKorea2013] Art tips and tricksWilliam Hugo Yang
 
[UniteKorea2013] 2D content workflows
[UniteKorea2013] 2D content workflows[UniteKorea2013] 2D content workflows
[UniteKorea2013] 2D content workflowsWilliam Hugo Yang
 

Mehr von William Hugo Yang (7)

[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android content[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android content
 
[UniteKorea2013] Serialization in Depth
[UniteKorea2013] Serialization in Depth[UniteKorea2013] Serialization in Depth
[UniteKorea2013] Serialization in Depth
 
[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity
 
[UniteKorea2013] Unity Hacks
[UniteKorea2013] Unity Hacks[UniteKorea2013] Unity Hacks
[UniteKorea2013] Unity Hacks
 
[UniteKorea2013] Butterfly Effect DX11
[UniteKorea2013] Butterfly Effect DX11[UniteKorea2013] Butterfly Effect DX11
[UniteKorea2013] Butterfly Effect DX11
 
[UniteKorea2013] Art tips and tricks
[UniteKorea2013] Art tips and tricks[UniteKorea2013] Art tips and tricks
[UniteKorea2013] Art tips and tricks
 
[UniteKorea2013] 2D content workflows
[UniteKorea2013] 2D content workflows[UniteKorea2013] 2D content workflows
[UniteKorea2013] 2D content workflows
 

Kürzlich hochgeladen

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Kürzlich hochgeladen (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

[UniteKorea2013] The Unity Rendering Pipeline

  • 1. The Unity Rendering Pipeline Kuba Cupisz (Tim Cooper) Texthttp://is.gd/RenderingPipeline_UniteAsia13
  • 2. Who am I? • Kuba • graphics programmer • at Unity for... quite.some.time • worked on small game projects before
  • 3. Topics What Unity is good/bad at Built-in shaders Shader combinations Per material keywords Lit shader replace Endless runner with light probes DX 11 Tessellation Random writes Volume textures
  • 4. What is Unity good at • Very flexible rendering pipeline • vertex lit / forward / deferred • custom shaders • custom lighting models • completely customizable
  • 5. What is Unity bad at • Very flexible rendering pipeline • difficult to configure (so.many.options) • Some parts are better maintained then others • dual lightmaps in forward • Default settings do not suit all projects • very general, scale from mobile to high end • aim your configuration at your target
  • 6. Built-in shaders - good for • Work with all rendering configurations • forward / deferred, realtime lighting / lightmaps • Support standard lighting models • lambert / blinn-phong • Work on all platforms
  • 7. Built-in shaders - not good for • Stylized games • only provide ‘standard’ lighting models • Super-performance • if you know how your game will look, you can write more specific (faster) shaders • Size • always have many shader variants due to supporting many possible configurations
  • 8. When to write your own? • When the built-in shaders • are not custom enough • are not fast enough - don’t assume, profile! • you know exactly how you want your game to be rendered
  • 9. Shader combinations • Compile variants of your shader • to do different things based on keywords • shader keywords are set globally • can be overridden per material
  • 10. Shader combinations • Each line declares a set of defines • only one per line can be active at a time • Make sure you enable one, otherwise Unity will pick one for you
  • 11. Shader combinations #pragma multi_compile AAA BBB • two variants • one where AAA is defined • another where BBB is defined (and AAA is not)
  • 12. Shader combinations #pragma multi_compile AAA BBB #pragma multi_compile CCC • two variants • AAA CCC • BBB CCC
  • 13. Shader combinations #pragma multi_compile AAA BBB #pragma multi_compile CCC DDD • four variants • AAA CCC • BBB CCC • AAA DDD • BBB DDD
  • 14. Per material keywords • Shader keywords property on a material • array of strings • each string a keyword • Write a custom editor to make it easy to use
  • 15. Material inspector • Extend the MaterialEditor class • Override OnInspectorGUI() • remember to call base.OnInspectorGUI() !
  • 16. Shader combinations example • Surface shader • 2 defines • 1 for darken blend mode • 1 for difference blend mode • configured via material inspector
  • 17. Shader combinations • Applications • switch the shaders in your scene via a keyword • completely change the look of your game • in the future • one shader for: diffuse, specular, normal maps, etc.
  • 18. Shader replace • Objects normally get rendered with whatever material /shader is configured on them • Using shader replace you can swap out the shader • still uses same material (so textures / properties will be the same as in the original rendering) • Sub-shader is selected based on tag-matching
  • 19. Shader replace - Tags • When setting a replacement shader, you can set the tag • Camera.SetReplacementShader (Shader s, string tag) • Camera.RenderWithShader (Shader s, string tag)
  • 20. Shader replace - Tags • No tag specified? • all objects will be rendered with the replacement shader • uses the first subshader of the replacement shader
  • 21. Shader replace - Tags • Tag set? • the real object’s shader is queried for the tag value • no matching tag? • not rendered • tag found? • subshader from the replacement shader selected which matches the tag
  • 22. Tags • Builtin, e.g. RenderType: • Opaque • Transparent • TransparentCutout • etc. • Custom • whatever you want!
  • 23. Lit-Shader replacement • New in Unity 4.1 • Useful for • scene view enhancement • special effects • How does it work? • just like normal shader replace! • but you can use shaders that have lighting passes (surface shaders!)
  • 24. Endless runner with light probes • The track is assembled from blocks • Any block can be matched with any other block • It’s not feasible to bake light probes for all the combinations of block setups
  • 25. Endless runner with light probes • Bake light probes for each block separately • After baking, light probes are tetrahedralized • When the player moves from one block to the other you want to switch to light probes for the new block • set Lightmapping.lightProbes
  • 26. Smooth transition • Just switching from one light probe set to another will give a pop • Solution: • make sure that start and end light probe positions have the same layout • when loading the new probes, set the start probes in the new set to the end probes of the previous set
  • 27. Smooth transition • Transition distance • add another set of light probes relatively closely to the start probes to control the transition distance
  • 28. Baked data is not movable • Loaded light probes will show up at the positions where they were baked • in our case the blocks’ pivots are at (0,0,0) • If you’d use player’s position to sample light probes you’d sample outside of the volume defined by the probes -- not good
  • 29. Baked data is not movable • Luckily you can set lightProbeAnchor on the renderer to a transform of choice • Parent the transform under the player • Set local offset to -currentBlocksOffset on block change
  • 30. DX 11 • Gives you more flexibility • Allows for techniques that were impossible to do on the GPU before and not feasible on the CPU
  • 31. Tessellation • What is tessellation • subdivision of geometry • adds more triangles • by default in the same plane as the original triangle, so doesn’t add more detail yet
  • 32. Tessellation • To get more detail, tessellate and: • displace by sampling a displacement texture, or • use Phong tessellation • inflates the geometry and smooths the silhouette
  • 33. Tessellation with surface shaders • Use tessellate:FunctionName modifier in the surface shader declaration • float FunctionName () { return tessAmount; } • built-in • UnityDistanceBasedTess • tessellate more close to the camera • UnityEdgeLengthBasedTess • tessellate big triangles more
  • 34. Random writes • Unordered Access View • for RenderTextures or ComputeBuffers • allows writing at any position within the buffer
  • 35. Random writes • RenderTexture • generally stores colors • bajilion different formats • ARGB32, ARGBHalf, ARGBFloat, R(8|Half|Float), etc.
  • 36. Random writes • ComputeBuffer (StructuredBuffer in DX11) • stores structs or simple types • could be color, of course • int, float, you name it
  • 37. Random writes • Create a ComputeBuffer from script • provide the count and the stride (size of one element in bytes) • Initialize the contents using SetData() • Set the buffer for a material using SetBuffer()
  • 38. Random writes • In the shader declare the buffer as • StructuredBuffer<your_data_type> • random reads • RWStructuredBuffer<your_data_type> • random reads and writes
  • 39. Random writes example • Image analysis • run a shader on the scene render • analyze each pixel and write to an output buffer at a location of your choice • you can also atomically increment the value • InterlockedAdd() • requires a buffer of ints or uints though
  • 40. Volume textures • You know how textures are normally in 2D?! • Now they are in 3D! • BOOM
  • 41. Volume textures • How does DX 11 come into play? • you can fill the volume texture from a compute shader really quickly (do it each frame?)
  • 42. Volume textures example • Fills in the volume texture based on dispatch thread ID* • combined thread and thread group index * Read up on semantics on MSDN
  • 45. Multiple render targets • In the shader do: • void frag(v2f i, out float4 Colour0 : COLOR0, out float4 Colour1 : COLOR1) or • make the pixel shader return a color array or • make the pixel shader return a struct with COLOR0...COLORn semantics
  • 46. Multiple render targets • In the script do: (javascript) // rt1, rt2, rt3, rt4 are RenderTextures // create an array of color buffers var mrt4 : RenderBuffer[] = [ rt1.colorBuffer, rt2.colorBuffer, rt3.colorBuffer, rt4.colorBuffer ]; // set those color buffers and the depth buffer from the first render texture as the current target Graphics.SetRenderTarget (mrt4, rt1.depthBuffer); // draw your stuff! [...]