SlideShare a Scribd company logo
1 of 16
Writing Shaders
YOU can do it!
Unite Boston 2015
● Yılmaz Kıymaz
● Unity developer for 7 years
● Shader enthusiast
● Software Development Engineer
at Nordeus
WRITING SHADERS
YOU CAN DO IT!
NORDEUS
Belgrade based
WRITING SHADERS
YOU CAN DO IT!
Developer of Top Eleven
Shaders are
WRITING SHADERS
YOU CAN DO IT!
scary!interesting
Weird terminology Unfamiliar math and data Runs on the GPU!?
Vertices, fragments
Vectors, matrices, textures
Cross product
Dot product
Matrix multiplication
Primitive assembly
Rasterization
ZWrite
Cull
Stencil
Massively parallelized
Different performance
criteria
Different constraints
Run away?
Learn all of it?
Actually...
You don't need to
worry about this
WRITING SHADERS
YOU CAN DO IT!
Experiment Fail Learn Repeat
Attend this talk Learn Profit!
What are shaders?
WRITING SHADERS
YOU CAN DO IT!
Shader GPU ImageInput
Mesh
Material Data
Lighting Data
and more
How do they work?
WRITING SHADERS
YOU CAN DO IT!
Shader Languages
WRITING SHADERS
YOU CAN DO IT!
HLSL GLSL CG
OpenGL Shading Language
OpenGL ARB (Architecture
Review Board)
OpenGL
Windows, Mac, Linux, iOS,
Android and more
High Level Shading
Language
Microsoft
DirectX
Windows, XBox
C for Graphics
Nvidia
DirectX & OpenGL
Deprecated but...
Thanks to Unity,
covers all platforms
ShaderLab
WRITING SHADERS
YOU CAN DO IT!
Unity specific shading and material language
All shaders written in Unity must be wrapped with ShaderLab
May seem like extra work but it's actually saving you from a lot more work
Dive into Unity
WRITING SHADERS
YOU CAN DO IT!
Diffuse
WRITING SHADERS
YOU CAN DO IT!
Specular
● Unity Manual
● Nvidia CG Tutorial
● CG Programming in Unity wikibook
● Video tutorial series on YouTube
● ShaderToy
● Aras' blog - aras-p.info/blog
● LearnOpenGL.com
● RealTimeRendering.com
● Many more at
RESOURCES
WRITING SHADERS
YOU CAN DO IT!
norde.us/unitewritingshaders
● Shader languages
● Shaders in Unity (ShaderLab)
● Vertex and Fragment Programs
● Lighting calculations
● Resources
RECAP
WRITING SHADERS
YOU CAN DO IT!
● yilmazk@nordeus.eu
● @VoxelBoy
● norde.us/unitewritingshaders
Q&A
WRITING SHADERS
YOU CAN DO IT!
THANK YOU!
WRITING SHADERS
YOU CAN DO IT!

More Related Content

What's hot

Designing an Objective-C Framework about 3D
Designing an Objective-C Framework about 3DDesigning an Objective-C Framework about 3D
Designing an Objective-C Framework about 3D
rsebbe
 

What's hot (9)

OpenGLES Android Graphics
OpenGLES Android GraphicsOpenGLES Android Graphics
OpenGLES Android Graphics
 
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...
 
Virtual Reality Modeling Language
Virtual Reality Modeling LanguageVirtual Reality Modeling Language
Virtual Reality Modeling Language
 
Xtext, diagrams and ux
Xtext, diagrams and uxXtext, diagrams and ux
Xtext, diagrams and ux
 
K2P workshop 3-23-13
K2P workshop 3-23-13K2P workshop 3-23-13
K2P workshop 3-23-13
 
Designing an Objective-C Framework about 3D
Designing an Objective-C Framework about 3DDesigning an Objective-C Framework about 3D
Designing an Objective-C Framework about 3D
 
Clean architecture for shaders unite2019
Clean architecture for shaders unite2019Clean architecture for shaders unite2019
Clean architecture for shaders unite2019
 
Diagrams, Xtext and UX
Diagrams, Xtext and UXDiagrams, Xtext and UX
Diagrams, Xtext and UX
 

Viewers also liked

Belgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UI
Belgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UIBelgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UI
Belgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UI
Nordeus
 
Nordeus for startit november 2012
Nordeus for startit   november 2012Nordeus for startit   november 2012
Nordeus for startit november 2012
Startit
 

Viewers also liked (19)

Unite2014: Mastering Physically Based Shading in Unity 5
Unite2014: Mastering Physically Based Shading in Unity 5Unite2014: Mastering Physically Based Shading in Unity 5
Unite2014: Mastering Physically Based Shading in Unity 5
 
Artists in gaming industry & at Nordeus
Artists in gaming industry & at NordeusArtists in gaming industry & at Nordeus
Artists in gaming industry & at Nordeus
 
Improving your KPIs with push notifications
Improving your KPIs with push notificationsImproving your KPIs with push notifications
Improving your KPIs with push notifications
 
Mobile optimization techniques
Mobile optimization techniquesMobile optimization techniques
Mobile optimization techniques
 
Early Churn Prediction and Personalised Interventions in Top Eleven game
Early Churn Prediction and Personalised Interventions in Top Eleven gameEarly Churn Prediction and Personalised Interventions in Top Eleven game
Early Churn Prediction and Personalised Interventions in Top Eleven game
 
An Introduction to Writing Custom Unity Shaders!
An Introduction to Writing  Custom Unity Shaders!An Introduction to Writing  Custom Unity Shaders!
An Introduction to Writing Custom Unity Shaders!
 
Belgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UI
Belgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UIBelgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UI
Belgrade Behance Reviews 2014 - Nordeus - Top Eleven UX/UI
 
Miloš Milošević, Nordeus
Miloš Milošević, NordeusMiloš Milošević, Nordeus
Miloš Milošević, Nordeus
 
Nordeus top eleven ux+ui
Nordeus top eleven ux+uiNordeus top eleven ux+ui
Nordeus top eleven ux+ui
 
Nordeus for startit november 2012
Nordeus for startit   november 2012Nordeus for startit   november 2012
Nordeus for startit november 2012
 
Top Eleven: The road to the Top via emerging markets - Nikola Cavic - Game Co...
Top Eleven: The road to the Top via emerging markets - Nikola Cavic - Game Co...Top Eleven: The road to the Top via emerging markets - Nikola Cavic - Game Co...
Top Eleven: The road to the Top via emerging markets - Nikola Cavic - Game Co...
 
Nordeus - Hackathon Nis presentation
Nordeus - Hackathon Nis presentationNordeus - Hackathon Nis presentation
Nordeus - Hackathon Nis presentation
 
Unity Surface Shader for Artist 03
Unity Surface Shader for Artist 03Unity Surface Shader for Artist 03
Unity Surface Shader for Artist 03
 
ENEI16 - WebGL with Three.js
ENEI16 - WebGL with Three.jsENEI16 - WebGL with Three.js
ENEI16 - WebGL with Three.js
 
Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
 
Dejan Pekter / Nordeus – Reactor design pattern
Dejan Pekter / Nordeus – Reactor design patternDejan Pekter / Nordeus – Reactor design pattern
Dejan Pekter / Nordeus – Reactor design pattern
 
유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석
 
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
 

Similar to Writing shaders - YOU can do it!

No Delay Software Company Overview
No Delay Software Company OverviewNo Delay Software Company Overview
No Delay Software Company Overview
NoDelay Software
 

Similar to Writing shaders - YOU can do it! (20)

GPU Programming 360iDev
GPU Programming 360iDevGPU Programming 360iDev
GPU Programming 360iDev
 
Fusing AI With AR for Android - 9/28/2019
Fusing AI With AR for Android - 9/28/2019Fusing AI With AR for Android - 9/28/2019
Fusing AI With AR for Android - 9/28/2019
 
Shibboleth Scripting – Domain Specific Languages in Games
Shibboleth Scripting – Domain Specific Languages in GamesShibboleth Scripting – Domain Specific Languages in Games
Shibboleth Scripting – Domain Specific Languages in Games
 
Introduction to Game-Making Tools
Introduction to Game-Making ToolsIntroduction to Game-Making Tools
Introduction to Game-Making Tools
 
Gpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and MetalGpu Programming With GPUImage and Metal
Gpu Programming With GPUImage and Metal
 
Hackathon Slides
Hackathon SlidesHackathon Slides
Hackathon Slides
 
Embracing Uncertainty: Learning to Think Responsively
Embracing Uncertainty: Learning to Think ResponsivelyEmbracing Uncertainty: Learning to Think Responsively
Embracing Uncertainty: Learning to Think Responsively
 
Metail Skin Colour Authoring Tool
Metail Skin Colour Authoring ToolMetail Skin Colour Authoring Tool
Metail Skin Colour Authoring Tool
 
UI/UX: Building Player Experiences
UI/UX: Building Player ExperiencesUI/UX: Building Player Experiences
UI/UX: Building Player Experiences
 
Serverless ddd
Serverless dddServerless ddd
Serverless ddd
 
Introduction To Game Programming
Introduction To Game ProgrammingIntroduction To Game Programming
Introduction To Game Programming
 
