Jason Yang and Jay McKee

Slides:



Advertisements
Similar presentations
A Real Time Radiosity Architecture for Video Games
Advertisements

Destruction Masking in Frostbite 2 using Volume Distance Fields
Advanced Visual Effects with Direct3D
Grass, Fur and all things hairy Nicolas ThibierozKarl Hillesland Gaming Engineering Manager, AMDSenior Research Engineer, AMD.
OIT and Indirect Illumination using DX11 Linked Lists
Using Graphics Processors for Real-Time Global Illumination UK GPU Computing Conference 2011 Graham Hazel.
Deferred Lighting and Post Processing on PLAYSTATION®3
Technology Behind AMD’s “Leo Demo” Jay McKee MTS Engineer, AMD
Exploration of advanced lighting and shading techniques
Deferred Shading Optimizations
COMPUTER GRAPHICS SOFTWARE.
An Optimized Soft Shadow Volume Algorithm with Real-Time Performance Ulf Assarsson 1, Michael Dougherty 2, Michael Mounier 2, and Tomas Akenine-Möller.
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 10, 2014 GRAPHICS HARDWARE GRAPHICS PROCESSING UNITS PARALLELISM.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
RealityEngine Graphics Kurt Akeley Silicon Graphics Computer Systems.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Filtering Approaches for Real-Time Anti-Aliasing
High-Quality Parallel Depth-of- Field Using Line Samples Stanley Tzeng, Anjul Patney, Andrew Davidson, Mohamed S. Ebeida, Scott A. Mitchell, John D. Owens.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
Shadow Silhouette Maps Pradeep Sen, Mike Cammarano, Pat Hanrahan Stanford University.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
Final Gathering on GPU Toshiya Hachisuka University of Tokyo Introduction Producing global illumination image without any noise.
1Notes. 2Atop  The simplest (useful) and most common form of compositing: put one image “atop” another  Image 1 (RGB) on top of image 2 (RGB)  For.
Z-Buffer Optimizations Patrick Cozzi Analytical Graphics, Inc.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
Paper by Alexander Keller
Mapping Computational Concepts to GPU’s Jesper Mosegaard Based primarily on SIGGRAPH 2004 GPGPU COURSE and Visualization 2004 Course.
Hidden Surface Removal
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Computer Graphics Mirror and Shadows
Ray Tracing and Photon Mapping on GPUs Tim PurcellStanford / NVIDIA.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Interactive Rendering of Meso-structure Surface Details using Semi-transparent 3D Textures Vision, Modeling, Visualization Erlangen, Germany November 16-18,
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
Interactive Time-Dependent Tone Mapping Using Programmable Graphics Hardware Nolan GoodnightGreg HumphreysCliff WoolleyRui Wang University of Virginia.
-Global Illumination Techniques
Cg Programming Mapping Computational Concepts to GPUs.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
Tone Mapping on GPUs Cliff Woolley University of Virginia Slides courtesy Nolan Goodnight.
Hardware-accelerated Rendering of Antialiased Shadows With Shadow Maps Stefan Brabec and Hans-Peter Seidel Max-Planck-Institut für Informatik Saarbrücken,
Sample Based Visibility for Soft Shadows using Alias-free Shadow Maps Erik Sintorn – Ulf Assarsson – uffe.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Stencil Routed A-Buffer
- Laboratoire d'InfoRmatique en Image et Systèmes d'information
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Single Pass Point Rendering and Transparent Shading Paper by Yanci Zhang and Renato Pajarola Presentation by Harmen de Weerd and Hedde Bosman.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Ray Tracing using Programmable Graphics Hardware
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
1cs426-winter-2008 Notes. 2 Atop operation  Image 1 “atop” image 2  Assume independence of sub-pixel structure So for each final pixel, a fraction alpha.
COMPUTER GRAPHICS CHAPTER 38 CS 482 – Fall 2017 GRAPHICS HARDWARE
Real-Time Soft Shadows with Adaptive Light Source Sampling
DX11 TECHNIQUES IN HK2207 Takahiro Harada AMD. DX11 TECHNIQUES IN HK2207 Takahiro Harada AMD.
Deferred Lighting.
The Graphics Rendering Pipeline
UMBC Graphics for Games
UMBC Graphics for Games
RADEON™ 9700 Architecture and 3D Performance
Frame Buffer Applications
Presentation transcript:

