ID3DXPRTEngine Interface

 

 

' ****************************************************************************************
' ID3DXPRTEngine interface
' IID_ID3DXPRTEngine = GUID$("{C3F4ADBF-E6D2-4b7b-BFE8-9E7208746ADF}")
' ****************************************************************************************

' ****************************************************************************************
' The ID3DXPRTEngine interface is used to compute a precomputed radiance transfer (PRT)
' simulation. Its methods are typically used offline, to compute per-vertex or per-texel
' transfer vectors in advance of real-time 3-D modeling.
' Remarks
'    To convert from RGB to luminance values, the following formula is used:
'       Luminance = R * 0.2125 + G * 0.7154 + B * 0.0721
'    The ID3DXPRTEngine interface is obtained by calling the D3DXCreatePRTEngine function.
' Interface Information
'    Stock Implementation   d3d9.dll
'    Custom Implementation  No
'    Inherits from  IUnknown
'    Header     d3dx9mesh.h
'    Import library     d3dx9.lib
'    Minimum operating systems  Windows 98
' ****************************************************************************************

' ****************************************************************************************
'DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown)
'{
'    // IUnknown
'  0.  STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
'  1.  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
'  2.  STDMETHOD_(ULONG, Release)(THIS) PURE;

'    // ID3DXPRTEngine

'    // This sets a material per attribute in the scene mesh and it is
'    // the only way to specify subsurface scattering parameters.  if
'    // bSetAlbedo is FALSE, NumChannels must match the current
'    // configuration of the PRTEngine.  If you intend to change
'    // NumChannels (through some other SetAlbedo function) it must
'    // happen before SetMeshMaterials is called.
'    //
'    // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
'    //  color bleeding effects
'    // bSetAlbedo sets albedo from material if TRUE - which clobbers per texel/vertex
'    //  albedo that might have been set before.  FALSE won't clobber.
'    // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube
'    //  and scaled by this amount
'  3.  STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes,
'                                UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE;

'    // setting albedo per-vertex or per-texel over rides the albedos stored per mesh
'    // but it does not over ride any other settings

'    // sets an albedo to be used per vertex - the albedo is represented as a float
'    // pDataIn input pointer (pointint to albedo of 1st sample)
'    // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
'    //  color bleeding effects
'    // Stride - stride in bytes to get to next samples albedo
'  4.  STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE;

'    // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used)
'    // pAlbedoTexture - texture that stores the albedo (dimension arbitrary)
'    // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
'    //  color bleeding effects
'    // pGH - optional gutter helper, otherwise one is constructed in computation routines and
'    //  destroyed (if not attached to buffers)
'  5.  STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture,
'                                 UINT NumChannels,
'                                 LPD3DXTEXTUREGUTTERHELPER pGH) PURE;

'    // gets the per-vertex albedo
'  6.  STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE;

'    // If pixel PRT is being computed normals default to ones that are interpolated
'    // from the vertex normals.  This specifies a texture that stores an object
'    // space normal map instead (must use a texture format that can represent signed values)
'    // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed
'  7.  STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE;

'    // Copies per-vertex albedo from mesh
'    // pMesh - mesh that represents the scene.  It must have the same
'    //  properties as the mesh used to create the PRTEngine
'    // Usage - D3DDECLUSAGE to extract albedos from
'    // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
'    //  color bleeding effects
'  8.  STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh,
'                                      D3DDECLUSAGE Usage,
'                                      UINT NumChannels) PURE;

'    // Resamples the input buffer into the output buffer
'    // can be used to move between per-vertex and per-texel buffers.  This can also be used
'    // to convert single channel buffers to 3-channel buffers and vice-versa.
'  9.  STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE;

'    // Returns the scene mesh - including modifications from adaptive spatial sampling
'    // The returned mesh only has positions, normals and texture coordinates (if defined)
'    // pD3DDevice - d3d device that will be used to allocate the mesh
'    // pFaceRemap - each face has a pointer back to the face on the original mesh that it comes from
'    //  if the face hasn't been subdivided this will be an identity mapping
'    // pVertRemap - each vertex contains 3 vertices that this is a linear combination of
'    // pVertWeights - weights for each of above indices (sum to 1.0f)
'    // ppMesh - mesh that will be allocated and filled
' 10.  STDMETHOD(GetAdaptedMesh)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,UINT *pFaceRemap, UINT *pVertRemap, FLOAT *pfVertWeights, LPD3DXMESH *ppMesh) PURE;

'    // Number of vertices currently allocated (includes new vertices from adaptive sampling)
' 11.  STDMETHOD_(UINT, GetNumVerts)(THIS) PURE;
'    // Number of faces currently allocated (includes new faces)
' 12.  STDMETHOD_(UINT, GetNumFaces)(THIS) PURE;

'    // This will subdivide faces on a mesh so that adaptively simulations can
'    // use a more conservative threshold (it won't miss features.)
'    // MinEdgeLength - minimum edge length that will be generated, if 0.0f a
'    //  reasonable default will be used
'    // MaxSubdiv - maximum level of subdivision, if 0 is specified a default
'    //  value will be used (5)
' 13.  STDMETHOD(RobustMeshRefine)(THIS_ FLOAT MinEdgeLength, UINT MaxSubdiv) PURE;

'    // This sets to sampling information used by the simulator.  Adaptive sampling
'    // parameters are currently ignored.
'    // NumRays - number of rays to shoot per sample
'    // UseSphere - if TRUE uses spherical samples, otherwise samples over
'    //  the hemisphere.  Should only be used with GPU and Vol computations
'    // UseCosine - if TRUE uses a cosine weighting - not used for Vol computations
'    //  or if only the visiblity function is desired
'    // Adaptive - if TRUE adaptive sampling (angular) is used
'    // AdaptiveThresh - threshold used to terminate adaptive angular sampling
'    //  ignored if adaptive sampling is not set
' 14.  STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays,
'                               BOOL UseSphere,
'                               BOOL UseCosine,
'                               BOOL Adaptive,
'                               FLOAT AdaptiveThresh) PURE;

'    // Methods that compute the direct lighting contribution for objects
'    // always represente light using spherical harmonics (SH)
'    // the albedo is not multiplied by the signal - it just integrates
'    // incoming light.  If NumChannels is not 1 the vector is replicated
'    //
'    // SHOrder - order of SH to use
'    // pDataOut - PRT buffer that is generated.  Can be single channel
' 15.  STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder,
'                                       LPD3DXPRTBUFFER pDataOut) PURE;

'    // Adaptive variant of above function.  This will refine the mesh
'    // generating new vertices/faces to approximate the PRT signal
'    // more faithfully.
'    // SHOrder - order of SH to use
'    // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error)
'    //  if value is less then 1e-6f, 1e-6f is specified
'    // MinEdgeLength - minimum edge length that will be generated
'    //  if value is too small a fairly conservative model dependent value
'    //  is used
'    // MaxSubdiv - maximum subdivision level, if 0 is specified it
'    //  will default to 4
'    // pDataOut - PRT buffer that is generated.  Can be single channel.
' 16.  STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder,
'                                               FLOAT AdaptiveThresh,
'                                               FLOAT MinEdgeLength,
'                                               UINT MaxSubdiv,
'                                               LPD3DXPRTBUFFER pDataOut) PURE;

'    // Function that computes the direct lighting contribution for objects
'    // light is always represented using spherical harmonics (SH)
'    // This is done on the GPU and is much faster then using the CPU.
'    // The albedo is not multiplied by the signal - it just integrates
'    // incoming light.  If NumChannels is not 1 the vector is replicated.
'    // ZBias/ZAngleBias are akin to parameters used with shadow zbuffers.
'    // A reasonable default for both values is 0.005, but the user should
'    // experiment (ZAngleBias can be zero, ZBias should not be.)
'    // Callbacks should not use the Direct3D9Device the simulator is using.
'    // SetSamplingInfo must be called with TRUE for UseSphere and
'    // FALSE for UseCosine before this method is called.
'    //
'    // pD3DDevice - device used to run GPU simulator - must support PS2.0
'    //  and FP render targets
'    // Flags - parameters for the GPU simulator, combination of one or more
'    //  D3DXSHGPUSIMOPT flags.  Only one SHADOWRES setting should be set and
'    //  the defaults is 512
'    // SHOrder - order of SH to use
'    // ZBias - bias in normal direction (for depth test)
'    // ZAngleBias - scaled by one minus cosine of angle with light (offset in depth)
'    // pDataOut - PRT buffer that is filled in.  Can be single channel
' 17.  STDMETHOD(ComputeDirectLightingSHGPU)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,
'                                          UINT Flags,
'                                          UINT SHOrder,
'                                          FLOAT ZBias,
'                                          FLOAT ZAngleBias,
'                                          LPD3DXPRTBUFFER pDataOut) PURE;


