12/21/2023 0 Comments Motion blur anime studio pro 11float zOverW = tex2D(depthTexture, texCoord) // H is the viewport position at this pixel in the range -1 to 1. Shader Code That Extracts the Per-Pixel World-Space Positions of the Objects That Were Rendered to the Depth Buffer // Get the depth buffer value at this pixel. The HLSL/Cg code in Listing 27-1 uses the previous equations in a full-screen post-processing pixel shader to compute the world-space position of the objects rendered at a given pixel, using the depth buffer and the inverse of the current view-projection matrix. Let M be the world-view-projection matrix and W be the world-space position at that pixel. We can show how this is achieved by defining the viewport-space position at a given pixel as H. We define the viewport position as the position of the pixel in viewport space-that is, the x and y components are in the range of -1 to 1 with the origin (0, 0) at the center of the screen the depth stored at the depth buffer for that pixel becomes the z component, and the w component is set to 1. Using the depth buffer as a texture, we can extract the world-space positions of the objects that were rendered to the depth buffer by transforming the viewport position at that pixel by the inverse of the current view-projection matrix and then multiplying the result by the w component. When an object is rendered and its depth values are written to the depth buffer, the values stored in the depth buffer are the interpolated z coordinates of the triangle divided by the interpolated w coordinates of the triangle after the three vertices of the triangles are transformed by the world-view-projection matrices. Notice how Figure 27-1 gives a strong illusion of motion.įigure 27-2 A Scene Without Motion Blur 27.2 Extracting Object Positions from the Depth Buffer This ability allows it to be easily integrated into existing engines targeting hardware that allows sampling from a depth buffer as a texture.įigures 27-1 and 27-2 show how different a scene can look with and without motion blur. The benefit of our technique is that it can be performed as a post-processing step. A motion blur effect can then be achieved by using this velocity vector as a direction to gather multiple samples across the frame buffer, averaging them out along the way to generate a blur. Then we can compute the difference in the viewport position between the current frame and the previous frame in order to generate the per-pixel velocity values. Once we determine the world-space position at that pixel, we can transform it by using the previous frame's view-projection matrix. The pixel shader program computes the world-space positions for each pixel by using the depth value-which is stored in the depth buffer-in conjunction with the current frame's view-projection matrix. In this chapter, we introduce a technique that uses the depth buffer as a texture input to a pixel shader program in order to generate the scene's velocity map. Additionally, some platforms have limited rendering memory and require a tiling mechanism in order to use multiple render targets on frame buffers that are 1280x720 or larger. Another disadvantage is that rendering to multiple render targets may decrease performance on some platforms. A major disadvantage of this strategy is that it requires modifying all the scene's shaders to add code that will calculate velocity and output it to the second render target. Other ways to generate a per-pixel velocity map include using multiple render targets and outputting the velocity information to one of the render targets. Such a multipass approach can be limiting: Many applications cannot afford to send the scene through the entire graphics pipeline more than once and still manage to reach the application's target frame rate. However, adding support for motion blur to an existing engine can be challenging because most motion blur techniques require the scene to be rendered in a separate pass in order to generate a per-pixel velocity buffer. Motion blur also helps smooth out a game's appearance, especially for games that render at 30 frames per second or less. Motion blur can be one of the most important effects to add to games, especially racing games, because it increases realism and a sense of speed. One of the best ways to simulate speed in a video game is to use motion blur. You can also subscribe to our Developer News Feed to get notifications of new material on the site.Ĭhapter 27. The CD content, including demos and content, is available on the web and for download. GPU Gems 3 GPU Gems 3 is now available for free online!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |