Direct3D Retained Mode - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

Direct3D Retained Mode

Description:

Tips and tricks. Allows animation of applicable APIs. APIs such as: SetGroupColorRGB ... Tips And Tricks. Various things can be done to speed up your application ... – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 39
Provided by: audragain
Category:

less

Transcript and Presenter's Notes

Title: Direct3D Retained Mode


1
(No Transcript)
2
Direct3D Retained Mode
  • Colin McCartney
  • Development Manager
  • Microsoft Corporation

3
Agenda
  • New features
  • Interpolator Interfaces
  • Support of true alpha
  • Progressive Meshes
  • Tips and tricks

4
New Features - Interpolators
  • Allows animation of applicable APIs
  • APIs such as
  • SetGroupColorRGB()
  • SetVerticies()
  • SetOrientation()
  • SetPosition()
  • Check out morph sample

5
New Features - Interpolators
  • Used by creating an Interpolator object and
    calling QueryInterface() for the interface you
    wish to animate
  • Attach interpolator object to the target object
    for animation

6
New Features - Interpolators
  • Example
  • First create a mesh with some vertices and faces

LPDIRECT3DRMMESH pMesh D3DRMGROUPINDEX
dwGID DWORD pFaceData D3DRMVERTEX
pVData pD3DRM-CreateMesh(pMesh) pMe
sh-AddGroup(3, 1, 3, pFaceData,
dwGID) pMesh-SetVertices(dwGID, 0, 3, pVData)
7
New Features - Interpolators
  • Now create an interpolator object to animate the
    color of vertices

LPDIRECT3DRMINTERPOLATOR pInterp LPDIRECT3DRMMESH
pMeshProxy pD3DRM-CreateObject(CLSIID_CDirect3
DRMMeshInterpolator, NULL,
IID_IDirect3DRMInterpolator,
(LPVOID)pInterp) // pMeshProxy provides
interpolants pInterp-QueryInterface(IID_IDirect3
DRMMesh, (LPVOID)pMeshProxy) // Hook
the interpolator to the real mesh pInterp-AddObje
ct(pMesh)
8
New Features - Interpolators
  • Provide the keys...

// pInterp and pMeshProxy and interfaces to the
same // Interpolator object pInterp-SetIndex(D3DV
AL(0.0)) pMeshProxy-SetGroupColorRGB(D3DVAL(0.0)
, D3DVAL(0.0), D3DVAL(0.0)) pInterp-SetInd
ex(D3DVAL(25.0)) pMeshProxy-SetGroupColorRGB(D3D
VAL(0.3), D3DVAL(0.3), D3DVAL(0.3)) pInterp
-SetIndex(D3DVAL(50.0)) pMeshProxy-SetGroupColo
rRGB(D3DVAL(1.0), D3DVAL(1.0),
D3DVAL(1.0)) pInterp-SetIndex(D3DVAL(75.0)) pMe
shProxy-Release() // Dont need it anymore
9
New Features - Interpolators
  • Now just add the mesh to the scene and vary the
    index over time
  • E.g. in a move callback

VOID CDECL interpolateFunc(LPDIRECT3DRMFRAME
pFrame, LPVOID pvArg, D3DVALUE
dvDelta) static D3DVALUE dvVal
D3DVAL(0.0) LPDIRECT3DRMINTERPOLATOR pInterp
(LPDIRECT3DRMINTERPOLATOR)pvArg
dvVal dvDelta pInterp-Interpolate(dvVal,
NULL, D3DRMINTERPOLATION_CLOSED
D3DRMINTERPOLATION_LINEAR)
10
New Features - Interpolators
  • Demo...

11
New Features - True Alpha
  • Alpha channel in texture
  • In order to support compatibility texture must be
    created from IDirect3DRM2 interface
  • Or use CLSIID_CDirect3DRMTexture2
  • Alpha value in vertex
  • Used to only provide stippled alpha
  • Now provides true alpha

12
New Features - True Alpha
  • Shadows use true alpha if available
  • How to use it?
  • Device must have an IDirect3DDevice2 available
  • Create device using IDirect3DRM2
  • Possibly need to use DrawPrimitive

13
New Features - True Alpha
  • Must also set IDirect3DRMDevice2SetRenderMode()
  • D3DRMRENDERMODE_BLENDEDTRANSPARENCY
  • Uses True Alpha instead of stippled alpha IF
    supported
  • D3DRMRENDERMODE_SORTEDTRANSPARENCY
  • Use only if really needed - overhead of sorting
  • Uses DrawPrimitive
  • Demo...

14
New Features - I/O
  • New load support
  • Asynchronous
  • Progressive Mesh only
  • From a URL
  • All objects (Frame, Mesh, PMesh)

15
New Features - Others
  • Mostly on IDirect3DRMFrame2
  • Bounding box support
  • Modify origin axis
  • Crease angle
  • Ray picking
  • Misc
  • Right-handed support
  • MIP map generation

16
New Features - Progressive Mesh
  • Provide real time, continuous level of detail
    support
  • no popping as in traditional LOD
  • Mesh stored as a base mesh and series of vertex
    splits
  • Mesh is renderable after the base mesh has been
    loaded

17
New Features - Progressive Mesh
  • Base mesh contains
  • all face and vertex information for the lowest
    level of detail
  • information about materials and textures
  • Vertex splits introduce a new vertex and 1 or 2
    new faces

18
New Features - Progressive Mesh
  • Vertex splits are invertible
  • edge collapse
  • Highest level of detail is geometrically
    identical to source mesh
  • lossless representation

19
New Features - Progressive Mesh
Vertex Split
vt
vl
vr
vs
vs

Edge collapse
20
New Features - Progressive Mesh
21
New Features - Direct3DRM and Progressive Mesh
  • New visual object and interface
  • IDirect3DRMProgressiveMesh
  • Same behavior as other visuals
  • added to frames in the hierarchy
  • adhere to overrides
  • Can create a normal mesh object from any level of
    detail

22
New Features - Direct3DRM and Progressive Mesh
  • Concise representation in DirectX Files
  • Feature set of the interface
  • Flexibility in choosing LOD to fine-tune frame
    rate
  • Incremental changes LOD reduce snapping / popping
    artifacts
  • Face, vertex or normalized basis

23
New Features - Direct3DRM and Progressive Mesh
  • Feature set of the interface
  • Asynchronous loading with new load flag
  • D3DRMLOAD_ASYNCHRONOUS
  • can be progressively rendered as it is loaded
  • can be combined with D3DRMLOAD_FROMURL

24
New Features - Direct3DRM and Progressive Mesh
Conversion tool Preserve appearance geometric
shape scalar fields (e.g. color,
normals) discontinuity curves
25
New Features -Progressive Mesh Recap
  • LOD selection at install time of a title
  • profile platform, decide LOD for content
  • Real time LOD simplification
  • based on frame rate or Z distance
  • Progressive download of 3D over the net
  • Polygon reduction in an authoring tool

26
New Features -Progressive Mesh Recap
  • More information
  • Siggraph 96 proceedings
  • http//www.research.microsoft.com/hoppe
  • http//www.microsoft.com/directx
  • Demo Havent you seen it yet???

27
Tips And Tricks
  • Debugging
  • Use the debug DLLs
  • win.ini section
  • Please dont profile using the debug dlls...

Direct3DRM debug3 dumpformats1 nopal40 nopal8
1 norgb80 norgb160
28
Tips And Tricks
  • Various things can be done to speed up your
    application
  • Many of them not specific to Retained Mode
  • scale the application

29
Tips And Tricks
  • Culling
  • Retained Mode culls on a mesh basis
  • bounding box/sphere
  • Z visibility - 200 triangles
  • Dont have one huge mesh
  • caveat - dont have one polygon meshes

30
Tips And Tricks
  • Mesh Usage
  • MeshBuilders are convenient
  • file access, face paradigm
  • have overhead
  • MeshBuilders built on top of Meshes
  • changing the MeshBuilder requires reconstruction
    of underlying Mesh
  • if you dont need the MeshBuilder again, throw it
    away

31
Tips And Tricks
  • Mesh Usage
  • Meshes are fast
  • built directly on ExecuteBuffers
  • changing the Meshes modifies ExecuteBuffer
    directly

32
Tips And Tricks
  • Textures
  • Check which texture formats are directly
    supported
  • currently via ImmediateMode
  • if you dont use a directly supported format,
    Direct3DRM will convert
  • Call TextureChanged() if you change the surface
    or palette

33
Tips And Tricks
  • Textures
  • Use system memory textures to enable texture
    caching
  • To enable alpha, use IDirect3DRM2
  • Use IDirect3DTexture2 to get BMPs the right way
    up Ooops

34
Tips And Tricks
  • Palettized Displays
  • You can lock down the palette
  • Create device via
  • CreateDeviceFromSurface()
  • CreateDeviceFromD3D()
  • Set texture shades to 1

35
Tips And Tricks
  • Screen update
  • Dont update what you dont need to
  • Either
  • let Retained Mode handle the update (in
    CreateFromClipper case)
  • use an update callback
  • Pay attention to region information
  • Always call IDirect3DRMDeviceUpdate()

36
Tips And Tricks
  • Scale the application
  • Applicable to any application
  • Keep a track of the frame rate
  • Keep motion steady using
  • IDirect3DRMFrameMove(dvDelta)
  • If you can, use Progressive Mesh
  • if you cant provide geometry at various levels
    of detail
  • Profile the application on start-up
  • hardware may change on you

37
Questions ?
?
?
?
?
?
?
?
?
?
?
?
38
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com