d3dx 8.1 anuj gosalia development lead directx ® graphics microsoft ® corporation
Post on 22-Dec-2015
220 views
TRANSCRIPT
D3DX 8.1 D3DX 8.1
Anuj GosaliaAnuj GosaliaDevelopment LeadDevelopment LeadDirectXDirectX®® GraphicsGraphics
MicrosoftMicrosoft®® Corporation Corporation
D3DX ReleasesD3DX Releases
Shipped D3DX 8.0 with DirectX 8.0 SDKShipped D3DX 8.0 with DirectX 8.0 SDK D3DX 8.0b released to WebD3DX 8.0b released to Web
Bug fixes to D3DX 8.0, no new featuresBug fixes to D3DX 8.0, no new features
D3DX 8.1D3DX 8.1 Includes new featuresIncludes new features Now in BetaNow in Beta
Overview Of D3DX 8.1Overview Of D3DX 8.1
Mesh UtilitiesMesh Utilities Effect FrameworkEffect Framework
Shader assemblersShader assemblers
Texture UtilitiesTexture Utilities Math UtilitiesMath Utilities Miscellaneous UtilitiesMiscellaneous Utilities Authoring tool supportAuthoring tool support
Mesh LibraryMesh Library
Progressive meshesProgressive meshes N-Patch tessellationN-Patch tessellation Mesh optimizationMesh optimization Skinned meshesSkinned meshes Other mesh utilitiesOther mesh utilities
Bounding volume generation (sphere, box)Bounding volume generation (sphere, box) Ray intersections (mesh, sphere, box)Ray intersections (mesh, sphere, box) Mesh cleanupMesh cleanup More…More…
Mesh BasicsMesh Basics
Vertex Buffer, Index Buffer, Vertex Buffer, Index Buffer, and Attributesand Attributes
Indexed Triangle listsIndexed Triangle lists 16/32-bit indices supported16/32-bit indices supported Supports file I/O (via .X)Supports file I/O (via .X) Can be used independently of .X filesCan be used independently of .X files DrawSubset is only for convenienceDrawSubset is only for convenience
Not the only way to draw a meshNot the only way to draw a mesh Manipulates adjacency if requestedManipulates adjacency if requested
Attributes: Buffer? Table?Attributes: Buffer? Table?
Mesh has 1 DWORD per triangle (face)Mesh has 1 DWORD per triangle (face) Stored in mesh object as Attribute BufferStored in mesh object as Attribute Buffer
Semantics of values is up to the appSemantics of values is up to the app Need not be sequentialNeed not be sequential
Attribute TableAttribute Table A compact representation A compact representation
of the attribute bufferof the attribute buffer Generated by Attribute Sorting a meshGenerated by Attribute Sorting a mesh GetAttributeTable, no SetAttributeTableGetAttributeTable, no SetAttributeTable
Mesh RenderingMesh Rendering
DrawSubset() draws all triangles DrawSubset() draws all triangles of a given attributeof a given attribute
Needs Attribute TableNeeds Attribute Table Else it does linear search per faceElse it does linear search per face
Efficient if attributes are sequential, Efficient if attributes are sequential, starting from 0starting from 0 Else it does search of attribute tableElse it does search of attribute table
Uses Fixed Function FVF shaderUses Fixed Function FVF shader Avoid unless all above conditions metAvoid unless all above conditions met
Mesh Adjacency In D3DXMesh Adjacency In D3DX
Many mesh operations Many mesh operations require adjacencyrequire adjacency
Array of 3 DWORDs per faceArray of 3 DWORDs per face Each DWORD is a face indexEach DWORD is a face index 0xffffffff means no adjacent face0xffffffff means no adjacent face
All mesh operations that change All mesh operations that change adjacency will optionally return adjacency will optionally return updated adjacencyupdated adjacency
Load from .X returns adjacencyLoad from .X returns adjacency
Point RepresentativesPoint Representatives
Alternate way of encoding adjacency infoAlternate way of encoding adjacency info Keeps track of vertices which have the same Keeps track of vertices which have the same
position but replicated due to differing position but replicated due to differing attributes (like normals, tex coords, etc.)attributes (like normals, tex coords, etc.)
One DWORD per vertexOne DWORD per vertex All vertices in a set of replicated vertices point All vertices in a set of replicated vertices point
to any one of them as a “representative”to any one of them as a “representative” Non-replicated vertices point to themselvesNon-replicated vertices point to themselves
Meshes And AdjacencyMeshes And Adjacency
Can convert from PRep to adjacency Can convert from PRep to adjacency and backand back
Generating adjacency from scratchGenerating adjacency from scratch Can use identity Prep, ignoring duplicatesCan use identity Prep, ignoring duplicates
Works in some casesWorks in some cases
GenerateAdjacecncy() will identify vertices GenerateAdjacecncy() will identify vertices with same position (i.e., infer PRep)with same position (i.e., infer PRep) Slower than aboveSlower than above Will get correct adjacency if epsilon Will get correct adjacency if epsilon
is appropriateis appropriate
Remap ArraysRemap Arrays
Describes how mesh was rearrangedDescribes how mesh was rearranged 1 DWORD for each destination face / 1 DWORD for each destination face /
vertexvertex Indicates which face / vertex of source it Indicates which face / vertex of source it
came fromcame from Many-to-one mapping possibleMany-to-one mapping possible Allows mesh related data outside mesh Allows mesh related data outside mesh
object to be updated with the meshobject to be updated with the mesh
Mesh OptimizationMesh Optimization
StripifyStripify Rearrange vertices of a mesh in strip orderRearrange vertices of a mesh in strip order
Vertex cache optimizeVertex cache optimize Based on Hugues Hoppe’s Based on Hugues Hoppe’s
Siggraph ‘99 paperSiggraph ‘99 paper Hardware specific optimizationHardware specific optimization
Both need adjacency informationBoth need adjacency information ConvertPointRepsToAdjacency with NULL ConvertPointRepsToAdjacency with NULL
(identity) PRep array will suffice(identity) PRep array will suffice
Mesh OptimizationMesh Optimization
Attribute sortAttribute sort Sorts faces and vertices on the Sorts faces and vertices on the
attribute idsattribute ids Splits shared vertices if necessarySplits shared vertices if necessary Generates Attribute TableGenerates Attribute Table
Compact MeshCompact Mesh Eliminates vertices not referred to Eliminates vertices not referred to
by the index arrayby the index array
Sharing Vertex BuffersSharing Vertex Buffers
Typically Optimize re-arranges vertices Typically Optimize re-arranges vertices and indicesand indices
If vertices already ordered by attribute, If vertices already ordered by attribute, src & dest mesh can share VBssrc & dest mesh can share VBs
D3DXMESHOPT_SHAREVBD3DXMESHOPT_SHAREVB Useful for clones and optimizingUseful for clones and optimizing
Offline cache optimizationOffline cache optimization
Best done at load timeBest done at load time Algorithm is fastAlgorithm is fast
““Default” is Geforce 1,2Default” is Geforce 1,2 Works well on all cardsWorks well on all cards
Optimize on above or card with no Optimize on above or card with no hardware T&Lhardware T&L
Meshes and Tri-StripsMeshes and Tri-Strips
D3DXConvertMeshSubsetToStripsD3DXConvertMeshSubsetToStrips D3DXConvertMeshSubsetToSingleStripD3DXConvertMeshSubsetToSingleStrip Returns new Index Buffer separate from Returns new Index Buffer separate from
the mesh objectthe mesh object Works on any meshWorks on any mesh
Helps to optimize it for vertex cache or Helps to optimize it for vertex cache or stripifystripify
May be a performance win in some May be a performance win in some specific casesspecific cases
Use OptimizeMesh sample to see what Use OptimizeMesh sample to see what works bestworks best
Progressive MeshesProgressive MeshesOverviewOverview
Generate an ID3DXPMesh object from Generate an ID3DXPMesh object from high poly-count mesh using high poly-count mesh using ID3DXSPMesh objectID3DXSPMesh object Done either offline or load timeDone either offline or load time
Render the ID3DXPMesh object at any Render the ID3DXPMesh object at any LOD at runtimeLOD at runtime
Generate a bunch of ID3DXMesh Generate a bunch of ID3DXMesh objects from ID3DXPMesh objectobjects from ID3DXPMesh object
Progressive MeshesProgressive MeshesMesh SimplificationMesh Simplification
Based on Garland-Heckbert Based on Garland-Heckbert quadric error metricquadric error metric
Incorporates refinements by Hugues Incorporates refinements by Hugues Hoppe to accommodate normal and Hoppe to accommodate normal and attribute space metricsattribute space metrics
Needs accurate adjacency informationNeeds accurate adjacency information
Progressive MeshesProgressive MeshesMesh Simplification(2)Mesh Simplification(2)
API for simplification via ID3DXSPMesh objectAPI for simplification via ID3DXSPMesh object No more batch files No more batch files Allows you to incorporate automated LOD Allows you to incorporate automated LOD
generation in your internal toolsgeneration in your internal tools
User controls to influence simplification User controls to influence simplification processprocess Assigning weights to verticesAssigning weights to vertices Weighing the importance of various vertex attributesWeighing the importance of various vertex attributes
Progressive MeshesProgressive MeshesHalf-edge collapsesHalf-edge collapses
Chooses one of the two original vertices Chooses one of the two original vertices during each edge collapseduring each edge collapse
No significant quality degradationNo significant quality degradation Mesh vertices never change with LODMesh vertices never change with LOD
Enables mixing PM and mesh deformation Enables mixing PM and mesh deformation algorithms like morphing and skinningalgorithms like morphing and skinning
Reduces the amount of information Reduces the amount of information stored in a vertex split recordstored in a vertex split record LOD changes are fasterLOD changes are faster
Progressive MeshesProgressive MeshesDynamic LOD changesDynamic LOD changes
ID3DXPMesh object allows dynamic ID3DXPMesh object allows dynamic LOD changes to arbitrary LOD changes to arbitrary face/vertex countsface/vertex counts
LOD changes are fast enough LOD changes are fast enough to do at runtimeto do at runtime
Modifies the index buffer and Modifies the index buffer and the adjacencythe adjacency
Progressive MeshesProgressive MeshesCloningCloning
Support sharing the vertex data Support sharing the vertex data across clonesacross clones
Can “clone” multiple ID3DXMesh Can “clone” multiple ID3DXMesh objects from a progressive mesh, all objects from a progressive mesh, all of which share the same VBof which share the same VB Can even optimize the resultant mesh while Can even optimize the resultant mesh while
sharing the original VBsharing the original VB
Progressive MeshesProgressive MeshesPersistencyPersistency
Persist to IStreamPersist to IStream Can embed PMs in any custom file formatCan embed PMs in any custom file format
ID3DXPMesh::SaveID3DXPMesh::Save D3DXCreatePMeshFromStreamD3DXCreatePMeshFromStream
Progressive MeshesProgressive MeshesOptimizationOptimization
PMesh face ordering may not be PMesh face ordering may not be cache optimalcache optimal
Can at least make base mesh optimizedCan at least make base mesh optimized ID3DXPMesh::OptimizeBaseLODID3DXPMesh::OptimizeBaseLOD
Use multiple clones of PMesh with Use multiple clones of PMesh with increasing base LODsincreasing base LODs ID3DXPMesh::TrimByVerticesID3DXPMesh::TrimByVertices ID3DXPMesh::TrimByFacesID3DXPMesh::TrimByFaces Can share VB across clonesCan share VB across clones
Switch to PMesh with highest base LODSwitch to PMesh with highest base LOD
N-Patch TessellationN-Patch Tessellation
D3DX provides software N-Patch D3DX provides software N-Patch tessellationtessellation
Uses adjacency to share vertices Uses adjacency to share vertices in tessellated meshin tessellated mesh
Assumes mesh is smoothAssumes mesh is smooth Any sharp edges due to normal Any sharp edges due to normal
discontinuity will cause cracksdiscontinuity will cause cracks Use D3DXWeldVertices to merge normals Use D3DXWeldVertices to merge normals
within epsilonwithin epsilon Improved in D3DX 8.1 to make Improved in D3DX 8.1 to make
welding normals lot easierwelding normals lot easier
Other Mesh UtilitiesOther Mesh Utilities
Compute bounding box and sphereCompute bounding box and sphere Compute normalsCompute normals Ray mesh intersectionRay mesh intersection
Returns triangle index and barycentric Returns triangle index and barycentric coordinates of point of intersection if hitcoordinates of point of intersection if hit
Ray box and sphere intersectionRay box and sphere intersection Clean-up topology for simplificationClean-up topology for simplification Cloning for VB and IB format Cloning for VB and IB format
conversionconversion
Mesh Library ImprovementsMesh Library Improvements
D3DXSplitMeshD3DXSplitMesh Use to split large 32-bit meshes into Use to split large 32-bit meshes into
multiple 16-bit meshesmultiple 16-bit meshes Splits shared verticesSplits shared vertices
Minimized if mesh is vertex cache optimizedMinimized if mesh is vertex cache optimized
D3DXWeldVerticesD3DXWeldVertices Takes per component epsilonsTakes per component epsilons Does partial weldsDoes partial welds
Mesh IntersectionMesh Intersection
Intersect ray with tri, mesh or mesh Intersect ray with tri, mesh or mesh subsetsubset
Returns face and barycentric Returns face and barycentric coordinates of intersectioncoordinates of intersection
Optionally returns list of all Optionally returns list of all intersectionsintersections
Needs no precomputationNeeds no precomputation Efficient algorithm for hit testing, etcEfficient algorithm for hit testing, etc Not efficient for too many intersections for Not efficient for too many intersections for
the same meshthe same mesh
Compute Tangent SpaceCompute Tangent Space
Create a per vertex coordinate systemCreate a per vertex coordinate system Normal define one axisNormal define one axis Texture coordinate (u,v) gradients Texture coordinate (u,v) gradients
used to orient tangentsused to orient tangents Use u to define one tangent & compute Use u to define one tangent & compute
binorm by cross productbinorm by cross product Or use u & v to define both tangentsOr use u & v to define both tangents
Compute Tangent Space (2)Compute Tangent Space (2)
Mesh texture parameterizations can Mesh texture parameterizations can have orientation flipshave orientation flips
Cross product binormal can be reverse Cross product binormal can be reverse from v space gradient in some partsfrom v space gradient in some parts
Solution: Encode binormal sign per Solution: Encode binormal sign per vertexvertex Use 4D vector for encoding per-vertex Use 4D vector for encoding per-vertex
tangenttangent Put sign in 4Put sign in 4thth component component Invert computed binormal in vertex shaderInvert computed binormal in vertex shader
Skinned MeshesSkinned Meshes
Plug-ins for authoring tools to export Plug-ins for authoring tools to export skinning dataskinning data 3D Studio Max and Character Studio3D Studio Max and Character Studio Maya (work in progress)Maya (work in progress)
.X files extended to handle .X files extended to handle skinning dataskinning data D3DX functions to load skinned meshesD3DX functions to load skinned meshes
ID3DXSkinMesh independent of .X filesID3DXSkinMesh independent of .X files
Skinned Mesh ObjectSkinned Mesh Object
Contains a mesh object plus Contains a mesh object plus skinning dataskinning data
Skinning data supplied as a bone Skinning data supplied as a bone and a list of vertices it affectsand a list of vertices it affects And a weight corresponding to each vertexAnd a weight corresponding to each vertex
Though not hardware friendly, this input Though not hardware friendly, this input method is simple and generalmethod is simple and general
Can convert to optimized formsCan convert to optimized forms
Skinning Technique #1Skinning Technique #1
Direct3DDirect3D®® 7.0 style 7.0 style Per vertex weightsPer vertex weights Up to 4 bones (matrices) per triangleUp to 4 bones (matrices) per triangle
Or patch if using R/T-PatchesOr patch if using R/T-Patches
ConvertToBlendedMesh generates ConvertToBlendedMesh generates a mesh with per vertex weightsa mesh with per vertex weights
Can cause mesh to have Can cause mesh to have many “subsets”many “subsets”
Works with well N-Patch tessellationWorks with well N-Patch tessellation
Skinning Technique #2Skinning Technique #2
Introduced in Direct3D 8.0Introduced in Direct3D 8.0 Per vertex indices refer to matrices from Per vertex indices refer to matrices from
a palette that affect it a palette that affect it Up to 4 indices per vertex, 12 per faceUp to 4 indices per vertex, 12 per face Up to 256 matrices in a paletteUp to 256 matrices in a palette
Reduces API calls and matrix changesReduces API calls and matrix changes ConvertToIndexedBlendedMesh ConvertToIndexedBlendedMesh
generates mesh with per vertex weights generates mesh with per vertex weights and matrix indicesand matrix indices
Skinning Technique #3Skinning Technique #3
Software skinning in D3DXSoftware skinning in D3DX Arbitrary number of influences Arbitrary number of influences
per vertexper vertex Useful for skinning curved surface Useful for skinning curved surface
control meshcontrol mesh Useful for accessing post skinned Useful for accessing post skinned
mesh datamesh data Hit testing skinned meshesHit testing skinned meshes
GenerateSkinnedMesh() / GenerateSkinnedMesh() / UpdateSkinnedMesh() does thisUpdateSkinnedMesh() does this
ConvertToBlendedMeshConvertToBlendedMesh
Truncates bone influences when Truncates bone influences when >4 per triangle exists>4 per triangle exists Keeps the 4 most important weightsKeeps the 4 most important weights Uses adjacency info to avoid cracksUses adjacency info to avoid cracks
Orders bone combinations by Orders bone combinations by increasing # of influencesincreasing # of influences Enables using GeForce’s restricted Enables using GeForce’s restricted
skinned support by rendering a prefix skinned support by rendering a prefix of the mesh in hardwareof the mesh in hardware
Use software for the restUse software for the rest
ConvertToIndexedBlended…ConvertToIndexedBlended…
Will truncate if >4 influences per vertexWill truncate if >4 influences per vertex Handles palette sizes < num bonesHandles palette sizes < num bones
But must be > maxFaceInflBut must be > maxFaceInfl
Partitions mesh into subsets that Partitions mesh into subsets that fit in a palettefit in a palette
Output can be used with vertex shadersOutput can be used with vertex shaders Output mesh has only necessary # Output mesh has only necessary #
of weightsof weights Use Clone to pad extra weights if shader Use Clone to pad extra weights if shader
expects fixed #expects fixed #
Skinning PerformanceSkinning Performance
Minimize # of bone combinations?Minimize # of bone combinations? Can merge subset combinationsCan merge subset combinations Increases # of blendsIncreases # of blends
Improve matrix coherence across Improve matrix coherence across combinations?combinations? Can’t prevent extra DrawPrim callsCan’t prevent extra DrawPrim calls Can’t prevent matrix concatenationCan’t prevent matrix concatenation Does not seem worthwhileDoes not seem worthwhile
Skinning Performance (2)Skinning Performance (2)
Non-hardware T&L devicesNon-hardware T&L devices Indexed palette skinning using FF pipeline Indexed palette skinning using FF pipeline
or vertex shaders is bestor vertex shaders is best
On GeForce 1,2 and Radeon, On GeForce 1,2 and Radeon, non-indexed skinning is fastestnon-indexed skinning is fastest
On Geforce 3 indexed skinning using On Geforce 3 indexed skinning using vertex shader is fastest ?vertex shader is fastest ?
Disclaimer: Your mileage may vary…Disclaimer: Your mileage may vary…
SW Skinning PerformaceSW Skinning Performace
Skin on CPU instead of GPUSkin on CPU instead of GPU CPU/GPU load balancingCPU/GPU load balancing Multipass renderingMultipass rendering
33% faster skinning in D3DX 8.133% faster skinning in D3DX 8.1 Consider using multiple streamsConsider using multiple streams
Minimize data processed by CPUMinimize data processed by CPU
Skinning PMeshesSkinning PMeshes
Skinning causes mesh to be split into Skinning causes mesh to be split into subsets, adversely affecting subsets, adversely affecting simplification qualitysimplification quality
Using Indexed skinning reduces Using Indexed skinning reduces subsets (1 if palette size >= num bones)subsets (1 if palette size >= num bones)
Call ConvertTo* and use result Call ConvertTo* and use result to create PMeshto create PMesh
Simplification And SkinningSimplification And Skinning
Simplification ignores geometry Simplification ignores geometry changes due to skinningchanges due to skinning
Default pose of mesh (figure mode?) Default pose of mesh (figure mode?) may not be best to simplifymay not be best to simplify Many joint (elbows, knees, etc.) are straightMany joint (elbows, knees, etc.) are straight Geometric error when simplifying across Geometric error when simplifying across
joints lower than would be when joint joints lower than would be when joint is bentis bent
Choose some different pose for Choose some different pose for simplification (How?)simplification (How?)
Skinning And NPatchesSkinning And NPatches
Tessellating indices is messyTessellating indices is messy Use software skinning of control point Use software skinning of control point
meshmesh Use only if hardware is doing full Use only if hardware is doing full
tessellationtessellation
Use non-indexed skinning Use non-indexed skinning of tessellated meshof tessellated mesh ConvertToBlendedMesh firstConvertToBlendedMesh first Tessellate the resultTessellate the result Update bone combination table with new Update bone combination table with new
attribute tableattribute table
Call To ActionCall To Action
Try out new features in DirectX 8.1Try out new features in DirectX 8.1 Give us feedbackGive us feedback Tell us about bugs and performance Tell us about bugs and performance
issuesissues What else would you like to see?What else would you like to see? Hang around for the next talk…Hang around for the next talk…
AcknowledgementsAcknowledgements
Thanks to Origin Systems for Thanks to Origin Systems for permission to use Unicorn modelpermission to use Unicorn model
Thanks to NewTek for permission to use Thanks to NewTek for permission to use the monster modelthe monster model
Questions ?Questions ?
D3DX 8.1 D3DX 8.1
Anuj GosaliaAnuj GosaliaDevelopment LeadDevelopment LeadDirectXDirectX®® Graphics Graphics
Microsoft CorporationMicrosoft Corporation
Overview Of D3DX 8.1Overview Of D3DX 8.1
Mesh UtilitiesMesh Utilities Effect FrameworkEffect Framework
Shader assemblersShader assemblers
Texture UtilitiesTexture Utilities Math UtilitiesMath Utilities Miscellaneous UtilitiesMiscellaneous Utilities Authoring tool supportAuthoring tool support
Effect FrameworkEffect Framework
Encapsulation of device stateEncapsulation of device state Enables scalable rendering techniquesEnables scalable rendering techniques Allows controlled fallbackAllows controlled fallback Can’t just switch to multi-passCan’t just switch to multi-pass
Older hardware can’t do more passes Older hardware can’t do more passes since alpha blending fill rate is lesssince alpha blending fill rate is less
Helps rapid prototypingHelps rapid prototyping Runtime interpretation of text-based Runtime interpretation of text-based
effect definitioneffect definition
Effect FrameworkEffect FrameworkFallback TechniquesFallback Techniques
Uses controlled effect fallbacksUses controlled effect fallbacks
EffectEffect
TechniqueTechnique
PassPassImplementationImplementation
Simple text file (.fx) to define effectsSimple text file (.fx) to define effects
Effect FrameworkEffect FrameworkFallback TechniquesFallback Techniques
Techniques are grouped by their quality Techniques are grouped by their quality or “LOD”or “LOD”
Techniques can be chosen based on Techniques can be chosen based on what hardware creates successfullywhat hardware creates successfully
Can test performance in back bufferCan test performance in back buffer User responsible for drawing geometryUser responsible for drawing geometry
Effect FrameworkEffect FrameworkCreating EffectsCreating Effects
D3DXCompileEffectFromFileD3DXCompileEffectFromFile Parses text fileParses text file
D3DXCreateEffectD3DXCreateEffect Use compiled effect to create Use compiled effect to create
an effect objectan effect object
State for each pass is encoded State for each pass is encoded as state blocksas state blocks
Effect Data typesEffect Data types
DWORD, FLOATDWORD, FLOAT VECTOR, MATRIXVECTOR, MATRIX TEXTURETEXTURE VERTEXSHADER, PIXELSHADERVERTEXSHADER, PIXELSHADER STRINGSTRING
Enables user-data associated with effectsEnables user-data associated with effects Not used to program device stateNot used to program device state
Parameterized EffectsParameterized Effects
Effects can have parameters Effects can have parameters of various typesof various types
Parameters augment static Parameters augment static state description in the .fx filesstate description in the .fx files
How (and which) parameters get How (and which) parameters get used defined by the effectused defined by the effect
Effect ImprovemetsEffect Improvemets
Support for longer namesSupport for longer names No longer limited to FourCCNo longer limited to FourCC
Enable ordinal or string based Enable ordinal or string based parameter resolutionparameter resolution
Block comment /* */ supportBlock comment /* */ support Merge ID3DXEffect and ID3DXTechniqueMerge ID3DXEffect and ID3DXTechnique
Need to carry around only 1 pointerNeed to carry around only 1 pointer
OnLost() and OnReset() methodsOnLost() and OnReset() methods
Effect FrameworkEffect FrameworkShader AssembliesShader Assemblies
In-line or load from fileIn-line or load from file VertexVertex
D3DXAssembleVertexShader()D3DXAssembleVertexShader() D3DXAssembleVertexShaderFromFile()D3DXAssembleVertexShaderFromFile()
PixelPixel D3DXAssemblePixelShader()D3DXAssemblePixelShader() D3DXAssemblePixelShaderFromFile()D3DXAssemblePixelShaderFromFile()
Shape LibraryShape Library
Regular polygonRegular polygon BoxBox Cylinder/ConeCylinder/Cone SphereSphere TorusTorus And, of course, the teapotAnd, of course, the teapot Optional adjacency info availableOptional adjacency info available
2D Text2D Text
Draw text to surface using GDIDraw text to surface using GDI Render to off screen DCRender to off screen DC Blit to an internal textureBlit to an internal texture Render using quadRender using quad
Cache output by rendering to a textureCache output by rendering to a texture Supports all GDI features: italics, Supports all GDI features: italics,
kerning, international fonts, etc.kerning, international fonts, etc. ID3DXFont::DrawTextID3DXFont::DrawText
Dynamic 2D textDynamic 2D text
Using GDI every time can be slowUsing GDI every time can be slow Render alphabet to a textureRender alphabet to a texture Render a quad per characterRender a quad per character Texture coordinates into the texture Texture coordinates into the texture
depend on the characterdepend on the character Works well with simple fontsWorks well with simple fonts
Not for international fonts, kerning, etc.Not for international fonts, kerning, etc.
CD3DFont in sample framework CD3DFont in sample framework does thisdoes this
3D Text3D Text
D3DXCreateTextD3DXCreateText Extrudes a string rendered using Extrudes a string rendered using
a TrueType fonta TrueType font Returns a mesh objectReturns a mesh object Does not handleDoes not handle
Kerning, etc.Kerning, etc. International font spacingInternational font spacing
Sprites (not point sprites!)Sprites (not point sprites!)
Draws image in a texture to screenDraws image in a texture to screen Using a textured quadUsing a textured quad
Alpha blendingAlpha blending Rotation, scalesRotation, scales Arbitrary transforms & warpsArbitrary transforms & warps For performanceFor performance
Draw multiple sprites between Begin/EndDraw multiple sprites between Begin/End Draw mutiple sprites from same textureDraw mutiple sprites from same texture
Rendering to TexturesRendering to Textures
ID3DXRenderToSurface abstractionID3DXRenderToSurface abstraction BeginBegin
Setup render targets, viewportsSetup render targets, viewports Use intermediate surface if necessaryUse intermediate surface if necessary call BeginScenecall BeginScene
EndEnd CleanupCleanup Call EndSceneCall EndScene Blit to dest if necessaryBlit to dest if necessary
Texture UtilitiesTexture Utilities
Image file loadersImage file loaders JPG, PNG, TGA, BMP, PPM, DDSJPG, PNG, TGA, BMP, PPM, DDS Supports files in memorySupports files in memory
Format conversionFormat conversion Image re-samplingImage re-sampling
Better filtering optionsBetter filtering options Supports wrap modesSupports wrap modes
Mip-map generationMip-map generation Color-key to alpha conversionColor-key to alpha conversion
DXTn Encode QualityDXTn Encode Quality
New high quality compression New high quality compression algorithmalgorithm
Fast enough for load-time compressionFast enough for load-time compression 75-95% of earlier algorithm75-95% of earlier algorithm
Dithers while encodingDithers while encoding Avoids blocking of smooth gradientsAvoids blocking of smooth gradients
Improved encoding for alpha imagesImproved encoding for alpha images
DXTn Encoding examplesDXTn Encoding examples
Texture utilities updateTexture utilities update
D3DXGetImageInfoFrom*()D3DXGetImageInfoFrom*() Info about image before loading itInfo about image before loading it Include file format infoInclude file format info Enables calling appropriate load functionEnables calling appropriate load function
D3DXLoadSurfaceFromSurface D3DXLoadSurfaceFromSurface performanceperformance Will use hardware if possibleWill use hardware if possible
Support for dynamic texturesSupport for dynamic textures
Image SaveImage Save
D3DXSaveSurfaceToFileD3DXSaveSurfaceToFile BMPsBMPs
8-bit paletted8-bit paletted 24-bit RGB24-bit RGB
DDSDDS All formatsAll formats Mip-maps, cube-maps, volumesMip-maps, cube-maps, volumes
New scratch poolNew scratch pool
D3DPOOL_SCRATCHD3DPOOL_SCRATCH Allows creation of resources that are Allows creation of resources that are
not limited by device capabilitiesnot limited by device capabilities Create-Destroy, Lock-UnlockCreate-Destroy, Lock-Unlock
Can set to device, use in renderingCan set to device, use in rendering
Use with D3DX to convert to something Use with D3DX to convert to something useableuseable
e.g., Load high-prec height field and e.g., Load high-prec height field and convert to device prec normal mapconvert to device prec normal map
Texture FillTexture Fill
Texture fill functionsTexture fill functions D3DXFillTextureD3DXFillTexture D3DXFillCubeTextureD3DXFillCubeTexture D3DXFillVolumeTextureD3DXFillVolumeTexture
Handles mip-mapsHandles mip-maps Callback function gets a 2D/3D Callback function gets a 2D/3D
location and size of texellocation and size of texel Encode functions as look-up tables for Encode functions as look-up tables for
pixel shaderspixel shaders
Bump MappingBump Mapping
D3DXComputeNormalMapD3DXComputeNormalMap Converts a height field to a normal mapConverts a height field to a normal map Looks at 8 neighbors to calculate slopeLooks at 8 neighbors to calculate slope Calculates occlusion term in alphaCalculates occlusion term in alpha
Rough estimate of what fraction of the Rough estimate of what fraction of the hemisphere at that location in the height field is hemisphere at that location in the height field is “sky”“sky”
Smooth gradients can have aliasingSmooth gradients can have aliasing Use high-precision height fieldUse high-precision height field D3DX now supports 16-bit formatsD3DX now supports 16-bit formats
Math Library ImprovementsMath Library Improvements
D3DXQuaternionSqaudSetupD3DXQuaternionSqaudSetup Use with D3DXQuaternionSqaudUse with D3DXQuaternionSqaud
D3DXMatrixMultiplyTransposeD3DXMatrixMultiplyTranspose For matrices in vertex shadersFor matrices in vertex shaders
D3DXFresnelTermD3DXFresnelTerm Useful along with texture fill functionsUseful along with texture fill functions
Math library optimizationMath library optimization
CPU specific optimizations CPU specific optimizations for most important functionsfor most important functions 3DNow, SSE and SSE23DNow, SSE and SSE2 Vector, matrix, quaternion, interpolation, …Vector, matrix, quaternion, interpolation, …
Auto-detect CPU typeAuto-detect CPU type First call to an optimized math function First call to an optimized math function
detects CPUdetects CPU Patches jump table so no additional Patches jump table so no additional
overhead for subsequent callsoverhead for subsequent calls
Aligned MatricesAligned Matrices
Support for 16-byte aligned matricesSupport for 16-byte aligned matrices D3DXMATRIXA16D3DXMATRIXA16 Uses declspec(align:16) on new compilersUses declspec(align:16) on new compilers
Visual C++Visual C++®® 6 + processor pack6 + processor pack Visual C++ 7 (future product)Visual C++ 7 (future product) Not in Visual C++ 6 service packsNot in Visual C++ 6 service packs
Aligns on stack, members, globalsAligns on stack, members, globals Overloaded new / delete for aligned heap Overloaded new / delete for aligned heap
allocationsallocations Use with care when embedding in structsUse with care when embedding in structs
Authoring Tool SupportAuthoring Tool Support
Feature adoption gated by art pipelineFeature adoption gated by art pipeline Longer lead times for content creationLonger lead times for content creation Tool evolution rateTool evolution rate Duplicated effort for custom toolsDuplicated effort for custom tools
Every shop writes own export plug-insEvery shop writes own export plug-ins
We will provide source and samplesWe will provide source and samples To help reduce learning curveTo help reduce learning curve
Look under “extras” directory in SDKLook under “extras” directory in SDK
Authoring Tool Authoring Tool Plug-InsPlug-Ins
MeshesMeshes PatchesPatches Transform hierarchyTransform hierarchy Materials and TexturesMaterials and Textures SkinningSkinning AnimationAnimation
3D Studio Max 3.x, 4.03D Studio Max 3.x, 4.0 Support Character Studio 2.x, 3.0Support Character Studio 2.x, 3.0
Biped animations stored as sampled Biped animations stored as sampled matricesmatrices
Physique skinning exportedPhysique skinning exported Might need to re-apply physique to old data Might need to re-apply physique to old data
files like babyenv.maxfiles like babyenv.max
COM Skin support plannedCOM Skin support planned Patch exportPatch export
Work in progressWork in progress Cannot export patches created by surface Cannot export patches created by surface
modifiermodifier
A|W Maya 2.x, 3.xA|W Maya 2.x, 3.x
Support Rigid and Smooth skinningSupport Rigid and Smooth skinning Maya 2.x only has NURBSMaya 2.x only has NURBS
Can convert to patches using a scriptCan convert to patches using a script Use this before calling the exporterUse this before calling the exporter Supports export of skinned patchesSupports export of skinned patches
Maya 3.x has patchesMaya 3.x has patches Do not have export option yetDo not have export option yet
Call To ActionCall To Action
Try out new features in DirectX 8.1Try out new features in DirectX 8.1 Give us feedbackGive us feedback Tell us about bugs and performance Tell us about bugs and performance
issuesissues What else would you like to see?What else would you like to see? Hang around for the next talk…Hang around for the next talk…
AcknowledgementsAcknowledgements
Thanks to Origin Systems for Thanks to Origin Systems for permission to use Unicorn modelpermission to use Unicorn model
Thanks to NewTek for permission to use Thanks to NewTek for permission to use the monster modelthe monster model
Questions ?Questions ?