Jason Yang and Jay McKee Real-Time Order Independent Transparency and Indirect Illumination Using Direct3D 11 Jason Yang and Jay McKee

…Continued from Last Year Depth of Field using Summed Area Tables 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Today’s Overview Fast creation of linked lists of arbitrary size on the GPU using D3D11 Integration into the standard graphics pipeline Demonstrates compute from rasterized data DirectCompute features in Pixel Shader Examples: Order Independent Transparency (OIT) Indirect Shadowing Building data structures from the graphics pipeline 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Background A-buffer – Carpenter ‘84 CPU side linked list per-pixel for anti-aliasing Fixed array per-pixel F-buffer, stencil routed A-buffer, Z3 buffer, and k-buffer, Slice map, bucket depth peeling Multi-pass Depth peeling methods for transparency Recent Freepipe, PreCalc [DX11 SDK] 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Linked List Construction Two Buffers Head pointer buffer addresses/offsets Initialized to end-of-list (EOL) value (e.g., -1) Node buffer arbitrary payload data + “next pointer” Each shader thread Retrieve and increment global counter value Atomic exchange into head pointer buffer Add new entry into the node buffer at location from step 1 Creating reverse linked list 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Order Independent Transparency Construction by Example Classical problem in computer graphics Correct rendering of semi-transparent geometry requires sorting – blending is an order dependent operation Sometimes sorting triangles is enough but not always Difficult to sort: Multiple meshes interacting (many draw calls) Impossible to sort: Intersecting triangles (must sort fragments) Try doing this in PowerPoint! 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Order Independent Transparency with Per-Pixel Linked Lists Computes correct transparency Good performance Works with depth and stencil testing Works with and without MSAA Example of programmable blend 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Algorithm Overview 0. Render opaque scene objects Render transparent scene objects Screen quad resolves and composites fragment lists 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Step 0 – Render Opaque Render all opaque geometry normally Render Target 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Algorithm Overview 0. Render opaque scene objects Render transparent scene objects All fragments are stored using per-pixel linked lists Store fragment’s: color, alpha, & depth Screen quad resolves and composites fragment lists 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Setup Two buffers Screen sized head pointer buffer Node buffer – large enough to handle all fragments Render as usual Disable render target writes 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Step 1 – Create Linked List Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Counter = 0 Node Buffer 1 2 3 4 5 6 … 7/28/2010

Step 1 – Create Linked List Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Counter = 0 Node Buffer 1 2 3 4 5 6 … 7/28/2010

Step 1 – Create Linked List Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Counter = 1 Node Buffer 1 2 3 4 5 6 … 7/28/2010

Step 1 – Create Linked List Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Counter = 1 Node Buffer 1 2 3 4 5 6 … 0.87 -1 7/28/2010

Step 1 – Create Linked List Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Counter = 3 Node Buffer 1 2 3 4 5 6 … 0.87 0.89 0.90 Culled due to existing scene geometry depth. -1 -1 -1 7/28/2010

Step 1 – Create Linked List -1 -1 -1 -1 -1 -1 -1 3 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Counter = 5 Node Buffer 1 2 3 4 5 6 … 0.87 0.89 0.90 0.65 0.65 -1 -1 -1 -1 7/28/2010

Step 1 – Create Linked List -1 -1 -1 -1 -1 -1 -1 5 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Counter = 6 Node Buffer 1 2 3 4 5 6 … 0.87 0.89 0.90 0.65 0.65 0.71 -1 -1 -1 -1 3 7/28/2010

