Lecture Rendering pipeline, shaders and effects 1Elias Holmlid
First part: The rendering pipeline Effects & shaders overview XNA, HLSL & Effects Shader authoring tools Particle Systems Second part Effect, texturing and particle system example Elias Holmlid2
3
Rasterization Taking vertex positions from the vertex shader and transforming them into pixels. Elias Holmlid4
Transform and shading of geometry Particles: motion + shading Intermediate buffers (textures) Post processing Elias Holmlid5
Texture Elias Holmlid6
Texture + Directional light Elias Holmlid7
Texture + Directional light + Spotlight Elias Holmlid8
Texture + Directional light + Spotlight + Normal map Elias Holmlid9
Texture + Directional light + Spotlight + Normal map + Pointlight Elias Holmlid10
Texture + Directional light + Spotlight + Normal map + Pointlight + Shadows Elias Holmlid11
Elias Holmlid12 Example: Heat texture
Elias Holmlid13 Example: Soft shadows
Bloom disabledBloom enabled Elias Holmlid14
C-like syntax No object orientation Functions can be used By using include-files, functions and datatypes can be reused Elias Holmlid15
Elias Holmlid16
Elias Holmlid17
Vertex shader Used to transform vertices ▪ Solids deforming ▪ Skeletal animation ▪ Particle motion Elias Holmlid18
Pixel shader Manipulates pixel color and optionally the pixel depth. Examples: ▪ Lighting ▪ Contrast ▪ Blur Elias Holmlid19
Easy to work with in XNA Represented by the class Effect Effect effect; effect.Load (”/effects/lightEffect”); You can then set the attributes of the effect effect.Parameters[”lightPosition”].SetValue() To make the code more robust and efficient, implement a helper class for each effect. After a while, you may want to find a faster way of adding new shaders Elias Holmlid20
Complete IDE´s available for developing shaders Elias Holmlid21
A way to simulate explosions, water, fire etc. Particles behave in a similar, yet slightly different way Elias Holmlid22
Particles created and killed on the CPU Custom vertex declaration used Pooling should be used (no memory allocation during runtime) Current position/color/size of each particle calculated in vertex shader Final color decided in pixel shader Elias Holmlid23