'    // Functions that computes subsurface scattering (using material properties)
'    // Albedo is not multiplied by result.  This only works for per-vertex data
'    // use ResampleBuffer to move per-vertex data into a texture and back.
'    //
'    // pDataIn - input data (previous bounce)
'    // pDataOut - result of subsurface scattering simulation
'    // pDataTotal - [optional] results can be summed into this buffer
' 18.  STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn,
'                         LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE;

'    // computes a single bounce of inter-reflected light
'    // works for SH based PRT or generic lighting
'    // Albedo is not multiplied by result
'    //
'    // pDataIn - previous bounces data
'    // pDataOut - PRT buffer that is generated
'    // pDataTotal - [optional] can be used to keep a running sum
' 19.  STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn,
'                             LPD3DXPRTBUFFER pDataOut,
'                             LPD3DXPRTBUFFER pDataTotal) PURE;

'    // Adaptive version of above function.
'    //
'    // pDataIn - previous bounces data, can be single channel
'    // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error)
'    //  if value is less then 1e-6f, 1e-6f is specified
'    // MinEdgeLength - minimum edge length that will be generated
'    //  if value is too small a fairly conservative model dependent value
'    //  is used
'    // MaxSubdiv - maximum subdivision level, if 0 is specified it
'    //  will default to 4
'    // pDataOut - PRT buffer that is generated
'    // pDataTotal - [optional] can be used to keep a running sum
' 20.  STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn,
'                                     FLOAT AdaptiveThresh,
'                                     FLOAT MinEdgeLength,
'                                     UINT MaxSubdiv,
'                                     LPD3DXPRTBUFFER pDataOut,
'                                     LPD3DXPRTBUFFER pDataTotal) PURE;

'    // Computes projection of distant SH radiance into a local SH radiance
'    // function.  This models how direct lighting is attenuated by the
'    // scene and is a form of "neighborhood transfer."  The result is
'    // a linear operator (matrix) at every sample point, if you multiply
'    // this matrix by the distant SH lighting coefficients you get an
'    // approximation of the local incident radiance function from
'    // direct lighting.  These resulting lighting coefficients can
'    // than be projected into another basis or used with any rendering
'    // technique that uses spherical harmonics as input.
'    // SetSamplingInfo must be called with TRUE for UseSphere and
'    // FALSE for UseCosine before this method is called.
'    // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars
'    // per channel at each sample location.
'    //
'    // SHOrderIn  - Order of the SH representation of distant lighting
'    // SHOrderOut - Order of the SH representation of local lighting
'    // NumVolSamples  - Number of sample locations
'    // pSampleLocs    - position of sample locations
'    // pDataOut       - PRT Buffer that will store output results
' 21.  STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn,
'                                            UINT SHOrderOut,
'                                            UINT NumVolSamples,
'                                            CONST D3DXVECTOR3 *pSampleLocs,
'                                            LPD3DXPRTBUFFER pDataOut) PURE;

'    // At each sample location computes a linear operator (matrix) that maps
'    // the representation of source radiance (NumCoeffs in pSurfDataIn)
'    // into a local incident radiance function approximated with spherical
'    // harmonics.  For example if a light map data is specified in pSurfDataIn
'    // the result is an SH representation of the flow of light at each sample
'    // point.  If PRT data for an outdoor scene is used, each sample point
'    // contains a matrix that models how distant lighting bounces of the objects
'    // in the scene and arrives at the given sample point.  Combined with
'    // ComputeVolumeSamplesDirectSH this gives the complete representation for
'    // how light arrives at each sample point parameterized by distant lighting.
'    // SetSamplingInfo must be called with TRUE for UseSphere and
'    // FALSE for UseCosine before this method is called.
'    // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars
'    // per channel at each sample location.
'    //
'    // pSurfDataIn    - previous bounce data
'    // SHOrder        - order of SH to generate projection with
'    // NumVolSamples  - Number of sample locations
'    // pSampleLocs    - position of sample locations
'    // pDataOut       - PRT Buffer that will store output results
' 22.  STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn,
'                                    UINT SHOrder,
'                                    UINT NumVolSamples,
'                                    CONST D3DXVECTOR3 *pSampleLocs,
'                                    LPD3DXPRTBUFFER pDataOut) PURE;
'    // Frees temporary data structures that can be created for subsurface scattering
'    // this data is freed when the PRTComputeEngine is freed and is lazily created
' 23.  STDMETHOD(FreeSSData)(THIS) PURE;

'    // Frees temporary data structures that can be created for bounce simulations
'    // this data is freed when the PRTComputeEngine is freed and is lazily created
' 24.  STDMETHOD(FreeBounceData)(THIS) PURE;

'    // This computes the convolution coefficients relative to the per sample normals
'    // that minimize error in a least squares sense with respect to the input PRT
'    // data set.  These coefficients can be used with skinned/transformed normals to
'    // model global effects with dynamic objects.  Shading normals can optionaly be
'    // solved for - these normals (along with the convolution coefficients) can more
'    // accurately represent the PRT signal.
'    //
'    // pDataIn  - SH PRT dataset that is input
'    // SHOrder  - Order of SH to compute conv coefficients for
'    // pNormOut - Optional array of vectors (passed in) that will be filled with
'    //             "shading normals", convolution coefficients are optimized for
'    //             these normals.  This array must be the same size as the number of
'    //             samples in pDataIn
'    // pDataOut - Output buffer (SHOrder convolution coefficients per channel per sample)
' 25.  STDMETHOD(ComputeConvCoeffs)(THIS_ LPD3DXPRTBUFFER pDataIn,
'                                 UINT SHOrder,
'                                 D3DXVECTOR3 *pNormOut,
'                                 LPD3DXPRTBUFFER pDataOut) PURE;

'    // scales all the samples associated with a given sub mesh
'    // can be useful when using subsurface scattering
'    // fScale - value to scale each vector in submesh by
' 26.  STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE;

'    // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo
'    // burned into the dataset, often better not to do this.  If this is not done the user
'    // must mutliply the albedo themselves when rendering - just multiply the albedo times
'    // the result of the PRT dot product.
'    // If pDataOut is a texture simulation result and there is an albedo texture it
'    // must be represented at the same resolution as the simulation buffer.  You can use
'    // LoadSurfaceFromSurface and set a new albedo texture if this is an issue - but must
'    // be careful about how the gutters are handled.
'    //
'    // pDataOut - dataset that will get albedo pushed into it
' 27.  STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE;

'    // Sets a pointer to an optional call back function that reports back to the
'    // user percentage done and gives them the option of quitting
'    // pCB - pointer to call back function, return S_OK for the simulation
'    //  to continue
'    // Frequency - 1/Frequency is roughly the number of times the call back
'    //  will be invoked
'    // lpUserContext - will be passed back to the users call back
' 28.  STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency,  LPVOID lpUserContext) PURE;
'};
' ****************************************************************************************

' ****************************************************************************************
' SetMeshMaterials method
' Sets mesh material properties in the 3-D scene. Use this method to specify subsurface
' scattering parameters.
' HRESULT SetMeshMaterials(
'   CONST D3DXSHMATERIAL ** ppMaterials,
'   UINT NumMeshes,
'   UINT NumChannels,
'   BOOL bSetAlbedo,
'   FLOAT fLengthScale
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_SetMeshMaterials ALIAS "ID3DXPRTEngine_SetMeshMaterials" ( _
    BYVAL pthis AS DWORD PTR, BYVAL ppMaterials AS DWORD, BYVAL NumMeshes AS DWORD, _
    BYVAL NumChannels AS DWORD, BYVAL bSetAlbedo AS LONG, BYVAL fLengthScale AS SINGLE) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[3] USING ID3DXPRTEngine_SetMeshMaterials(pthis, ppMaterials, NumMeshes, NumChannels, bSetAlbedo, fLengthScale) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetPerVertexAlbedo method
' Sets an albedo value for each texel, overwriting previous albedo values.
' HRESULT SetPerVertexAlbedo(
'   CONST VOID * pDataIn,
'   UINT NumChannels,
'   UINT Stride
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_SetPerVertexAlbedo ALIAS "ID3DXPRTEngine_SetPerVertexAlbedo" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pAlbedoTexture AS DWORD, BYVAL NumChannels AS DWORD, _
    BYVAL pGH AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[4] USING ID3DXPRTEngine_SetPerVertexAlbedo(pthis, pAlbedoTexture, NumChannels, pGH) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetPerTexelAlbedo method