Graphical password ppt
Graphical password pptGraphical password ppt
Graphical password ppt
 
GPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf AtlantaGPU Programming: CocoaConf Atlanta
GPU Programming: CocoaConf Atlanta
 
Making A Game Engine Is Easier Than You Think
Making A Game Engine Is Easier Than You ThinkMaking A Game Engine Is Easier Than You Think
Making A Game Engine Is Easier Than You Think
 
No Delay Software Company Overview
No Delay Software Company OverviewNo Delay Software Company Overview
No Delay Software Company Overview
 
Brief Introduction to Spectacular
Brief Introduction to SpectacularBrief Introduction to Spectacular
Brief Introduction to Spectacular
 
Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...
Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...
Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...
 
Game Design
Game DesignGame Design
Game Design
 
Key Differences Between Node JS vs JavaScript.pdf
Key Differences Between Node JS vs JavaScript.pdfKey Differences Between Node JS vs JavaScript.pdf
Key Differences Between Node JS vs JavaScript.pdf
 
Next-gen IDE v2 - OpenSlava 2013-10-11
Next-gen IDE v2 - OpenSlava 2013-10-11Next-gen IDE v2 - OpenSlava 2013-10-11
Next-gen IDE v2 - OpenSlava 2013-10-11
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 

Writing shaders - YOU can do it!

  • 1. Writing Shaders YOU can do it! Unite Boston 2015
  • 2. ● Yılmaz Kıymaz ● Unity developer for 7 years ● Shader enthusiast ● Software Development Engineer at Nordeus WRITING SHADERS YOU CAN DO IT!
  • 3. NORDEUS Belgrade based WRITING SHADERS YOU CAN DO IT! Developer of Top Eleven
  • 4. Shaders are WRITING SHADERS YOU CAN DO IT! scary!interesting Weird terminology Unfamiliar math and data Runs on the GPU!? Vertices, fragments Vectors, matrices, textures Cross product Dot product Matrix multiplication Primitive assembly Rasterization ZWrite Cull Stencil Massively parallelized Different performance criteria Different constraints
  • 5. Run away? Learn all of it? Actually... You don't need to worry about this
  • 6. WRITING SHADERS YOU CAN DO IT! Experiment Fail Learn Repeat Attend this talk Learn Profit!
  • 7. What are shaders? WRITING SHADERS YOU CAN DO IT! Shader GPU ImageInput Mesh Material Data Lighting Data and more
  • 8. How do they work? WRITING SHADERS YOU CAN DO IT!
  • 9. Shader Languages WRITING SHADERS YOU CAN DO IT! HLSL GLSL CG OpenGL Shading Language OpenGL ARB (Architecture Review Board) OpenGL Windows, Mac, Linux, iOS, Android and more High Level Shading Language Microsoft DirectX Windows, XBox C for Graphics Nvidia DirectX & OpenGL Deprecated but... Thanks to Unity, covers all platforms
  • 10. ShaderLab WRITING SHADERS YOU CAN DO IT! Unity specific shading and material language All shaders written in Unity must be wrapped with ShaderLab May seem like extra work but it's actually saving you from a lot more work
  • 11. Dive into Unity WRITING SHADERS YOU CAN DO IT!
  • 13. ● Unity Manual ● Nvidia CG Tutorial ● CG Programming in Unity wikibook ● Video tutorial series on YouTube ● ShaderToy ● Aras' blog - aras-p.info/blog ● LearnOpenGL.com ● RealTimeRendering.com ● Many more at RESOURCES WRITING SHADERS YOU CAN DO IT! norde.us/unitewritingshaders
  • 14. ● Shader languages ● Shaders in Unity (ShaderLab) ● Vertex and Fragment Programs ● Lighting calculations ● Resources RECAP WRITING SHADERS YOU CAN DO IT!
  • 15. ● yilmazk@nordeus.eu ● @VoxelBoy ● norde.us/unitewritingshaders Q&A WRITING SHADERS YOU CAN DO IT!

