SDK White Paper. HLSL Blood Shader Gravity Maps

Similar documents
SDK White Paper. Vertex Lighting Achieving fast lighting results

SDK White Paper. Matrix Palette Skinning An Example

Technical Report. Anisotropic Lighting using HLSL

User Guide. Vertex Texture Fetch Water

Application Note. NVIDIA Business Platform System Builder Certification Guide. September 2005 DA _v01

White Paper. Soft Shadows. February 2007 WP _v01

SDK White Paper. Occlusion Query Checking for Hidden Pixels

White Paper. Denoising. February 2007 WP _v01

SDK White Paper. Soft Shadows

User Guide. TexturePerformancePBO Demo

Multi-View Soft Shadows. Louis Bavoil

Order Independent Transparency with Dual Depth Peeling. Louis Bavoil, Kevin Myers

GPU LIBRARY ADVISOR. DA _v8.0 September Application Note

User Guide. GPGPU Disease

Technical Brief. AGP 8X Evolving the Graphics Interface

NVIDIA nforce 790i SLI Chipsets

White Paper. Texture Arrays Terrain Rendering. February 2007 WP _v01

Android PerfHUD ES quick start guide

Technical Brief. LinkBoost Technology Faster Clocks Out-of-the-Box. May 2006 TB _v01

Enthusiast System Architecture Certification Feature Requirements

Sparkling Effect. February 2007 WP _v01

Technical Report. GLSL Pseudo-Instancing

NVWMI VERSION 2.18 STANDALONE PACKAGE

GRID SOFTWARE FOR RED HAT ENTERPRISE LINUX WITH KVM VERSION /370.28

CUDA Particles. Simon Green

Technical Brief. NVIDIA Quadro FX Rotated Grid Full-Scene Antialiasing (RG FSAA)

NVWMI VERSION 2.24 STANDALONE PACKAGE

White Paper. Solid Wireframe. February 2007 WP _v01

Technical Brief. NVIDIA and Microsoft Windows Vista Getting the Most Out Of Microsoft Windows Vista

Soft Particles. Tristan Lorach

User Guide. GLExpert NVIDIA Performance Toolkit

Deinterleaved Texturing for Cache-Efficient Interleaved Sampling. Louis Bavoil

GLExpert NVIDIA Performance Toolkit

NVIDIA SDK. NVMeshMender Code Sample User Guide

White Paper. Perlin Fire. February 2007 WP _v01

Constant-Memory Order-Independent Transparency Techniques

Horizon-Based Ambient Occlusion using Compute Shaders. Louis Bavoil

Technical Report. Mesh Instancing

High Quality DXT Compression using OpenCL for CUDA. Ignacio Castaño

GRID SOFTWARE FOR MICROSOFT WINDOWS SERVER VERSION /370.12

SDK White Paper. Video Filtering on the GPU. Eric Young NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050

NSIGHT ECLIPSE PLUGINS INSTALLATION GUIDE

Cg Toolkit. Cg 2.0 January 2008 Release Notes

User Guide. DU _v01f January 2004

Cg Toolkit. Cg 2.1 beta August 2008 Release Notes

Cg Toolkit. Cg 1.2 Release Notes

Cg Toolkit. Cg 2.1 October 2008 Release Notes

Histogram calculation in OpenCL. Victor Podlozhnyuk

Cg Toolkit. Cg 2.0 May 2008 Release Notes

Technical Report. Non-Power-of-Two Mipmap Creation

Tuning CUDA Applications for Fermi. Version 1.2

Optical Flow Estimation with CUDA. Mikhail Smirnov

NVIDIA CAPTURE SDK 6.1 (WINDOWS)

Cg Toolkit. Cg 1.3 Release Notes. December 2004

SDK White Paper. Improve Batching Using Texture Atlases

Histogram calculation in CUDA. Victor Podlozhnyuk

QUADRO SYNC II FIRMWARE VERSION 2.02

CUDA/OpenGL Fluid Simulation. Nolan Goodnight

Technical Report. SLI Best Practices

Cg Toolkit. Cg 1.4 rc 1 Release Notes

Technical Report. SLI Best Practices

Cg Toolkit. Cg 2.2 April 2009 Release Notes

User Guide. Melody 1.2 Normal Map Creation & Multiple LOD Generation

