Lecture 9 --- Rendering pipeline, shaders and effects Elias Holmlid 1 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 Holmlid 2 Elias Holmlid 3 Rasterization Taking vertex positions from the vertex shader and transforming them into pixels. Elias Holmlid 4 Transform and shading of geometry Particles: motion + shading Intermediate buffers (textures) Post processing Elias Holmlid 5 Texture Elias Holmlid 6 Texture + Directional light Elias Holmlid 7 Texture + Directional light + Spotlight Elias Holmlid 8 Texture + Directional light + Spotlight + Normal map Elias Holmlid 9 Texture + Directional light + Spotlight + Normal map + Pointlight Elias Holmlid 10 Texture + Directional light + Spotlight + Normal map + Pointlight + Shadows Elias Holmlid 11 Example: Heat texture Elias Holmlid 12 Example: Soft shadows Elias Holmlid 13 Bloom disabled Elias Holmlid Bloom enabled 14 C-like syntax No object orientation Functions can be used By using include-files, functions and datatypes can be reused Elias Holmlid 15 Elias Holmlid 16 Elias Holmlid 17 Vertex shader Used to transform vertices ▪ Solids deforming ▪ Skeletal animation ▪ Particle motion Elias Holmlid 18 Pixel shader Manipulates pixel color and optionally the pixel depth. Examples: ▪ Lighting ▪ Contrast ▪ Blur Elias Holmlid 19 Easy to work with in XNA Represented by the class Effect Effect effect; effect.Load<Effect>(”/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 Holmlid 20 Complete IDE´s available for developing shaders Elias Holmlid 21 A way to simulate explosions, water, fire etc. Particles behave in a similar, yet slightly different way Elias Holmlid 22 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 Holmlid 23
© Copyright 2026 Paperzz