Advances in Real-Time Rendering Course Node Buffer Counter Counter allocated in GPU memory (i.e. a buffer) Atomic updates Contention issues DX11 Append feature Linear writes to a buffer Implicit writes Append() Explicit writes IncrementCounter() Standard memory operations Up to 60% faster than memory counters 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Algorithm Overview 0. Render opaque scene objects Render transparent scene objects Screen quad resolves and composites fragment lists Single pass Pixel shader sorts associated linked list (e.g., insertion sort) Composite fragments in sorted order with background Output final fragment 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Step 2 – Render Fragments Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 5 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Node Buffer 1 2 3 4 5 6 … (0,0)->(1,1): Fetch Head Pointer: -1 -1 indicates no fragment to render 0.87 0.89 0.90 0.65 0.65 0.71 -1 -1 -1 -1 3 7/28/2010

Step 2 – Render Fragments Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 5 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Node Buffer 1 2 3 4 5 6 … (1,1): Fetch Head Pointer: 5 Fetch Node Data (5) Walk the list and store in temp array 0.87 0.89 0.90 0.65 0.65 0.71 -1 -1 -1 -1 3 0.71 0.65 0.87

Step 2 – Render Fragments -1 -1 -1 -1 -1 -1 -1 5 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Node Buffer 1 2 3 4 5 6 … (1,1): Sort temp array Blend colors and write out 0.87 0.89 0.90 0.65 0.65 0.71 -1 -1 -1 -1 3 Insertion sort 0.65 0.71 0.87

Step 2 – Render Fragments Head Pointer Buffer -1 -1 -1 -1 -1 -1 -1 5 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 Render Target -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 Node Buffer 1 2 3 4 5 6 … 0.87 0.89 0.90 0.65 0.65 0.71 -1 -1 -1 -1 3 7/28/2010

Advances in Real-Time Rendering Course Anti-Aliasing Store coverage information in the linked list Resolve on per-sample Execute a shader at each sample location Use MSAA hardware Resolve per-pixel Execute a shader at each pixel location Average all sample contributions within the shader Sub-pixel intersections Pros: Slightly faster than per-sample execution Can be done with a Compute Shader Cons: Destination Render Target is single sample Depthstencil testing is not available for early rejection 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Demo

Performance Comparison Teapot Dragon Linked List 743 fps 338 fps Precalc 285 fps 143 fps Depth Peeling 579 fps 45 fps Bucket Depth Peeling --- 256 fps Dual Depth Peeling 94 fps Performance scaled to ATI Radeon HD 5770 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Mecha Demo 602K scene triangles 254K transparent triangles 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Layers Worst case 370K fragments filling 40% of the frame 2ms to store the fragments 3.3ms 0->64 fps 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Scaling 112 -> 60 fps -> 32fps 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Indirect Illumination with Indirect Shadows using DirectX 11 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Why Indirect Shadowing? Help perceive subtle dynamic changes occuring in a scene. Adds helpful cues for depth perception. Indirect light contribution on scene pixels more accurate. Especially important for visual experience and gameplay when environments are dimmly lit or action happens away from direct light. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course 4 Phases: Create 3D grid holding blocker geometry for indirect shadowing. (use DX11 Compute Shader) Generate Reflective Shadow Maps (RSMs). Indirect Light Indirect Shadowing 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course PHASE #1 Create 3D grid containing blocker geometry for shadowing. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Create 3D grid for shadow blocker geometry (0,0,0) eol = End of list (0xffffffff) Insert triangles of low LOD versions of blocker geometry into cells of 3D grid (0,1,0)

Advances in Real-Time Rendering Course PHASE #2 Generate RSMs 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Reflective Shadow Map RSM is like a standard shadow map but with added information such as color, normal, flux, etc. Pixels in RSM considered as point light sources for 1 bounce indirect light. Create 1 RSM for each light source you want to contribute indirect light. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

RSM ~ G-Buffer for lights Position Color Normal

Advances in Real-Time Rendering Course PHASE #3 Indirect Light 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Indirect Light At this point, assumed you have: Main scene G-buffer with color, position, normal Generated RSMs with color, position, normal Separate indirect light and indirect shadow phases so you can use different buffer sizes based on performance needs. In this example both phases use 1/4 size buffer. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Full-screen quad. For each scene pixel: Transform scene pixel position and normal to RSM space 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Indirect Light Accumulate For each scene pixel, loop through RSM kernel pixels, do standard lighting calculation between RSM kernel pixel and scene pixel and accumulate light.