Technical Brief. FirstPacket Technology Improved System Performance. May 2006 TB _v01

Semantic and Annotation Remapping in FX Composer

NVIDIA CAPTURE SDK 7.1 (WINDOWS)

NVIDIA CAPTURE SDK 6.0 (WINDOWS)

NVIDIA DEBUG MANAGER FOR ANDROID NDK - VERSION 8.0.1

CUDA Particles. Simon Green

Skinned Instancing. Bryan Dudash

PASCAL COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

VIRTUAL GPU MANAGEMENT PACK FOR VMWARE VREALIZE OPERATIONS

NVIDIA SLI Mosaic Mode

Technical Brief. NVIDIA Storage Technology Confidently Store Your Digital Assets

MAXWELL COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

GRID VIRTUAL GPU FOR HUAWEI UVP Version ,

Cg Toolkit. Cg 2.2 February 2010 Release Notes

MOSAIC CONTROL DISPLAYS

Cg Toolkit. Cg 1.2 User s Manual Addendum

Rain. Sarah Tariq

Getting Started. NVIDIA CUDA C Installation and Verification on Mac OS X

KEPLER COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

NVIDIA CUDA C GETTING STARTED GUIDE FOR MAC OS X

Getting Started. NVIDIA CUDA Development Tools 2.3 Installation and Verification on Mac OS X

GRID VIRTUAL GPU FOR HUAWEI UVP Version /

Tegra 250 Development Kit Android Setup Experience

GRID VGPU FOR VMWARE VSPHERE Version /

Particle Simulation using CUDA. Simon Green

RMA PROCESS. vr384 October RMA Process

Getting Started. NVIDIA CUDA Development Tools 2.2 Installation and Verification on Mac OS X. May 2009 DU _v01

CUDA TOOLKIT 3.2 READINESS FOR CUDA APPLICATIONS

NVIDIA CUDA GETTING STARTED GUIDE FOR MAC OS X

CUDA-GDB: The NVIDIA CUDA Debugger

QUADRO WORKSTATION APPLICATION ELSA MAXtreme Release Notes. Based on Version

NVIDIA Quadro K6000 SDI Reference Guide

User Guide. NVIDIA Quadro FX 4700 X2 BY PNY Technologies Part No. VCQFX4700X2-PCIE-PB

NVBLAS LIBRARY. DU _v6.0 February User Guide

INLINE PTX ASSEMBLY IN CUDA

PNY Technologies, Inc. 299 Webro Rd. Parsippany, NJ Tel: Fax:

VIRTUAL GPU LICENSE SERVER VERSION

Transcription:

SDK White Paper HLSL Blood Shader Gravity Maps WP-01389-001_v01 July 2004

Preface Gravity Maps With the arrival of programmable pixel shaders, it has become possible to render the world around us in a more convincing and precise manner. A side effect of this increased aesthetic realism is an increase in the correct nature of the physics involved in the rendering process. This increase in accuracy is driven by the demands of techniques such as dot3 bump mapping which require the realistic behavior of surfaces and light. Borrowing from the same concepts that allow the evaluation of lighting equations on a per pixel basis, you can compute physical properties such as gravity at each point. Given this ability to define gravity at each point you can realistically model the dynamics of a fluid across an arbitrary surface. Kevin Myers kmyers@nvidia.com NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050 SDK-00876-001_v01 2