Editor's Notes

  1. Hello everyone. Thank you for coming and let's get started.
  2. My name is Yilmaz Kiymaz. I've been a Unity developer for about 7 years now
  3. Nordeus is a kickass mobile games company based in Belgrade, with other offices around the world in London, Dublin, Skopje and San Francisco. Nordeus is the developer of Top Eleven, which is the most popular and most played online football management game. We are also working very hard on new titles. And in the process, you can see from the pictures that we have a lot of fun!
  4. I remember, back when I started learning about shaders a few years ago, I thought they were super interesting. After all, they give you complete control over how your game is going to look. So I started reading online tutorials and I realized that shaders, are scary. They have all this weird terminology such as Primitive Assembly, Rasterization, ZWrites, Culling, and Stencil, none of which I knew what it meant. And they have unfamiliar math and data. They're operating on vertices and fragment, vectors and matrices and textures and they have math I was scared of even before I knew about shaders, such as cross product, dot product, matrix multiplication and more. And then someone tells me these shaders run on the GPU? Which they say is massively parallelized and has different performance criteria and constraints?
  5. And then I saw this. What the hell is that? I'll tell you what it is, it's the of the OpenGL 4.3 pipeline map. And that's not even all of it, that's like half. I was ready to run for my life. But then I said OK, I got this. You can do this Yilmaz. So I sat down and started reading. A lot. And stuff still didn't make much sense. Why couldn't they do things like we do in regular programming? It wasn't until I actually started getting my hands dirty that some things began to click in my mind. I started experimenting with the shaders that come with Unity, commenting out lines to see what they did, adding a few lines myself here and there, obviously creating a lot of non-compilable shaders, but this is when things actually started making sense because I could see what each part was doing. Now the online tutorials started making sense as well and soon enough I was able to write some very humble shaders from scratch.
  6. So I went through this process of experimenting, failing, then learning a few things from my failures and then repeating the whole thing again and again, quite a lot of times before I was able to actually do anything interesting. What I would like to do for you today is to spare you from this horrible near-infinite loop. Instead, you can hopefully do this. Attend this talk (which you're already doing so right on!), learn, and profit! and write your own shaders. It is pretty ambitious, so let's dive in.
  7. What are shaders? I thought a lot about how to give the shortest definition possible and I think it's this. Shaders are short programs, executed on the GPU, to produce images on the screen. That sounds nice and simple. But of course, there's a lot more going on behind the scenes. For example, there's a bunch of Input data that needs to be fed into the shader, most importantly the 3d mesh, and then material data, lighting data, and some more. These inputs are processed in the vertex and fragment programs in the shader. The GPU has specialized computation units (usually called Shader Units) to run these vertex and fragment programs and calculate the resulting pixels we see on the screen.
  8. Let's take a look at it from the GPU's point of view. When a game engine sends the 3D mesh to the GPU to be drawn, the GPU sees a bunch of vertices; a vertex array. Then the vertex shader that you and I write, processes these vertices and transforms their positions so they can be used to display the 3d mesh in the right position on the screen. Then the GPU steps in and assembles triangles from these vertices and then comes rasterization. Rasterization is the process of converting these triangles into shadable fragments. Now these aren't the same as pixels. Pixels are the final color values that end up on the screen. Fragments can actually be even smaller than pixels and some of them might get discarded based on a bunch of different criteria. But anyways, once the fragments are generated by rasterization, our own fragment shader will be run for all these fragments, to give them a Color value. And after that, based on parameters that we set up, the GPU will do testing and blending of these fragments to turn them into the final pixels that we see on the screen.
  9. There are several shader languages out there to author shaders. Here are the ones that are most widespread and that you're most likely to encounter when writing shaders in Unity. There's HLSL, which is High Level Shading Language, created by Microsoft. It only works with the DirectX graphics library, which is only available on Windows and XBox. Then there's GLSL, which is OpenGL Shading Language, created by OpenGL Architecture Review Board. It only works with OpenGL which runs on many many platforms, such as Windows, Mac, Linux, iOS, Android and more. And then there's CG. It stands for C for Graphics, created by Nvidia and it supports both DirectX and OpenGL. However, it is no longer being developer however, HLSL and CG syntax is pretty much identical and when you write CG shaders in Unity, they will get cross-compiled into both GLSL and HLSL so they can run on all the platforms that Unity supports, which is great.
  10. When writing CG shaders in Unity, it is mandatory to wrap them with Unity's own ShaderLab language. It is a Unity-specific shading and material language. It may seem like having to wrap all CG shaders in this additional language is extra work but it is actually saving you from a lot of manual work you'd have to do to manage a lot of different parameters and state and edge cases. So it's a good thing.
  11. Now let's switch over to Unity. First, I want to show you what I mean when I say that the vertex shader transforms the vertices of the mesh from their original positions into the final screen positions with which they are rendered.
  12. There are some great resources online if you'd like to improve your knowledge on shaders. The Unity manuals ShaderLab section is a great place to start. There's a CG tutorial from Nvidia that is also pretty good at explaining a lot of concepts. The CG Programming in Unity wikibook has a lot of example shaders and good explanations. And there are at least a couple really good video tutorials on writing CG shaders in Unity. You can find links to all these resources and more at the shortened URL you see at the bottom of this slide. I'd like to show you one of these resources, which is ShaderToy, because I think it's a great website for getting inspired to write some very exotic but fun shaders.