SlideShare a Scribd company logo
GLOBAL SOFTWARE CONSULTANCY
Shaders and the Black Magic
Raju Kandaswamy
1© 2020 ThoughtWorks
Welcome to Hogwarts - Intro to Shaders
● Shaders are little scriptlets which are executed in the GPU to
render the content to the screen [Framebuffer]
● Primarily intended to manipulate the input/output pixels (colors),
vertex, surface (tessellate)
● 2D Shaders (Image), 3D Shaders (Geometry)
● Unlike CPU, GPU executes shaders scripts in its array of parallel
pipelines
● A 2018 Macbook Pro’s GPU contains 1024 cores where as CPU
contains only 6 cores.
● Shaders are perfect candidates for Image processing and
computer vision
● Many variants of Shader programming languages available such as
GLSL, HLSL and others
● Unity uses a variant of HLSL
2© 2020 ThoughtWorks
The Book of shaders
● The Vertex
● The Geometry / Primitives
● The Fragment
● The Colored Pixel
3© 2020 ThoughtWorks
House of Colors at Hogwarts
4
RGB(A) HSV YUV
● All color components are represented between 0 to 1
● Fragments deal with pixel colors
● Shader scripts manipulate color components
● Need to convert to different house of colors for some operations
● Final output must be in RGB
0
1
Interpolations for the magic wand
5
0
1
0.3
0.6
Shader primitives for effective Spells
● Color (RGB, RGBA) - float3, float4
● Vertex - float3
● UV - float2
● tex2D - Sampler
● Arithmetic primitives - + - * / %
● Math primitives - max, min, sin, cos
● Matrix - float2x2, float3x3
6© 2020 ThoughtWorks
U
V
Shader Graph - The art of making potions
7© 2020 ThoughtWorks
● LWRP & HDRP projects in Unity
● Graph
● Node
● Slots
● Binding
● Function
● Material
● Input Parameters
● Custom Nodes
Lifting the Invisible Cloak
8© 2020 ThoughtWorks
● 3x3 Filter Kernels
○ Gaussian Blur
○ Sharpen
○ Edge detection
■ Sobel
■ Canny
Tone mapping and Transfiguration
9© 2020 ThoughtWorks
● Transform one set of Colors to Other
○ Simple Reinhard
○ Adaptive Reinhard
○ Filmic
Potion Mixing Room of Hogwarts
10© 2020 ThoughtWorks
● www.shadertoy.com
Render Script & Mystery of
performance
11© 2020 ThoughtWorks
Android’s Sibling of Shaders
● Get the images processed by CPU/GPU/DSP in Java / Kotlin code
● No NDK ot JNI pain
● .rs gets compiled into Java Classes
● ForEach and Fragments
● uchar4
● rsUnpackColor8888 -> float4
● rsPackColor8888 -> uchar4
12© 2020 ThoughtWorks
Thank You
13

More Related Content

PPT
Measuring SGX Texturing Performance
PPTX
Using Shader in cocos2d-x
PPTX
Baiscs of OpenGL
PPTX
Computer Graphics Project on Sinking Ship using OpenGL
PPTX
Graphics in C++
PPTX
Graphics Programming in C
PDF
Graphics Programming in C under GNU Linux (Ubuntu distribution)
PDF
Shortest Path search in your Database and more with pgRouting - FOSS4G Europe...
Measuring SGX Texturing Performance
Using Shader in cocos2d-x
Baiscs of OpenGL
Computer Graphics Project on Sinking Ship using OpenGL
Graphics in C++
Graphics Programming in C
Graphics Programming in C under GNU Linux (Ubuntu distribution)
Shortest Path search in your Database and more with pgRouting - FOSS4G Europe...

Similar to Shaders and the black magic (20)