Introduction This white paper describes a method for animating fluids across an arbitrary surface. It assumes familiarity with dot3 bump mapping techniques (Per Pixel Lighting Intro by Sim Dietrich). The shader utilizes a normal map to compute a per-pixel gravity value which is then used to animate a fluid, stored in a height map. The effect is accomplished using HLSL and PS 2.0. Creating a Gravity Map In the preparation of a Gravity Map you must first consider the information that a normal map already presents. With a normal map consisting of per pixel normals stored in an RGB texture, you have a description of the direction the surface points in, at each point. If gravity were defined as being a vector in the negative z direction, the x and y components of the normal would define the pull of gravity across texture space. The z component can be ignored since the movement is about a plane. Therefore if you were to compute gravity in texture space, a normal map with the z component removed would be sufficient. The remaining x and y components form a 2-D vector that is a ratio of the force of gravity at that point. The problems with using normal maps to define gravity are the same as those that show up in dot3 bump mapping the information is defined in tangent space. In reality, gravity direction is a constant vector defined in world space, much like a light vector. Therefore just as the light vector used in dot3 bump mapping, you need to move the gravity vector into tangent space. To accomplish this, apply the WorldTranspose transformation, followed by an ObjectToTangent space transformation moving gravity into tangent space. Once the gravity is in tangent space, the x and y components serve as a 2-D directional vector for gravitational movement. To determine the final directional vector, take the sum of this 2-D gravity vector and the x and y components of the pixel s normal. This final 2-D vector then yields the direction that an object will move across the surface in tangent space. As shown in Figure 1, ignore the z value and use the x and y components to dictate direction. Since gravity and normal vectors are normalized the x and y components can range from -2 to 2. However, any value outside the range -1 to 1 is indicative of a surface that has been tilted upside down. In this case the object falls off the surface, it does not move across the texture. Apply this process to each point across the surface determining a unique gravity vector for each point. To create a more viscous fluid that responds in a sharper manner to surface details, raise the gravity vector to the third power. This creates a sort of attenuation that ramps the effect of gravity. Finally, write out the x and y components to r and g respectively. Since our values can range from -1 to 1, you need to pack the vector applying the equation 1/2 * x +.5. SDK-00876-001_v01 3

Blood Shader Animating Blood At this point, you have defined gravity at every point and saved it out to a texture. You can now use it to animate fluids. Remember that the shader is a self-feeding process with the amount of fluid, in this case blood, stored in a height map. The height map is defined in the unused b component of the gravity map. Every frame the shader reads the height value of the blood at each texel, as well as the 2-D gravity vector. It then subtracts from the current texel whatever percentage its gravity vector states it will lose this frame. Finally, it checks its four neighbors for any fluid that may be coming into the current texel. To compute how much blood will fall into the current texel, the shader must sample the gravity map values of the four neighbors. Each of the four texels left, right, above, and below is checked for gravity vectors pointing in the direction of the current texel. For instance, in checking the neighbor above the current texel the shader looks at the y (green) component. Anything in the range of 0 to -1 (unpacked) gives the fraction of blood that this texel will take. This fraction is then multiplied by the height of the blood at the neighbor as given in the equation abs(texelabove.y) * TexAbove.b. This value is computed for all four neighbors and added to the current texels height. Finally, if the current texels blood height is greater than a predefined minimum, the generation of the gravity map is again performed for the next frame. This cycle continues to repeat until there are no longer any texels with blood high enough (predefined) to move. Figure 1. Animating Blood SDK-00876-001_v01 4

Blood Shader Displaying the Horror The final product of this shader is a continuously changing height map with a 2-D gravity induced directional vector defined at each point. Visually, the goal is produce the effect of a thick fluid oozing across a surface. The height map contains information regarding the intensity of the color for each point. Take this value and multiply it by a given blood color. This yields a final blood color contribution which is added to the color of the surface material. In order to increase the intensity of the blood color, decrease the color contribution of the surface by a factor of (1 BloodHeight). For added realism, compute deltas for the blood height of each texel based on its neighbors. Derive dx = LeftHeight RightHeight and dy = BelowHeight AboveHeight. These values are then added to the surface normal to give the effect of a thick fluid. The final product uses a simple moving specular light to show bump mapped blood, dripping down a wall, animated entirely on the GPU. SDK-00876-001_v01 5

Bibliography Per Pixel Lighting Intro Sim Dietrich http://developer.nvidia.com/attach/1659 SDK-00876-001_v01 6

Notice ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, MATERIALS ) ARE BEING PROVIDED AS IS." NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. Information furnished is believed to be accurate and reliable. However, NVIDIA Corporation assumes no responsibility for the consequences of use of such information or for any infringement of patents or other rights of third parties that may result from its use. No license is granted by implication or otherwise under any patent or patent rights of NVIDIA Corporation. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. NVIDIA Corporation products are not authorized for use as critical components in life support devices or systems without express written approval of NVIDIA Corporation. Trademarks NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA Corporation. Other company and product names may be trademarks of the respective companies with which they are associated. Copyright 2004 NVIDIA Corporation. All rights reserved NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050 www.nvidia.com