Advances in Real-Time Rendering Course Problem! Too many samples per kernel will kill performance…but we need very large kernel to get good visual results. For decent results need >= 512x512 as well as big kernel >= 80x80 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Solution: Don’t use the full kernel for each screen pixel. Instead, use dithered pattern of pixels which only considers 1 out of NxN pixels each time in the light accumulation loop. Dithered pattern position uses scene pixel screen position modulo N. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Indirect Lighting However, the dithered pattern used to calculate indirect light falling on screen pixel still won’t be smooth… Perform bilateral filter with up-sample to smooth things out and go to main scene image size. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course PHASE #4 Indirect Shadowing 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Indirect Shadowing Similar steps, full screen quad, transform scene pixel to RSM, but instead of lighting calculation… Accumulate the amount of *blocked* light between RSM kernel and scene pixel. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

How do you estimate amount of blocked light? Trace N rays from scene pixel to RSM kernel pixels and check for blocking triangles from the 3D grid step. Accumulate indirect light from *blocked* RSM kernel pixels only! Apply bilateral filter and up-sample. SUBTRACT result from indirect light in previous step. 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Indirect Light 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

After Indirect Shadowing 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Full Scene

Advances in Real-Time Rendering Course No Indirect Lighting 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

With Indirect Lighting 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Indirect Lighting + Shadowing 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Demo Time

Advances in Real-Time Rendering Course Summary: Fairly simple implementation. All but the 3D grid phase is probably in your pipeline today. Fully dynamic. No pre-generated data required. Offers a “playground” to experiment with ray-casting and per-pixel data structures in DX11. 70-110 fps on AMD HD5970 12800x800 -- 9 shadow rays per pixel 32x32x32 grid. -- ~6000 blocker triangles per frame 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Thanks Holger Grün, Nicolas Thibieroz, Justin Hensley, Abe Wiley, Dan Roeger, David Hoff, and Tom Frisinger – AMD Chris Oat – Rockstar New England Jakub Klarowicz – Techland 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course References Yang J., Hensley J., Grün H., Thibieroz N.: Real-Time Concurrent Linked List Construction on the GPU. In Rendering Techniques 2010: Eurographics Symposium on Rendering (2010), vol. 29, Eurographics. Grün H., Thibieroz N.: OIT and Indirect Illumination using DX11 Linked Lists. In Proceedings of Game Developers Conference 2010 (Mar. 2010). http://developer.amd.com/gpu_assets/OIT%20and%20Indirect%20Illumination%20using%20DX11%20Linked%20Lists_forweb.ppsx 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Advances in Real-Time Rendering Course Questions? http://developer.amd.com/samples/demos/pages/ATIRadeonHD5800SeriesRealTimeDemos.aspx 7/28/2010 Advances in Real-Time Rendering Course Siggraph 2010, Los Angeles, CA

Code Example RWStructuredBuffer RWStructuredCounter; RWTexture2D<int> tRWFragmentListHead; RWTexture2D<float4> tRWFragmentColor; RWTexture2D<int2> tRWFragmentDepthAndLink; [earlydepthstencil] void PS( PsInput input ) { float4 vFragment = ComputeFragmentColor(input); int2 vScreenAddress = int2(input.vPositionSS.xy); // Get counter value and increment int nNewFragmentAddress = RWStructuredCounter.IncrementCounter(); if ( nNewFragmentAddress == FRAGMENT_LIST_NULL ) { return; } // Update head buffer int nOldFragmentAddress; InterlockedExchange(tRWFragmentListHead[vScreenAddress], nNewHeadAddress, nOldHeadAddress ); // Write the fragment attributes to the node buffer int2 vAddress = GetAddress( nNewFragmentAddress ); tRWFragmentColor[vAddress] = vFragment; tRWFragmentDepthAndLink[vAddress] = int2( int(saturate(input.vPositionSS.z))*0x7fffffff), nOldFragmentAddress ); return; }