SlideShare a Scribd company logo
Graphics Programming with Unity3D Jonathan Moore [email_address]
The GPU Highly Parallelized Performs Vector, Matrix, and Texture lookup operations at fast speeds But comes with limitations not as flexible as the CPU rigid levels of communication Limited forms of data output but this is changing with newer Graphics APIs DirectCompute, OpenCL, and CUDA allow more general usage of the GPU
Two main access points in Unity Shading The conversion of 3D models into 2D-space (your screen) with the graphics pipeline Lighting, Bump Mapping, Toon Shading, etc Post-Processing performing shader operations on the image that is about to be drawn to the screen to achieve certain effects Motion Blur, Depth of Field, SSAO, etc
The Pipeline
A 3D Model Most important parts: A collection of points (vertices) The triangles that are drawn on those points Additional information: Uv coordinates for Texture look-ups 2 sets (can be swapped with Unity's importer) Normals Important for lighting Tangents used for bump mapping
The Vertex Shader Responsible for transforming vertex coordinates Passes information to pixel shader normals, uvs, vertex lighting, custom information information is interpolated between the 3 vertices of a triangle The vertex shader can often help obtain less accurate effects at a lower cost vertex lighting vs. pixel lighting
The Pixel Shader Responsible for outputting a color for each triangle fragment Largely color-focused (usually returns a half4) Texture Look-ups, adding bump map shading, compositing note that the GPU utilizes a half data type Runs ~10x as many times as vertex shader that number may increase with newer shader pipelines
Sample Code!
Types of Lighting Flat Normal is uniform for each triangle Vertex / Gouraud Lighting is calculated in vertex shader for each normal and then interpolated Pixel / Phong Lighting is computed per fragment by having the normals interpolated most expensive
Types of Lighting
Shaderlab Not shader code??? Not that complicated, but can tend to abstract things too much CG code is injected into it when more control is needed Fairly well described in the Unity documentation Also serves as wrapper for your shaders, so don't ignore it! Especially Colormask RGB, Cull Off, etc
Multi-pass Rendering The other reason why you should care about Shaderlab Essentially allows you to draw the model multiple times and combine the results together Fairly well described in the Unity documentation Unity uses this to combine lighting equations Can be used for your own devices Transparency + Glow
More Sample Code!
Image Effects Some effects can happen by changing the screen in 2D space before it gets displayed Part script, part shader Unity has a script in Pro Standard Assets that the script can inherit from OnRenderImage and Graphics.Blit are the key Graphics.Blit will apply the material to the image, in this case that material will have a shader set up to do the image effect
Image Effect Sample Code!
Image Effect “Hacks” Use them to do calculations outside of OnRenderImage I've used them to do texture combination and interpolation Remember that GPU is stupid fast  Create a buffer by rendering to a texture and then using that with a screen space effect Distortion particle effect Render with replacement is a powerful Unity feature (see camera docs)
More Image Effect Sample Code!
The Future: Unity 3.0 Deferred Rendering Huge improvement over Multi-pass More dynamic lights per scene Access to G-Buffer Shaderlab Supposedly being revamped to make it easier to use (according to Aras) Occlusion Culling Helps prevent hidden objects from wasting processing
The Future: DX11+ OpenGL 4.0 Tessellation is apparently the future Adding geometry to meshes in real time to give them more details and better lighting Allows for models much closer to the quality of animated movies New Shader Pipeline The future grows the number of programmable shaders from 3 to 5 Vertex Shader -> Tesselation Shader -> Hull Shader -> Geometry Shader -> Pixel Shader
Additional Resources NVIDIA developer zone The CG Tutorial GPU Gems (legendary for a reason) Real Time Rendering (Akenine-Moller) ShaderX books (similar to GPU Gems) SIGGRAPH White Papers Unite Presentations Several on shader tips and tricks
Thats all folks! [email_address] jonmoore.squarespace.com

More Related Content

PDF
GPU - Basic Working
PDF
19564926 graphics-processing-unit
PPTX
Graphics processing unit
PPTX
Graphics processing unit (GPU)
PPTX
Graphic Processing Unit (GPU)
PDF
GPU - An Introduction
PPTX
Graphic Processing Unit
PDF
CPU vs. GPU presentation
GPU - Basic Working
19564926 graphics-processing-unit
Graphics processing unit
Graphics processing unit (GPU)
Graphic Processing Unit (GPU)
GPU - An Introduction
Graphic Processing Unit
CPU vs. GPU presentation

What's hot (20)

PPTX
GPU Computing: A brief overview
PDF
PPTX
PPTX
graphics processing unit ppt
PDF
Introduction to GPU Programming
PPTX
Graphics processing unit ppt
PDF
GPU power consumption and performance trends
PPT
Graphics Processing Unit - GPU
PPTX
GPU Architecture NVIDIA (GTX GeForce 480)
PPT
Parallel computing with Gpu
PPTX
Graphics processing unit (gpu)
PDF
Gpu Systems
PPTX
Graphics Processing Units
PPTX
GRAPHICS PROCESSING UNIT (GPU)
PPTX
Gpu databases
PPTX
Revisiting Co-Processing for Hash Joins on the Coupled Cpu-GPU Architecture
PPTX
A New Approach for Parallel Region Growing Algorithm in Image Segmentation u...
PDF
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
GPU Computing: A brief overview
graphics processing unit ppt
Introduction to GPU Programming
Graphics processing unit ppt
GPU power consumption and performance trends
Graphics Processing Unit - GPU
GPU Architecture NVIDIA (GTX GeForce 480)
Parallel computing with Gpu
Graphics processing unit (gpu)
Gpu Systems
Graphics Processing Units
GRAPHICS PROCESSING UNIT (GPU)
Gpu databases
Revisiting Co-Processing for Hash Joins on the Coupled Cpu-GPU Architecture
A New Approach for Parallel Region Growing Algorithm in Image Segmentation u...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
Ad

Viewers also liked (17)

PPTX
GPU Computing
PDF
Example Application of GPU
PPT
PPTX
Video ram
PPTX
Graphics Processing Unit by Saurabh
PDF
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
PDF
PDF
Gpu presentation
PPT
LUDO BOARD GAME OPENGL COMPUTER GRAPHICS
PPTX
Computer Graphics Project Development Help with OpenGL computer graphics proj...
PPTX
Lec04 gpu architecture
PDF
Graph
PPT
Graph Theory Application - Not Only for Engineering Problems
PPT
OpenGL Projects on SIMULATION OF WATER RIPPELS
DOCX
Computer Graphics Project- The Running Train
GPU Computing
Example Application of GPU
Video ram
Graphics Processing Unit by Saurabh
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
Gpu presentation
LUDO BOARD GAME OPENGL COMPUTER GRAPHICS
Computer Graphics Project Development Help with OpenGL computer graphics proj...
Lec04 gpu architecture
Graph
Graph Theory Application - Not Only for Engineering Problems
OpenGL Projects on SIMULATION OF WATER RIPPELS
Computer Graphics Project- The Running Train
Ad

Similar to Gpu presentation (20)

PPT
Shadow Techniques for Real-Time and Interactive Applications
PPT
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
DOCX
Ha4 constraints
PPT
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
PPTX
The Rendering Pipeline - Challenges & Next Steps
PPT
Praseed Pai
PPTX
DirectX 11 Rendering in Battlefield 3
PPTX
FGS 2011: Making A Game With Molehill: Zombie Tycoon
PPTX
Datt 2501 week 10
PPT
Advanced Lighting for Interactive Applications
DOCX
Constraints
PDF
Unite 2013 optimizing unity games for mobile platforms
PDF
Computer Graphics Notes
PPTX
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
PPTX
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
PPTX
Graphics pipelining
PDF
Deferred rendering in_leadwerks_engine[1]
PDF
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
PDF
Game Engine Overview
PPTX
overviewing new unity graphic features
Shadow Techniques for Real-Time and Interactive Applications
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Ha4 constraints
The Intersection of Game Engines & GPUs: Current & Future (Graphics Hardware ...
The Rendering Pipeline - Challenges & Next Steps
Praseed Pai
DirectX 11 Rendering in Battlefield 3
FGS 2011: Making A Game With Molehill: Zombie Tycoon
Datt 2501 week 10
Advanced Lighting for Interactive Applications
Constraints
Unite 2013 optimizing unity games for mobile platforms
Computer Graphics Notes
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Making High Quality Interactive VR with Unreal Engine Luis Cataldi
Graphics pipelining
Deferred rendering in_leadwerks_engine[1]
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
Game Engine Overview
overviewing new unity graphic features

More from spartasoft (7)

PPTX
Interviewing and Getting a Job 101
PPTX
Ai part 1
KEY
Spartasoft Month Long Game Roundtable
PPT
GDC 2011 recap
PPT
Console development
PPT
Build some PR!
PPT
Unite 2010
Interviewing and Getting a Job 101
Ai part 1
Spartasoft Month Long Game Roundtable
GDC 2011 recap
Console development
Build some PR!
Unite 2010

Gpu presentation

  • 1. Graphics Programming with Unity3D Jonathan Moore [email_address]
  • 2. The GPU Highly Parallelized Performs Vector, Matrix, and Texture lookup operations at fast speeds But comes with limitations not as flexible as the CPU rigid levels of communication Limited forms of data output but this is changing with newer Graphics APIs DirectCompute, OpenCL, and CUDA allow more general usage of the GPU
  • 3. Two main access points in Unity Shading The conversion of 3D models into 2D-space (your screen) with the graphics pipeline Lighting, Bump Mapping, Toon Shading, etc Post-Processing performing shader operations on the image that is about to be drawn to the screen to achieve certain effects Motion Blur, Depth of Field, SSAO, etc
  • 5. A 3D Model Most important parts: A collection of points (vertices) The triangles that are drawn on those points Additional information: Uv coordinates for Texture look-ups 2 sets (can be swapped with Unity's importer) Normals Important for lighting Tangents used for bump mapping
  • 6. The Vertex Shader Responsible for transforming vertex coordinates Passes information to pixel shader normals, uvs, vertex lighting, custom information information is interpolated between the 3 vertices of a triangle The vertex shader can often help obtain less accurate effects at a lower cost vertex lighting vs. pixel lighting
  • 7. The Pixel Shader Responsible for outputting a color for each triangle fragment Largely color-focused (usually returns a half4) Texture Look-ups, adding bump map shading, compositing note that the GPU utilizes a half data type Runs ~10x as many times as vertex shader that number may increase with newer shader pipelines
  • 9. Types of Lighting Flat Normal is uniform for each triangle Vertex / Gouraud Lighting is calculated in vertex shader for each normal and then interpolated Pixel / Phong Lighting is computed per fragment by having the normals interpolated most expensive
  • 11. Shaderlab Not shader code??? Not that complicated, but can tend to abstract things too much CG code is injected into it when more control is needed Fairly well described in the Unity documentation Also serves as wrapper for your shaders, so don't ignore it! Especially Colormask RGB, Cull Off, etc
  • 12. Multi-pass Rendering The other reason why you should care about Shaderlab Essentially allows you to draw the model multiple times and combine the results together Fairly well described in the Unity documentation Unity uses this to combine lighting equations Can be used for your own devices Transparency + Glow
  • 14. Image Effects Some effects can happen by changing the screen in 2D space before it gets displayed Part script, part shader Unity has a script in Pro Standard Assets that the script can inherit from OnRenderImage and Graphics.Blit are the key Graphics.Blit will apply the material to the image, in this case that material will have a shader set up to do the image effect
  • 16. Image Effect “Hacks” Use them to do calculations outside of OnRenderImage I've used them to do texture combination and interpolation Remember that GPU is stupid fast Create a buffer by rendering to a texture and then using that with a screen space effect Distortion particle effect Render with replacement is a powerful Unity feature (see camera docs)
  • 17. More Image Effect Sample Code!
  • 18. The Future: Unity 3.0 Deferred Rendering Huge improvement over Multi-pass More dynamic lights per scene Access to G-Buffer Shaderlab Supposedly being revamped to make it easier to use (according to Aras) Occlusion Culling Helps prevent hidden objects from wasting processing
  • 19. The Future: DX11+ OpenGL 4.0 Tessellation is apparently the future Adding geometry to meshes in real time to give them more details and better lighting Allows for models much closer to the quality of animated movies New Shader Pipeline The future grows the number of programmable shaders from 3 to 5 Vertex Shader -> Tesselation Shader -> Hull Shader -> Geometry Shader -> Pixel Shader
  • 20. Additional Resources NVIDIA developer zone The CG Tutorial GPU Gems (legendary for a reason) Real Time Rendering (Akenine-Moller) ShaderX books (similar to GPU Gems) SIGGRAPH White Papers Unite Presentations Several on shader tips and tricks
  • 21. Thats all folks! [email_address] jonmoore.squarespace.com