Featured SDK Code Samples
In each release of our SDK you'll find hundreds of code samples, effects,
and tools to help you take advantage of the
latest in graphics technology. Check out the SDK home page
for the latest version of the complete SDK, or browse through individual code samples below. You can also click on the
images to see a gallery of larger images.
|
|
|
|
Dynamic Ambient Occlusion
OpenGL
|
|
This example demonstrates a new technique for computing diffuse light transfer and shows how it can be used to compute global illumination for animated scenes. This technique is efficient enough when implemented on a fast GPU to calculate ambient occlusion and indirect lighting data on the fly for each rendered frame. It does not have the limitations of precomputed radiance transfer (PRT) or precomputed ambient occlusion techniques, which are limited to rigid objects that do not move relative to one another. The technique works by treating polygon meshes as a set of surface elements that can emit, transmit, or reflect light and that can shadow each other. This method is efficient because it works without calculating the visibility of one element to another. Instead, it uses a much simpler and faster technique that uses shadowing to account for occluding (blocking) geometry.
|
|
|
Whitepaper
Download
|
|
Antialiasing with Post-Processing
DirectX 9
|
|
An antialiased backbuffer is read as the source image for a post-processing effect which creates a green glow. The IDirect3DDevice9::StretchRect() function is used to copy the antialiased image to a render-target texture for post-processing. Using this function is better than rendering the scene to a render-target texture in the first place.
|
|
|
Whitepaper
Download
|
|
GPU Cloth
DirectX 9
|
|
This sample demonstrates how to use Shader Model 3.0 to simulate and render cloth on the GPU. The cloth vertex positions are computed through several pixel shaders and saved into a texture. A vertex shader then reads these positions using Vertex Texture Fetch (VTF) to render the cloth.
|
|
|
Whitepaper
Download
|
|
Snow Accumulation
DirectX 9
|
|
This sample shows a technique for procedurally adding snow to a non snow scene.
|
|
|
Download
|
|
GPU Filter for Photoshop(tm)
OpenGL
|
|
This code example implements a Photoshop™ filter plugin that performs its key pixel operations using GLSL shaders. Docs are included to guide developers who desire to use GLSL in Photoshop on their own. This code sample requires the use of Adobe's Photoshop CS API toolkit, which is available to registered developers directly from Adobe Systems. If you just want to use the filter without compiling the source, move the enclosed GPUFilter.8bf to your local Photoshop Plugins\Filters folder.
|
|
|
Whitepaper
Download
|
|
QuerySample
DirectX 9
|
|
Shows how to check for availability and use of the various query types supported in DirectX9. This sample queries for and displays results for queries of type: event, occlusion, timestamp, timestamp frequency, timestamp disjoint, and if running with the debug runtime, resource and vertex stats.
|
|
|
Download
|
|
|
|
Stencil Shadow Volume Extrusion
DirectX 9
|
|
In this sample, vertex shaders are used to extrude polygon objects into stencil shadow volumes. This avoids the CPU cost of computing shadow volumes and updating the shadow volume vertex buffers. It requires more memory to store additional face vertices and zero-area triangles for the automatic shadow volume extrusion.
|
|
|
Download
|
|
Mandelbrot
DirectX 9
|
|
PS.3.0 shaders and fp32 render target textures are used to compute the Mandelbrot set fractal on the GPU. This demonstrates ps.3.0 branching and the accuracy of fp32 rendering. Zoom in to the set by left-clicking, and zoom out by right-clicking. The demo can also render the Julia set for the point at the center of the current Mandelbrot view.
|
|
|
Whitepaper
Download
|
|
HDR with 2x FP16 MRTs
DirectX 9
|
|
This sample shows some tricks with floating point render targets to squeeze more frames per second from an HDR application. By using two G16R16F render targets and MRT, you can achieve from 20 to 40% speed increase on the GeForce 6 series. All HDR maps are courtesy of Paul Debevec (www.debevec.org).
|
|
|
Download
|
|
DXSAS Sample Implementation 0.8
DirectX 9
|
|
This sample demonstrates how to implement a DirectX Semantics and Annotations (DXSAS) ScriptExecute parser in an engine. Full support for the standard annotations and semantics is provided. The user interface lets you apply multiple scene and model effects simultaneously, so the you can see hundreds of different effect combinations. All effect files were developed using FX Composer.
|
|
|
Download
|
|
Video Filter
DirectX 9
|
|
This sample demonstrates how apply shader effects onto two videos and composite them together with pixel shaders. Shaders are used to perform YUV2RGB color conversion, Color Correction, and effects like sephia, blur, sharpen, luminance edge detection, fade, and radial blur.
|
|
|
Whitepaper
Download
|
|
PBO Texture Performance
OpenGL
|
|
Explores various ways to use OpenGL pixel buffer objects (PBOs). This code sample can also be used to see the maximum bus-transfer rates for textures to and from the GPU.
|
|
|
Download
|
|
|
|
Multiple Draw Buffers
OpenGL
|
|
This simple example illustrates the use of the ATI_draw_buffers extension to render to multiple draw buffers simultaneously. Instead of outputing a single color value, a fragment program can now output up to 4 different color values to 4 separate buffers. This feature is supported on all GeForce 6 series GPUs. It is known as "Multiple Render Targets" in Direct3D.
|
|
|
Download
|
|
GPGPU Disease
OpenGL
|
|
This sample creates a disturbing dynamic disease effect. It simulates a phenomenon known as chemical reaction-diffusion, by solving the governing partial differential equations in a fragment program. The result is an endless variety of changing patterns that are then used to generate bump and texture maps which are applied to a mesh with various shaders.
|
|
|
Download
|
|
GPGPU Fluid
OpenGL
|
|
This code sample demonstrates fast, realistic fluid dynamics simulation on the GPU. The sample solves the Navier-Stokes equations for incompressible fluid flow using a technique originally presented at SIGGRAPH 1999 by Jos Stam. The sample allows the user to draw arbitrary obstacles and flow viscous or inviscid fluid around them.
|
|
|
Whitepaper
Download
|
|
Simple Soft Shadows
OpenGL
|
|
This sample demonstrates how branching in fragment programs can be used to optimize soft shadow rendering in OpenGL. This technique could also be applied to accelerate other filtering algorithms to increase performance significantly on GPUs that support Shader Model 3.0.
|
|
|
Whitepaper
Download
|
|
Soft Shadows
DirectX 9
|
|
This sample shows how to use conditional branching to compute filtered soft shadows efficiently. This technique could also be applied to accelerate other filtering algorithms to increase performance significantly on GPUs that support Shader Model 3.0.
|
|
|
Whitepaper
Download
|
|
|
|
HDR Deferred Shading
DirectX 9
|
|
This sample shows high dynamic range (HDR) lighting combined with deferred shading. Deferred shading is a technique where the components of the lighting equation (surface attributes like the normal, position, albedo, etc.) are rendered into multiple screensized render targets (MRTs). Lighting is then done using geometrically simple passes over these MRT buffers, fetching the components of the lighting equation and outputting lighting results. This results in less shaded depth complexity, less geometry processing, better batching, and a cleaner rendering pipeline. The high dynamic range comes from the lighting passes being accumulated using fp16 blending into a floating point render target, after which tone mapping and a bloom effect are done using fp16 filtering to get the HDR results into the displayable 0..1 range.
|
|
|
Download
|
|
Simple NV_fragment_program2
OpenGL
|
|
This simple example demonstrates the use of the NV_fragment_program2 extension, including looping and branching in fragment programs, and fast normalization of fp16 vectors using the "NRM" instruction. The example uses this functionality to implement multiple per-pixel lights in a single pass. NV_fragment_program2 is only available on GeForce 6 series GPUs.
|
|
|
Download
|
|
16-bit Floating Point Blending and Filtering
OpenGL
|
|
This simple example demonstrates 16-bit floating point blending and texture filtering. It repeatedly renders an OpenEXR-format image to a 16-bit floating point p-buffer with additive blending, and then uses a fragment program to display the results to the screen. The exposure multiplier value can be increased and decreased using the '+' and '-' keys.
|
|
|
Download
|
|
Simple Vertex Texture
OpenGL
|
|
This simple example demonstrates the use of the NV_vertex_program3 extension to perform texture look-ups in a vertex program. It uses this feature to perform simple displacement mapping. The example also shows how to implement bilinear filtering of vertex texture fetches.
|
|
|
Download
|
|
Instancing
DirectX 9
|
|
This sample makes use of Microsoft's Direct3D9 Instancing group to render thousands of meshes on the screen with only a handful of draw calls, thus saving CPU time. This is a great technique for trees, rocks, grass, RTS units and other similar groups of similar, but perhaps not identical items.
|
|
|
Whitepaper
Download
|
|
High Dynamic Range Rendering
OpenGL
|
|
This example demonstrates how to implement simple high-dynamic range rendering in OpenGL on both GeForce FX and GeForce 6 series GPUs. It loads environment map images in the Radiance ".hdr" format and uses these to light simple 3D objects. On GeForce FX series GPUs it uses two "HILO" format cubemaps (16-bit integer). On GeForce 6 series GPUs it uses 16-bit floating point cube maps with texture filtering. The example also implements a glow post-processing effect using a separarable Gaussian blur.
|
|
|
Download
|