PDF
Smedberg niklas bringing_aaa_graphics
PDF
High Performance Rust UI.pdf
PDF
Computer Graphics - Lecture 01 - 3D Programming I
PDF
mloc.js 2014 - JavaScript and the browser as a platform for game development
PDF
PSGL (PlayStation Graphics Library)
PDF
Metail Skin Colour Authoring Tool
PDF
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
PPTX
How the Universal Render Pipeline unlocks games for you - Unite Copenhagen 2019
PDF
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
PDF
The rendering technology of 'lords of the fallen' philip hammer
PDF
Open gl
PDF
Rendering Tech of Space Marine
PDF
Dissecting the Rendering of The Surge
PDF
Unity: Next Level Rendering Quality
PDF
【Unite 2018 Tokyo】スクリプタブルレンダーパイプライン入門
ODP
Advanced Linux Game Programming
PDF
COSCUP 2023 - Make Your Own Ray Tracing GPU with FPGA
PPTX
Graphics Libraries
PPT
Programmable Piplelines
PDF
High performance graphics and computation - OpenGL ES and RenderScript
Smedberg niklas bringing_aaa_graphics
High Performance Rust UI.pdf
Computer Graphics - Lecture 01 - 3D Programming I
mloc.js 2014 - JavaScript and the browser as a platform for game development
PSGL (PlayStation Graphics Library)
Metail Skin Colour Authoring Tool
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
How the Universal Render Pipeline unlocks games for you - Unite Copenhagen 2019
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The rendering technology of 'lords of the fallen' philip hammer
Open gl
Rendering Tech of Space Marine
Dissecting the Rendering of The Surge
Unity: Next Level Rendering Quality
【Unite 2018 Tokyo】スクリプタブルレンダーパイプライン入門
Advanced Linux Game Programming
COSCUP 2023 - Make Your Own Ray Tracing GPU with FPGA
Graphics Libraries
Programmable Piplelines
High performance graphics and computation - OpenGL ES and RenderScript
Ad

Recently uploaded (20)

PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Encapsulation theory and applications.pdf
PDF
August Patch Tuesday
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Zenith AI: Advanced Artificial Intelligence
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
OMC Textile Division Presentation 2021.pptx
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Encapsulation theory and applications.pdf
August Patch Tuesday
1 - Historical Antecedents, Social Consideration.pdf
WOOl fibre morphology and structure.pdf for textiles
A comparative study of natural language inference in Swahili using monolingua...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
TLE Review Electricity (Electricity).pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
NewMind AI Weekly Chronicles - August'25-Week II
SOPHOS-XG Firewall Administrator PPT.pptx
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Zenith AI: Advanced Artificial Intelligence
Ad

Shaders and the black magic

  • 1. GLOBAL SOFTWARE CONSULTANCY Shaders and the Black Magic Raju Kandaswamy 1© 2020 ThoughtWorks
  • 2. Welcome to Hogwarts - Intro to Shaders ● Shaders are little scriptlets which are executed in the GPU to render the content to the screen [Framebuffer] ● Primarily intended to manipulate the input/output pixels (colors), vertex, surface (tessellate) ● 2D Shaders (Image), 3D Shaders (Geometry) ● Unlike CPU, GPU executes shaders scripts in its array of parallel pipelines ● A 2018 Macbook Pro’s GPU contains 1024 cores where as CPU contains only 6 cores. ● Shaders are perfect candidates for Image processing and computer vision ● Many variants of Shader programming languages available such as GLSL, HLSL and others ● Unity uses a variant of HLSL 2© 2020 ThoughtWorks
  • 3. The Book of shaders ● The Vertex ● The Geometry / Primitives ● The Fragment ● The Colored Pixel 3© 2020 ThoughtWorks
  • 4. House of Colors at Hogwarts 4 RGB(A) HSV YUV ● All color components are represented between 0 to 1 ● Fragments deal with pixel colors ● Shader scripts manipulate color components ● Need to convert to different house of colors for some operations ● Final output must be in RGB 0 1
  • 5. Interpolations for the magic wand 5 0 1 0.3 0.6
  • 6. Shader primitives for effective Spells ● Color (RGB, RGBA) - float3, float4 ● Vertex - float3 ● UV - float2 ● tex2D - Sampler ● Arithmetic primitives - + - * / % ● Math primitives - max, min, sin, cos ● Matrix - float2x2, float3x3 6© 2020 ThoughtWorks U V
  • 7. Shader Graph - The art of making potions 7© 2020 ThoughtWorks ● LWRP & HDRP projects in Unity ● Graph ● Node ● Slots ● Binding ● Function ● Material ● Input Parameters ● Custom Nodes
  • 8. Lifting the Invisible Cloak 8© 2020 ThoughtWorks ● 3x3 Filter Kernels ○ Gaussian Blur ○ Sharpen ○ Edge detection ■ Sobel ■ Canny
  • 9. Tone mapping and Transfiguration 9© 2020 ThoughtWorks ● Transform one set of Colors to Other ○ Simple Reinhard ○ Adaptive Reinhard ○ Filmic
  • 10. Potion Mixing Room of Hogwarts 10© 2020 ThoughtWorks ● www.shadertoy.com
  • 11. Render Script & Mystery of performance 11© 2020 ThoughtWorks
  • 12. Android’s Sibling of Shaders ● Get the images processed by CPU/GPU/DSP in Java / Kotlin code ● No NDK ot JNI pain ● .rs gets compiled into Java Classes ● ForEach and Fragments ● uchar4 ● rsUnpackColor8888 -> float4 ● rsPackColor8888 -> uchar4 12© 2020 ThoughtWorks