' Sets an albedo value for each texel, overwriting previous albedo values.
' HRESULT SetPerTexelAlbedo(
'   LPDIRECT3DTEXTURE9 pAlbedoTexture,
'   UINT NumChannels,
'   LPD3DXTEXTUREGUTTERHELPER pGH
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_SetPerTexelAlbedo ALIAS "ID3DXPRTEngine_SetPerTexelAlbedo" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pAlbedoTexture AS DWORD, BYVAL NumChannels AS DWORD, _
    BYVAL pGH AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[5] USING ID3DXPRTEngine_SetPerTexelAlbedo(pthis, pAlbedoTexture, NumChannels, pGH) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' GetVertexAlbedo method
' Retrieves albedo values of the mesh vertices.
' HRESULT GetVertexAlbedo(
'   D3DXCOLOR * pVertColors,
'   UINT NumVerts
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_GetVertexAlbedo ALIAS "ID3DXPRTEngine_GetVertexAlbedo" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pVertColors AS DWORD, BYVAL NumVerts AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[6] USING ID3DXPRTEngine_GetVertexAlbedo(pthis, pVertColors, NumVerts) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetPerTexelNormal method
' Sets a normal vector for each texel in a texture object. This method is used to store
' vertex normal vectors from a mesh (or interpolated vertex normals if pixel-based
' precomputed radiance transfer (PRT) is being computed).
' HRESULT SetPerTexelNormal(
'   LPDIRECT3DTEXTURE9 pNormalTexture
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_SetPerTexelNormal ALIAS "ID3DXPRTEngine_SetPerTexelNormal" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pNormalTexture AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[7] USING ID3DXPRTEngine_SetPerTexelNormal(pthis, pNormalTexture) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ExtractPerVertexAlbedo method
' Copies per-vertex albedo values from a mesh.
' HRESULT ExtractPerVertexAlbedo(
'   LPD3DXMESH pMesh,
'   D3DDECLUSAGE Usage,
'   UINT NumChanIn
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ExtractPerVertexAlbedo ALIAS "ID3DXPRTEngine_ExtractPerVertexAlbedo" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pMesh AS DWORD, BYVAL Usage AS DWORD, _
    BYVAL NumChanIn AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[8] USING ID3DXPRTEngine_ExtractPerVertexAlbedo(pthis, pMesh, Usage, NumChanIn) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ResampleBuffer method
' Resamples an input ID3DXPRTBuffer buffer and saves it to an output buffer. This method
' can be used to convert a vertex buffer to a texture buffer and vice-versa. It can also
' be used to convert single-channel buffers to 3-channel buffers and vice-versa.
' HRESULT ResampleBuffer(
'   LPD3DXPRTBUFFER pBufferIn,
'   LPD3DXPRTBUFFER pBufferOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ResampleBuffer ALIAS "ID3DXPRTEngine_ResampleBuffer" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pBufferIn AS DWORD, BYVAL pBufferOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[9] USING ID3DXPRTEngine_ResampleBuffer(pthis, pBufferIn, pBufferOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' GetAdaptedMesh method
' Returns a mesh with modifications resulting from adaptive spatial sampling. The returned
' mesh contains only positions, normals, and texture coordinates (if defined).
' HRESULT GetAdaptedMesh(
'   LPDIRECT3DDEVICE9 pDevice,
'   UINT * pFaceRemap,
'   UINT * pVertRemap,
'   FLOAT * pfVertWeights,
'   LPD3DXMESH * ppMesh
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_GetAdaptedMesh ALIAS "ID3DXPRTEngine_GetAdaptedMesh" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDevice AS DWORD, BYVAL pFaceRemap AS DWORD, _
    BYVAL pVertRemap AS DWORD, BYVAL pfVertWeights AS DWORD, BYREF ppMesh AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[10] USING ID3DXPRTEngine_GetAdaptedMesh(pthis, pDevice, pFaceRemap, pVertRemap, pfVertWeights, ppMesh) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' GetNumVerts method
