Download presentation
Presentation is loading. Please wait.
Published byCarina Manly Modified over 10 years ago
1
POST-PROCESSING SET09115 Intro Graphics Programming
2
Breakdown Background Review – shading and texturing What is post-processing? Working with Post-Processing Greyscale shader Working with OpenGL Example Post-Processes Gaussian blur, motion blur, depth of field
3
Recommended Reading Course Text Chapter 8, section 8.11 onwards Real Time Rendering Chapter 10 All interesting 10.9 onwards relevant
4
Background
5
Review – What are Shaders? Shaders are small programs that run on the GPU Shaders allow us to implement effects that we may wish for in our rendered scene Lighting, texturing being the most basic Three types of shader Vertex Geometry Fragment (or pixel)
6
Review – Shading Pipeline Vertex data goes in at the start Final rendered image comes out at the end It is possible to get data from the pipeline without displaying anything Stream output (geometry stage) Render to texture (rasterization stage)
7
Review – What is Texturing? Texturing is the process of attaching images to geometric objects Texturing can be used to provide more realistic detail than colour and lighting alone
8
Review – How Texturing Works Texturing requires two pieces of information The texture to be used The texture coordinates for each vertex of the model The texture coordinates are used to determine parts of the image to attach to individual pieces of geometry Sort of a mixture between wrapping paper and cutting out and gluing
9
What do we mean by Post-Processing? Post-processing is any rendering technique we apply after the main object render Pixel shader Post-processing covers a wide range of techniques Depth of field, toon shading, motion blur, etc.
10
How does Post-Processing Work? Post-processing typically utilises two techniques we have covered Shaders Textures Instead of rendering to the screen, we render to a texture We take this texture, render it to the whole screen, and use a post-process shader on it to manipulate it Render to texture Render texture to screen We can also render the texture to texture again Multi pass post-processing
11
OpenGL Frame Buffer Objects OpenGL uses a technique called frame buffer objects to get textures from the GPU Three stage process Create an empty texture Create a frame buffer object Attach texture to frame buffer object We can then use the frame buffer object at any time Bind it to enable render to the texture Unbind to enable render to the screen
12
Example Post Process Call of Duty: Modern Warfare 2 Motion Blur [Link]Link
13
Questions?
14
Working with Post-Processing
15
Simple Example
16
GLSL Pixel Shader uniform sampler2D texture; in vec2 texCoord; out vec4 colour; void main( void ) { vec4 temp = texture2D(texture, texCoord); float I = 0.299 * temp.r + 0.587 * temp.g + 0.184 * temp.b; colour = vec4(I, I, I, 1.0); }
17
Setting up OpenGL // Create a texture data = new GLubyte[800 * 600 * 3]; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, 800, 600, 0, GL_RGB, GL_UNSIGNED_BYTE, data); // Create a framebuffer glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Attach texture glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
18
Performing the Render First bind the framebuffer glBindFramebuffer(GL_FRAMEBUFFER, fbo); Perform your render Unbind the framebuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); Bind the texture rendered to glBindTexture(GL_TEXTURE_2D, texture) Perform screen render
19
Output
20
Depth Buffer Objects It is also possible to get the depth buffer from the render Image data is greyscale based on distance from viewer Darker pixels closer Lighter pixels nearer Why would we want this?
21
Screen Space Ambient Occlusion Using a depth buffer lets us perform fast ambient occlusion Sample surrounding pixel depths Use this to determine if pixel is being occluded by any of the pixels First used in Crysis (2007)
22
Questions?
23
Example Post-Processes
24
Gaussian Blur Gaussian blur is a common technique used in graphics Sometimes called Gaussian smoothing The goal is to reduce noise in the image See top But this will also remove detail See bottom
25
How Gaussian Blur Works Gaussian blur operates using a pixel sampling technique Each pixel is effected by a number of surrounding pixels Instead of sampling each surrounding pixel 25 pixel reads The blur is done in two stages 10 pixel reads total
26
Edge Detection Edge detection allows us to detect the edges of an object Essentially the change in colour between pixels Edge detection is also done using a filter and pixel sampling approach
27
Motion Blur Motion blur is a technique that works by taking a number of existing frames Texture renders And then blending them together based on the pixel colour change No change In focus Change Blurred
28
Depth of Field Depth of field is a technique that enables objects out of focus to look blurred Two techniques Multiple camera positions Depth buffer
29
HDR High Dynamic Range HDR is a technique to allow a wider range in contrast between colours Dark colours dont turn so much to black with no detail Light colours dont turn so much to white with no detail
30
Bloom Bloom is the effect where light has a glow which effects the other objects around it Typically an extension of HDR, where light is blended into the other objects
31
Film Grain A noise addition technique where we make the image look like it was recorded using old film Can be useful when you want to use some pre-rendered cut- scenes
32
Questions?
33
To do this week… Practical this week still in Games Lab Shaders You should investigate some post-processing techniques, and maybe try and implement them if you have time We have only really scratched the surface Hopefully, you have all started work on the coursework Ill come round and have a look on Thursday
34
Summary Post-processing is any rendering technique that we apply after the main render We typically use two techniques Texturing Shading We can implement post-processing by rendering the main scene to a texture, then manipulating the texture Numerous techniques exist Blurring, depth of field, toon shading, etc.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.