SlideShare a Scribd company logo
1 of 21
Working with shader
What is a Shader ?
A shader is a program that runs in the graphics
pipeline in CPU and tells the computer how to
render each pixel.
These programs are called shaders because
they're often used to control lighting and
shading, but they also can handle other special
effects.
Minecraft before and after shader
Graphic rendering pipeline
Consists of six stages:
1. Per-Vertex Operation
2. Primitive Assembly
3. Primitive Processing
4. Rasterization
5. Fragment Processing
Per-Vertex Operation
Transform from the local coordinate
system to the 3d world coordinate
system. A model of a teapot in
abstract is placed in the coordinate
system of the 3d world.
Vertex shader comes here.
Per Vertex Operation - Lighting and shading is programmable
Primitive Assembly
Traditionally this is done using
triangles, as a result a primitive is
assembled, e.g. a triangle.
Primitive Assembly
Primitive Processing
Geometric primitives that now fall
completely outside of the viewing
frustum will not be visible and are
discarded at this stage.
Primitive Processing
Rasterization
Primitives are then broken down into
smaller units, corresponding to pixels
in the framebuffer. Each of these
smaller units are called Fragments.
Fragment shader comes after here.
Rasterization
Fragment Processing
Once the primitive has been
rasterized, color/texture is applied to
the geometry.
Fragment Processing
Per-Fragment Operation
Fragments are submitted to tests:
1. Pixel Ownership - not customizable by applications
2. Scissor - fails if fragment is outside of a specified rectangle
3. Alpha - outcome depends on alpha of the fragment
4. Stencil - outcome depends on value in stencil buffer
5. Depth - outcome depends on depth of fragment
6. Blending - outcome depends on fragment color
7. Dithering - not customizable by applications
8. Logical operations - outcome depends on color of
fragment
Per-Fragment Operation - usually configurable but not programmable
The ultimate goal of the Vertex Shader is to
provide the final transformation of the mesh
vertices to the rendering pipeline.
Vertex Shader
Vertex Shader pipeline
The goal of the Fragment shader is to provide
Coloring and Texture data to each pixel
heading to the framebuffer.
A framebuffer is a bitmap that is used to
refresh a display from a memory buffer
containing a complete frame of data.
Fragment/Pixel Shader
Pixel shader pipeline
MSAA - each pixel at the edge of a polygon is sampled multiple times. For each
sample-pass, a slight offset is applied to all screen coordinates.

More Related Content

Similar to Working with Shader with Unity

OpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUOpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUJiansong Chen
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for GamesUmbra
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for GamesSampo Lappalainen
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicschangehee lee
 
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiMaking High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiUnreal Engine
 
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiMaking High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiLuis Cataldi
 
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"Harshil Gupta
 
Hardware software co simulation of edge detection for image processing system...
Hardware software co simulation of edge detection for image processing system...Hardware software co simulation of edge detection for image processing system...
Hardware software co simulation of edge detection for image processing system...eSAT Publishing House
 
Overview of Graphics System
Overview of Graphics SystemOverview of Graphics System
Overview of Graphics SystemPrathimaBaliga
 
Demosaic RTL for ISP workflow
Demosaic RTL for ISP workflowDemosaic RTL for ISP workflow
Demosaic RTL for ISP workflowMaikon
 
11_Saloni Malhotra_SummerTraining_PPT.pptx
11_Saloni Malhotra_SummerTraining_PPT.pptx11_Saloni Malhotra_SummerTraining_PPT.pptx
11_Saloni Malhotra_SummerTraining_PPT.pptxSaloniMalhotra23
 
FGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie TycoonFGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie Tycoonmochimedia
 
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio [Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio Owen Wu
 
Clean architecture for shaders unite2019
Clean architecture for shaders unite2019Clean architecture for shaders unite2019
Clean architecture for shaders unite2019Abhilash Majumder
 
Video Stitching using Improved RANSAC and SIFT
Video Stitching using Improved RANSAC and SIFTVideo Stitching using Improved RANSAC and SIFT
Video Stitching using Improved RANSAC and SIFTIRJET Journal
 
A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...
A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...
A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...sipij
 

Similar to Working with Shader with Unity (20)

OpenGL ES and Mobile GPU
OpenGL ES and Mobile GPUOpenGL ES and Mobile GPU
OpenGL ES and Mobile GPU
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for Games
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for Games
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiMaking High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
 
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis CataldiMaking High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
 
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
 
Chapter-3.pdf
Chapter-3.pdfChapter-3.pdf
Chapter-3.pdf
 
Hardware software co simulation of edge detection for image processing system...
Hardware software co simulation of edge detection for image processing system...Hardware software co simulation of edge detection for image processing system...
Hardware software co simulation of edge detection for image processing system...
 
Overview of Graphics System
Overview of Graphics SystemOverview of Graphics System
Overview of Graphics System
 
Demosaic RTL for ISP workflow
Demosaic RTL for ISP workflowDemosaic RTL for ISP workflow
Demosaic RTL for ISP workflow
 
11_Saloni Malhotra_SummerTraining_PPT.pptx
11_Saloni Malhotra_SummerTraining_PPT.pptx11_Saloni Malhotra_SummerTraining_PPT.pptx
11_Saloni Malhotra_SummerTraining_PPT.pptx
 
A0280105
A0280105A0280105
A0280105
 
FGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie TycoonFGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie Tycoon
 
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio [Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
 
Clean architecture for shaders unite2019
Clean architecture for shaders unite2019Clean architecture for shaders unite2019
Clean architecture for shaders unite2019
 
All projects
All projectsAll projects
All projects
 
Video Stitching using Improved RANSAC and SIFT
Video Stitching using Improved RANSAC and SIFTVideo Stitching using Improved RANSAC and SIFT
Video Stitching using Improved RANSAC and SIFT
 
A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...
A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...
A Smart Camera Processing Pipeline for Image Applications Utilizing Marching ...
 

Recently uploaded

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Working with Shader with Unity

  • 2. What is a Shader ? A shader is a program that runs in the graphics pipeline in CPU and tells the computer how to render each pixel. These programs are called shaders because they're often used to control lighting and shading, but they also can handle other special effects.
  • 3. Minecraft before and after shader
  • 4. Graphic rendering pipeline Consists of six stages: 1. Per-Vertex Operation 2. Primitive Assembly 3. Primitive Processing 4. Rasterization 5. Fragment Processing
  • 5. Per-Vertex Operation Transform from the local coordinate system to the 3d world coordinate system. A model of a teapot in abstract is placed in the coordinate system of the 3d world. Vertex shader comes here.
  • 6. Per Vertex Operation - Lighting and shading is programmable
  • 7. Primitive Assembly Traditionally this is done using triangles, as a result a primitive is assembled, e.g. a triangle.
  • 9. Primitive Processing Geometric primitives that now fall completely outside of the viewing frustum will not be visible and are discarded at this stage.
  • 11. Rasterization Primitives are then broken down into smaller units, corresponding to pixels in the framebuffer. Each of these smaller units are called Fragments. Fragment shader comes after here.
  • 13. Fragment Processing Once the primitive has been rasterized, color/texture is applied to the geometry.
  • 15. Per-Fragment Operation Fragments are submitted to tests: 1. Pixel Ownership - not customizable by applications 2. Scissor - fails if fragment is outside of a specified rectangle 3. Alpha - outcome depends on alpha of the fragment 4. Stencil - outcome depends on value in stencil buffer 5. Depth - outcome depends on depth of fragment 6. Blending - outcome depends on fragment color 7. Dithering - not customizable by applications 8. Logical operations - outcome depends on color of fragment
  • 16. Per-Fragment Operation - usually configurable but not programmable
  • 17. The ultimate goal of the Vertex Shader is to provide the final transformation of the mesh vertices to the rendering pipeline. Vertex Shader
  • 19. The goal of the Fragment shader is to provide Coloring and Texture data to each pixel heading to the framebuffer. A framebuffer is a bitmap that is used to refresh a display from a memory buffer containing a complete frame of data. Fragment/Pixel Shader
  • 21. MSAA - each pixel at the edge of a polygon is sampled multiple times. For each sample-pass, a slight offset is applied to all screen coordinates.