it’s just data! the wonderful world of shadersseawisphunter.com/pdf/dan-buckstein-shaders.pdf ·...
TRANSCRIPT
It’s Just Data!The Wonderful World of Shaders
Daniel S. Buckstein
VT Game Developers Meetup
Feb. 22, 2018
Daniel S. Buckstein
Hello World
Dan “ShaderMan” Buckstein
Assistant Professor, Champlain
College (Game Programming)
– M.Sc, Computer Science, UOIT
– B.IT, Game Development & Entrepreneurship, UOIT
– Favourite games: Dragon Quest I-VI, Super Mario 64, Banjo-Kazooie
Daniel S. Buckstein
What are we talking about?
• The technical yet cross-discipline perspective.
• Not really shaders for Unity, Unreal, Maya...
1. “It’s just data!”
2. Shaders are for everyone
3. Tricks of the trade
Daniel S. Buckstein
How much is there to discuss?
• This talk:
45-ish minutes
• Graphics curriculum in EGP at Champlain:
90 – 135 cr. hoursDaniel S. Buckstein
My First Shader
• CircaFeb. 20-something, 2011
• I was bored.
Daniel S. Buckstein
What are shaders?
Daniel S. Buckstein
https://www.lri.fr/~mbl/ENS/IG2/docs/opengl-stm.pdf
What are shaders?
• Shaders are the “programmable” in “programmable pipeline”
Daniel S. Buckstein
http://www.3dgep.com/wp-content/uploads/2014/02/OpenGL-4.0-Pipeline.png
Data input/output (API/framebuffer)OpenGL-controlled process
Shader: programmer-controlled process
Don’t forget me…
What are shaders?
• Shaders are the “programmable” in “programmable pipeline”
• A chain of shaders is called a shader program
– E.g. VS TCS TES GS FS
– E.g. VS GS FS
– E.g. VS FS (most popular)
– E.g. VS (minimum requirement)
– E.g. CS (must be standalone)
Daniel S. Buckstein
What are shaders?
• Well-known shading languages:
• Cg: C for graphics (Nvidia) rip
• HLSL: High-Level Shading Language (v6.0)
• GLSL: The OpenGL Shading Language (v4.6)
• Metal: Apple’s proprietary language (v2.0)
• SPIR-V: Vulkan’s core language (v1.0)
Daniel S. Buckstein
Daniel S. Buckstein
The one rule to rule them all:
It’s just
data!Daniel S. Buckstein
It’s just data!
• A shader program eats raw data:
• API defines geometry, stores it in vertex buffer
• Vertex shader reads this only as you tell it to!
Daniel S. Buckstein
Data in interleaved VBO:
𝑝0𝑥 𝑝0𝑦 𝑝0𝑧 ො𝑛0𝑥 ො𝑛0𝑦 ො𝑛0𝑧 𝑢0 𝑣0 𝑝1𝑥 𝑝1𝑦 𝑝1𝑧 ො𝑛1𝑥 ො𝑛1𝑦 ො𝑛1𝑧 𝑢1 𝑣1
“position” “normal” “texcoord”
The first vertex (all of it!) The second vertex…
It’s just data!
• A shader program also outputs raw data:
Off-screen render pass(assume same size as display)
DepthBACK BUFFER (main target)
Daniel S. Buckstein
It’s just data!
• Shaders are fancy data readers and writers.
• They are crazy fast.
• And they don’t give a damn.
Daniel S. Buckstein
What can shaders do?
• The misnomer: a shader does not “shade”
• Its true purpose is to manipulate data
Vertex shader Vertices (mesh data)
Tessellation Mesh detail (LOD)
Geometry Primitives (multiple VS)
Fragment Framebuffer (“color”)
Compute Whatever you want
Daniel S. Buckstein
What can shaders do?
• Sprite sheet animation vertex shader
• Mesh deformation vertex shader
• Particles geometry shader
• Stereo 3D/VR parallel geometry shader
• Any and all shading fragment shader
• Post-processing fragment shader
• Anything and everything compute shader
Daniel S. Buckstein
What can shaders do?
• Compute is easier than it sounds…
Daniel S. BucksteinCourtesy of Michael G.
Who cares about shaders?
• Programmer: build the framework, feed data
• Artist: manipulate data to make pretty things
• Designer: high-level code… you can code too!
• Producer: graphics player $$$$$
• Other: simulation… film… stage… audio…
Daniel S. Buckstein
Who cares about shaders?
• Engines and editors (e.g. Unity, Unreal, Maya) write the shader programs for you…
• …anyone can define the “materials”:
Daniel S. Buckstein
How do we manipulate data?
• Why should I tell you…
Daniel S. Buckstein
…when I can show you?
Conclusion
• What does my future hold???
• What does your future hold???
Better graphics.
Better games.
Daniel S. Buckstein
Conclusion
• Where can you get started?
• www.kickjs.org VS & FS
• www.shadertoy.com only FS
• Check out some other people’s work: • Pac-Man: https://www.shadertoy.com/view/Ms3XWN
• Doom: https://www.shadertoy.com/view/lldGDr
• Others: https://shadertoyunofficial.wordpress.com/2017/11/11/playable-games-in-shadertoy/
Daniel S. Buckstein
Conclusion
• Where can you get started?
• Learn some math.
• Read a book.
• Just do it.
Daniel S. Buckstein
Vectors, matrices, quaternions.
OpenGL SuperBible, Real-Time Rendering
Conclusion
• It’s just data…
• Communication with the GPU is key.
• Get busy, there’s so much to do!
Daniel S. Buckstein
The end.
• Questions? Comments? Concerns?
Daniel S. Buckstein