' Retrieves the number of vertices in the mesh, including any new vertices added as a
' result of adaptive spatial sampling.
' UINT GetNumVerts();
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_GetNumVerts ALIAS "ID3DXPRTEngine_GetNumVerts" (BYVAL pthis AS DWORD PTR) EXPORT AS DWORD

    LOCAL DWRESULT AS DWORD
    IF pthis = %NULL THEN EXIT FUNCTION
    CALL DWORD @@pthis[11] USING ID3DXPRTEngine_GetNumVerts(pthis) TO DWRESULT
    FUNCTION = DWRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' GetNumFaces method
' Retrieves the number of faces in the mesh, including any new faces added as a result of
' adaptive spatial sampling.
' UINT GetNumFaces();
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_GetNumFaces ALIAS "ID3DXPRTEngine_GetNumFaces" (BYVAL pthis AS DWORD PTR) EXPORT AS DWORD

    LOCAL DWRESULT AS DWORD
    IF pthis = %NULL THEN EXIT FUNCTION
    CALL DWORD @@pthis[12] USING ID3DXPRTEngine_GetNumFaces(pthis) TO DWRESULT
    FUNCTION = DWRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' RobustMeshRefine method
' Subdivides faces on a mesh, allowing for conservative adaptive sampling that will not
' eliminate features on the mesh.
' HRESULT RobustMeshRefine(
'   FLOAT MinEdgeLength,
'   UINT MaxSubdiv
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_RobustMeshRefine ALIAS "ID3DXPRTEngine_RobustMeshRefine" ( _
    BYVAL pthis AS DWORD PTR, BYVAL MinEdgeLength AS SINGLE, BYVAL MaxSubdiv AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[13] USING ID3DXPRTEngine_RobustMeshRefine(pthis, MinEdgeLength, MaxSubdiv) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetSamplingInfo method
' Sets sampling properties used by the precomputed radiance transfer (PRT) simulator.
' HRESULT SetSamplingInfo(
'   UINT NumRays,
'   BOOL UseSphere,
'   BOOL UseCosine,
'   BOOL Adaptive,
'   FLOAT AdaptiveThresh
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_SetSamplingInfo ALIAS "ID3DXPRTEngine_SetSamplingInfo" ( _
    BYVAL pthis AS DWORD PTR, BYVAL NumRays AS DWORD, BYVAL UseSphere AS LONG, _
    BYVAL UseCosine AS LONG, BYVAL Adaptive AS LONG, BYVAL AdaptiveThresh AS SINGLE) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[14] USING ID3DXPRTEngine_SetSamplingInfo(pthis, NumRays, UseSphere, UseCosine, Adaptive, AdaptiveThresh) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeDirectLightingSH method
' Computes the direct lighting contribution to 3-D objects where the source radiance is
' represented by a spherical harmonic (SH) approximation.
' HRESULT ComputeDirectLightingSH(
'   UINT Order,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeDirectLightingSH ALIAS "ID3DXPRTEngine_ComputeDirectLightingSH" ( _
    BYVAL pthis AS DWORD PTR, BYVAL Order AS DWORD, BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[15] USING ID3DXPRTEngine_ComputeDirectLightingSH(pthis, Order, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeDirectLightingSHAdaptive method
' Computes the direct lighting contribution to 3-D objects where the source radiance is
' represented by a spherical harmonic (SH) approximation, using adaptive sampling. This
' method generates new vertices and faces on the mesh to more accurately approximate the
' precomputed radiance transfer (PRT) signal.
' HRESULT ComputeDirectLightingSHAdaptive(
'   UINT Order,
'   FLOAT AdaptiveThresh,
'   FLOAT MinEdgeLength,
'   UINT MaxSubdiv,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeDirectLightingSHAdaptive ALIAS "ID3DXPRTEngine_ComputeDirectLightingSHAdaptive" ( _
    BYVAL pthis AS DWORD PTR, BYVAL Order AS DWORD, BYVAL AdaptiveThresh AS SINGLE, _
    BYVAL MinEdgeLength AS SINGLE, BYVAL MaxSubdiv AS DWORD, BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[16] USING ID3DXPRTEngine_ComputeDirectLightingSHAdaptive(pthis, Order, AdaptiveThresh, MinEdgeLength, MaxSubdiv, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeDirectLightingSHGPU method
' Uses the graphics processing unit (GPU) to compute the direct lighting contribution to
' 3-D objects where the source radiance is represented by a spherical harmonic (SH)
' approximation. Computing the lighting on the GPU will generally be much faster than on
' the CPU.
' HRESULT ComputeDirectLightingSHGPU(
'   LPDIRECT3DDEVICE9 pDevice,
'   UINT Flags,
'   UINT Order,
'   FLOAT ZBias,
'   FLOAT ZAngleBias,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeDirectLightingSHGPU ALIAS "ID3DXPRTEngine_ComputeDirectLightingSHGPU" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDevice AS DWORD, BYVAL Order AS DWORD, _
    BYVAL Flags AS DWORD, BYVAL ZBias AS SINGLE, BYVAL ZAngleBias AS SINGLE, _
    BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[17] USING ID3DXPRTEngine_ComputeDirectLightingSHGPU(pthis, pDevice, Order, Flags, ZBias, ZAngleBias, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeSS method
' Computes the source radiance resulting from subsurface scattering, using material
' properties set by ID3DXPRTEngine::SetMeshMaterials. This method can be used only for
' materials defined per-vertex in a mesh object.
' HRESULT ComputeSS(
'   LPD3DXPRTBUFFER pDataIn,
'   LPD3DXPRTBUFFER pDataOut,
'   LPD3DXPRTBUFFER pDataTotal
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeSS ALIAS "ID3DXPRTEngine_ComputeSS" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDataIn AS DWORD, BYVAL pDataOut AS DWORD, _
    BYVAL pDataTotal AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[18] USING ID3DXPRTEngine_ComputeSS(pthis, pDataIn, pDataOut, pDataTotal) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeBounce method
' Computes the source radiance resulting from a single bounce of interreflected light.
' This method can be used for any lit scene, including a spherical harmonic (SH)-based
' precomputed radiance transfer (PRT) model.
' HRESULT ComputeBounce(
'   LPD3DXPRTBUFFER pDataIn,
'   LPD3DXPRTBUFFER pDataOut,
'   LPD3DXPRTBUFFER pDataTotal
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeBounce ALIAS "ID3DXPRTEngine_ComputeBounce" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDataIn AS DWORD, BYVAL pDataOut AS DWORD, _
    BYVAL pDataTotal AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[19] USING ID3DXPRTEngine_ComputeBounce(pthis, pDataIn, pDataOut, pDataTotal) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeBounceAdaptive method
' Computes the source radiance resulting from a single bounce of interreflected light,
' using adaptive sampling. This method generates new vertices and faces on the mesh to
' more accurately approximate the precomputed radiance transfer (PRT) signal. This method
' can be used for any lit scene, including a spherical harmonic (SH)-based PRT model.
' HRESULT ComputeBounceAdaptive(
'   LPD3DXPRTBUFFER pDataIn,
'   FLOAT AdaptiveThresh,
'   FLOAT MinEdgeLength,
'   UINT MaxSubdiv,
'   LPD3DXPRTBUFFER pDataOut,
'   LPD3DXPRTBUFFER pDataTotal
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeBounceAdaptive ALIAS "ID3DXPRTEngine_ComputeBounceAdaptive" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDataIn AS DWORD, BYVAL AdaptiveThresh AS SINGLE, _
    BYVAL MinEdgeLength AS SINGLE, BYVAL MaxSubdiv AS DWORD, BYVAL pDataOut AS DWORD, _
    BYVAL pDataTotal AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[20] USING ID3DXPRTEngine_ComputeBounceAdaptive(pthis, pDataIn, AdaptiveThresh, MinEdgeLength, MaxSubdiv, pDataOut, pDataTotal) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeVolumeSamplesDirectSH method
' Computes a projection of distant lighting into spherical harmonic (SH) basis vectors
' that represent incident radiance at specified locations.
' HRESULT ComputeVolumeSamplesDirectSH(
'   UINT OrderIn,
'   UINT OrderOut,
'   UINT NumVolSamples.xml,
'   CONST D3DXVECTOR3 * pSampleLocs,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeVolumeSamplesDirectSH ALIAS "ID3DXPRTEngine_ComputeVolumeSamplesDirectSH" ( _
    BYVAL pthis AS DWORD PTR, BYVAL OrderIn AS DWORD, BYVAL OrderOut AS DWORD, _
    BYVAL NumVolSamples AS DWORD, BYVAL pSampleLocs AS DWORD, BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[21] USING ID3DXPRTEngine_ComputeVolumeSamplesDirectSH(pthis, OrderIn, OrderOut, NumVolSamples, pSampleLocs, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeVolumeSamples method
' Computes a projection of the direct lighting from the previous light bounce into spherical
' harmonic (SH) basis vectors that represent incident radiance at specified locations.
' HRESULT ComputeVolumeSamples(
'   LPD3DXPRTBUFFER pSurfDataIn,
'   UINT Order,
'   UINT NumVolSamples.xml,
'   CONST D3DXVECTOR3 * pSampleLocs,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeVolumeSamples ALIAS "ID3DXPRTEngine_ComputeVolumeSamples" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pSurfDataIn AS DWORD, BYVAL Order AS DWORD, _
    BYVAL NumVolSamples AS DWORD, BYVAL pSampleLocs AS DWORD, BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[22] USING ID3DXPRTEngine_ComputeVolumeSamples(pthis, pSurfDataIn, Order, NumVolSamples, pSampleLocs, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' FreeSSData method
' Frees memory used for temporary subsurface light scattering simulation data.
' HRESULT FreeSSData();
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_FreeSSData ALIAS "ID3DXPRTEngine_FreeSSData" (BYVAL pthis AS DWORD PTR) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[23] USING ID3DXPRTEngine_FreeSSData(pthis) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' FreeBounceData method
' Frees memory used for temporary bounced-light simulation data.
' HRESULT FreeBounceData();
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_FreeBounceData ALIAS "ID3DXPRTEngine_FreeBounceData" (BYVAL pthis AS DWORD PTR) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[24] USING ID3DXPRTEngine_FreeBounceData(pthis) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ComputeConvCoeffs method
' Computes convolution coefficients relative to per-sample normal vectors to minimize the
' least-squares error with respect to input precomputed radiance transfer (PRT) data. The
' convolution coefficients can be used with skinned or transformed normals to model global
' effects on dynamic objects.
' HRESULT ComputeConvCoeffs(
'   LPD3DXPRTBUFFER pDataIn,
'   UINT Order,
'   D3DXVECTOR3 * pNormOut,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ComputeConvCoeffs ALIAS "ID3DXPRTEngine_ComputeConvCoeffs" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDataIn AS DWORD, BYVAL Order AS DWORD, _
    BYVAL pNormOut AS DWORD, BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[25] USING ID3DXPRTEngine_ComputeConvCoeffs(pthis, pDataIn, Order, pNormOut, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' ScaleMeshChunk method
' Scales all the samples associated with a given submesh. The method is useful for computing
' subsurface scattering.
' HRESULT ScaleMeshChunk(
'   UINT uMeshChunk,
'   FLOAT fScale,
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_ScaleMeshChunk ALIAS "ID3DXPRTEngine_ScaleMeshChunk" ( _
    BYVAL pthis AS DWORD PTR, BYVAL uMeshChunk AS DWORD, BYVAL FSCALE AS SINGLE, _
    BYREF pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[26] USING ID3DXPRTEngine_ScaleMeshChunk(pthis, uMeshChunk, FSCALE, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' MultiplyAlbedo method
' Multiplies each precomputed radiance transfer (PRT) vector by the per-vertex albedo.
' HRESULT MultiplyAlbedo(
'   LPD3DXPRTBUFFER pDataOut
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_MultiplyAlbedo ALIAS "ID3DXPRTEngine_MultiplyAlbedo" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pDataOut AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[27] USING ID3DXPRTEngine_MultiplyAlbedo(pthis, pDataOut) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetCallBack method
' Sets a pointer to an optional callback function that computes the percentage of
' spherical harmonic (SH) computations completed and gives the caller the option of
' aborting the simulator.
' HRESULT SetCallBack(
'   LPD3DXSHPRTSIMCB pCB,
'   FLOAT Frequency,
'   LPVOID lpUserContext
' );
' ****************************************************************************************
FUNCTION ID3DXPRTEngine_SetCallBack ALIAS "ID3DXPRTEngine_SetCallBack" ( _
    BYVAL pthis AS DWORD PTR, BYVAL pCB AS DWORD, BYVAL Frequency AS SINGLE, _
    BYVAL lpUserContext AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[28] USING ID3DXPRTEngine_SetCallBack(pthis, pCB, Frequency, lpUserContext) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************
 

 

Page last updated on Tuesday, 14 March 2006 23:44:10 +0100