source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/RayTraceEffects [DirectX]/Common/DXUTEffectMap.cpp @ 3255

Revision 3255, 24.6 KB checked in by szirmay, 15 years ago (diff)
Line 
1//-----------------------------------------------------------------------------
2// File: DXUTEffectMap.cpp
3//
4// Desc: Maps the set of standard semantics and annotations to a collection
5//       of ID3DXEffect objects.
6//
7// Copyright (c) Microsoft Corporation. All rights reserved.
8//-----------------------------------------------------------------------------
9#include "dxstdafx.h"
10
11
12
13//-------------------------------------------------------------------------------------
14DXUT_SEMANTIC CDXUTEffectMap::StringToSemantic( const char* cstrSemantic )
15{
16    char strSemantic[MAX_PATH+1] = {0};
17    RemoveTrailingNumber( strSemantic, MAX_PATH, cstrSemantic );
18
19    if( StringEquals( strSemantic, "Diffuse" ) )                               return DXUT_Diffuse;
20    if( StringEquals( strSemantic, "Specular" ) )                              return DXUT_Specular;
21    if( StringEquals( strSemantic, "Ambient" ) )                               return DXUT_Ambient;
22    if( StringEquals( strSemantic, "SpecularPower" ) )                         return DXUT_SpecularPower;
23    if( StringEquals( strSemantic, "Emissive" ) )                              return DXUT_Emissive;
24    if( StringEquals( strSemantic, "Normal" ) )                                return DXUT_Normal;
25    if( StringEquals( strSemantic, "Height" ) )                                return DXUT_Height;
26    if( StringEquals( strSemantic, "Refraction" ) )                            return DXUT_Refraction;
27    if( StringEquals( strSemantic, "Opacity" ) )                               return DXUT_Opacity;
28    if( StringEquals( strSemantic, "Environment" ) )                           return DXUT_Environment;
29    if( StringEquals( strSemantic, "EnvironmentNormal" ) )                     return DXUT_EnvironmentNormal;
30    if( StringEquals( strSemantic, "Fresnel" ) )                               return DXUT_Fresnel;
31   
32    if( StringEquals( strSemantic, "World" ) )                                 return DXUT_World;
33    if( StringEquals( strSemantic, "WorldInverse" ) )                          return DXUT_WorldInverse;
34    if( StringEquals( strSemantic, "WorldInverseTranspose" ) )                 return DXUT_WorldInverseTranspose;
35    if( StringEquals( strSemantic, "WorldView" ) )                             return DXUT_WorldView;
36    if( StringEquals( strSemantic, "WorldViewInverse" ) )                      return DXUT_WorldViewInverse;
37    if( StringEquals( strSemantic, "WorldViewInverseTranspose" ) )             return DXUT_WorldViewInverseTranspose;
38    if( StringEquals( strSemantic, "WorldViewProjection" ) )                   return DXUT_WorldViewProjection;
39    if( StringEquals( strSemantic, "WorldViewProjectionInverse" ) )            return DXUT_WorldViewProjectionInverse;
40    if( StringEquals( strSemantic, "WorldViewProjectionInverseTranspose" ) )   return DXUT_WorldViewProjectionInverseTranspose;
41    if( StringEquals( strSemantic, "View" ) )                                  return DXUT_View;
42    if( StringEquals( strSemantic, "ViewInverse" ) )                           return DXUT_ViewInverse;
43    if( StringEquals( strSemantic, "ViewInverseTranspose" ) )                  return DXUT_ViewInverseTranspose;
44    if( StringEquals( strSemantic, "ViewProjection" ) )                        return DXUT_ViewProjection;
45    if( StringEquals( strSemantic, "ViewProjectionInverse" ) )                 return DXUT_ViewProjectionInverse;
46    if( StringEquals( strSemantic, "ViewProjectionInverseTranspose" ) )        return DXUT_ViewProjectionInverseTranspose;
47    if( StringEquals( strSemantic, "Projection" ) )                            return DXUT_Projection;
48    if( StringEquals( strSemantic, "ProjectionInverse" ) )                     return DXUT_ProjectionInverse;
49    if( StringEquals( strSemantic, "ProjectionInverseTranspose" ) )            return DXUT_ProjectionInverseTranspose;
50
51    if( StringEquals( strSemantic, "RenderTargetDimensions" ) )                return DXUT_RenderTargetDimensions;
52    if( StringEquals( strSemantic, "RenderTargetClipping" ) )                  return DXUT_RenderTargetClipping;
53    if( StringEquals( strSemantic, "Time" ) )                                  return DXUT_Time;
54    if( StringEquals( strSemantic, "LastTime" ) )                              return DXUT_LastTime;
55    if( StringEquals( strSemantic, "ElapsedTime" ) )                           return DXUT_ElapsedTime;
56    if( StringEquals( strSemantic, "Position" ) )                              return DXUT_Position;
57    if( StringEquals( strSemantic, "Direction" ) )                             return DXUT_Direction;
58    if( StringEquals( strSemantic, "BoundingCenter" ) )                        return DXUT_BoundingCenter;
59    if( StringEquals( strSemantic, "BoundingSphereSize" ) )                    return DXUT_BoundingSphereSize;
60    if( StringEquals( strSemantic, "BoundingSphereMin" ) )                     return DXUT_BoundingSphereMin;
61    if( StringEquals( strSemantic, "BoundingSphereMax" ) )                     return DXUT_BoundingSphereMax;
62    if( StringEquals( strSemantic, "BoundingBoxSize" ) )                       return DXUT_BoundingBoxSize;
63    if( StringEquals( strSemantic, "BoundingBoxMin" ) )                        return DXUT_BoundingBoxMin;
64    if( StringEquals( strSemantic, "BoundingBoxMax" ) )                        return DXUT_BoundingBoxMax;
65    if( StringEquals( strSemantic, "Attenuation" ) )                           return DXUT_Attenuation;
66    if( StringEquals( strSemantic, "RenderColorTarget" ) )                     return DXUT_RenderColorTarget;
67    if( StringEquals( strSemantic, "RenderDepthStencilTarget" ) )              return DXUT_RenderDepthStencilTarget;
68    if( StringEquals( strSemantic, "UnitsScale" ) )                            return DXUT_UnitsScale;
69    if( StringEquals( strSemantic, "StandardsGlobal" ) )                       return DXUT_StandardsGlobal;
70       
71    return DXUT_UNKNOWN_SEMANTIC;
72}
73
74
75//-------------------------------------------------------------------------------------
76DXUT_SEMANTIC CDXUTEffectMap::StringToSemantic( const WCHAR* strSemantic )
77{
78    char cstr[MAX_PATH+1] = {0};
79    WideCharToMultiByte( CP_ACP, 0, strSemantic, -1, cstr, MAX_PATH, NULL, NULL );
80    return StringToSemantic( cstr );
81}
82
83
84//-------------------------------------------------------------------------------------
85DXUT_OBJECT CDXUTEffectMap::StringToObject( const char* cstrObject )
86{
87    char strObject[MAX_PATH+1] = {0};
88    RemoveTrailingNumber( strObject, MAX_PATH, cstrObject );
89
90    if( StringEquals( strObject, "Geometry" ) )  return DXUT_Geometry;
91    if( StringEquals( strObject, "Light" ) )     return DXUT_Light;
92    if( StringEquals( strObject, "Camera" ) )    return DXUT_Camera;
93    if( StringEquals( strObject, "Frame" ) )     return DXUT_Frame;
94   
95    return DXUT_UNKNOWN_OBJECT;
96}
97
98
99//-------------------------------------------------------------------------------------
100DXUT_OBJECT CDXUTEffectMap::StringToObject( const WCHAR* strObject )
101{
102    char cstr[MAX_PATH+1] = {0};
103    WideCharToMultiByte( CP_ACP, 0, strObject, -1, cstr, MAX_PATH, NULL, NULL );
104    return StringToObject( cstr );
105}
106
107
108//-------------------------------------------------------------------------------------
109VOID CDXUTEffectMap::Reset()
110{
111        D3DXMatrixIdentity( &m_matWorld );
112    D3DXMatrixIdentity( &m_matView );
113    D3DXMatrixIdentity( &m_matProjection );
114
115        // Reset all the stored parameter lists
116        for( UINT iSemantic = 0; iSemantic < NUM_DXUT_SEMANTICS; iSemantic++ )
117        {
118                for( UINT iObject = 0; iObject < NUM_DXUT_OBJECTS; iObject++ )
119                {
120                        for( UINT iIndex = 0; iIndex < MAX_INDEX; iIndex++ )
121                        {
122                                CGrowableArray<ParamList>* pBinding = &m_Bindings[ iSemantic ][ iObject ][ iIndex ];
123
124                                // Clear nested arrays first
125                                for( int iParamList = 0; iParamList < pBinding->GetSize(); iParamList++ )
126                                {
127                                        pBinding->GetAt( iParamList ).Reset();
128                                }
129                               
130                                // Remove all the bound parameter lists
131                                pBinding->RemoveAll();
132                        }
133                }
134        }
135}
136
137
138//-------------------------------------------------------------------------------------
139HRESULT CDXUTEffectMap::SetStandardParameter( const WCHAR* strSemantic,
140                                         const WCHAR* strObject,
141                                         DWORD dwObjectIndex,
142                                         float* pData,
143                                         DWORD dwDataLen,
144                                         const WCHAR* strType,
145                                         const WCHAR* strUnits,
146                                         const WCHAR* strSpace )
147{
148    // Map the semantic to the standard set
149    DXUT_SEMANTIC eSemantic = StringToSemantic( strSemantic );
150    if( eSemantic == DXUT_UNKNOWN_SEMANTIC )
151        return E_FAIL;
152
153    // Map the object to the standard set
154    DXUT_OBJECT eObject = StringToObject( strObject );
155    if( eObject == DXUT_UNKNOWN_OBJECT )
156        return E_FAIL; 
157
158    return SetStandardParameter( eSemantic, eObject, dwObjectIndex, pData, dwDataLen, strType, strUnits, strSpace );
159}
160
161
162//-------------------------------------------------------------------------------------
163HRESULT CDXUTEffectMap::SetStandardParameter( DXUT_SEMANTIC eSemantic,
164                                         DXUT_OBJECT eObject,
165                                         DWORD dwObjectIndex,
166                                         float* pData,
167                                         DWORD dwDataLen,
168                                         const WCHAR* strType,
169                                         const WCHAR* strUnits,
170                                         const WCHAR* strSpace )
171{
172    HRESULT hr;
173
174    // TODO: remove index limits
175    if( dwObjectIndex >= MAX_INDEX )
176        return E_INVALIDARG;
177
178    // TODO: handle unit and space conversions
179
180    // Retrieve the interested handles
181    CGrowableArray<ParamList>* pBindings = &m_Bindings[ eSemantic ][ eObject ][ dwObjectIndex ];
182       
183    for( int iList=0; iList < pBindings->GetSize(); iList++ )
184    {
185        ParamList& paramList = pBindings->GetAt(iList);
186
187        for( int iParam=0; iParam < paramList.ahParameters.GetSize(); iParam++ )
188        {
189            V_RETURN( paramList.pEffect->SetFloatArray( paramList.ahParameters[iParam], pData, dwDataLen ) );
190        }
191    }
192
193    return S_OK;
194}
195
196void ParamList::Reset()
197{
198        SAFE_RELEASE(pEffect);
199        ahParameters.RemoveAll();
200}
201
202
203//-------------------------------------------------------------------------------------
204// Investigates all the parameters, looking at semantics and annotations and placing
205// handles to these parameters within the internal database.
206//-------------------------------------------------------------------------------------
207HRESULT CDXUTEffectMap::AddEffect( ID3DXEffect* pEffect )
208{
209    HRESULT hr;
210
211        if( pEffect == NULL )
212                return E_INVALIDARG;
213
214    // Get the number of parameters
215    D3DXEFFECT_DESC descEffect;
216    V_RETURN( pEffect->GetDesc( &descEffect ) );
217   
218    // Enumerate the parameters
219    for( UINT iParam=0; iParam < descEffect.Parameters; iParam++ )
220    {
221        // Retrieve param
222        D3DXHANDLE hParameter = pEffect->GetParameter( NULL, iParam );
223        if( NULL == hParameter )
224            return E_FAIL;
225
226        // Grab description
227        D3DXPARAMETER_DESC desc;
228        V_RETURN( pEffect->GetParameterDesc( hParameter, &desc ) );
229
230        // If this parameter doesn't have a semantic, skip to the next parameter
231        if( desc.Semantic == NULL )
232            continue;
233
234        // Map the semantic to the standard set
235        DXUT_SEMANTIC eSemantic = StringToSemantic( desc.Semantic );
236        if( eSemantic == DXUT_UNKNOWN_SEMANTIC )
237            continue;
238
239        // Get the object annotation
240        const char* cstrObject = "Geometry";
241        D3DXHANDLE hAnnotation = pEffect->GetAnnotationByName( hParameter, "Object" );
242        if( hAnnotation )
243        {
244            V_RETURN( pEffect->GetString( hAnnotation, &cstrObject ) );
245        }
246
247        // Map the object to the standard set
248        DXUT_OBJECT eObject = StringToObject( cstrObject );
249        if( eObject == DXUT_UNKNOWN_OBJECT )
250            continue;
251
252        // Extract the index from the semantic
253        int index = 0;
254        const char* strIndex = desc.Semantic + strlen(desc.Semantic)-1;
255
256        // If there is a digit at the end of the semantic, locate the beginning of the index
257        // and convert to an integer
258        if( isdigit( (BYTE) (*strIndex) ) )
259        {
260            while( isdigit( (BYTE) (*(strIndex-1)) ) )
261            {
262                --strIndex;
263            }
264
265            index = atoi( strIndex );
266        }
267
268        // Check whether index is out of bounds
269        if( index < 0 || index >= MAX_INDEX )
270            continue;
271
272        // Store the handle
273        CGrowableArray<ParamList>* pBindings = &m_Bindings[ eSemantic ][ eObject ][ index ];
274       
275        bool bBound = false;
276        for( int i=0; i < pBindings->GetSize(); i++ )
277        {
278            if( pBindings->GetAt(i).pEffect == pEffect )
279            {
280                // Found the containing effect for this parameter in the list, add the new handle
281                pBindings->GetAt(i).ahParameters.Add( hParameter );
282                bBound = true;
283                break;
284            }
285        }
286
287        if( !bBound )
288        {
289            // This parameter belongs to a new effect
290            ParamList newParamList;
291            newParamList.pEffect = pEffect;
292                        pEffect->AddRef();
293            newParamList.ahParameters.Add( hParameter );
294            pBindings->Add( newParamList );
295        }
296       
297    }
298   
299    return S_OK;
300}
301
302
303//-------------------------------------------------------------------------------------
304// Removes all instances of this effect from the binding list
305//-------------------------------------------------------------------------------------
306HRESULT CDXUTEffectMap::RemoveEffect( ID3DXEffect* pEffect )
307{
308        if( pEffect == NULL )
309                return E_INVALIDARG;
310
311        // Search through the list of registered semantics and remove all items
312        // assigned to the given effect
313        for( UINT iSemantic = 0; iSemantic < NUM_DXUT_SEMANTICS; iSemantic++ )
314        {
315                for( UINT iObject = 0; iObject < NUM_DXUT_OBJECTS; iObject++ )
316                {
317                        for( UINT iIndex = 0; iIndex < MAX_INDEX; iIndex++ )
318                        {
319                                CGrowableArray<ParamList>* pBinding = &m_Bindings[ iSemantic ][ iObject ][ iIndex ];
320
321                                // Clear nested arrays first
322                                for( int iParamList = 0; iParamList < pBinding->GetSize(); iParamList++ )
323                                {
324                                        ParamList& rParamList = pBinding->GetAt( iParamList );
325
326                                        if( rParamList.pEffect == pEffect )
327                                                rParamList.Reset();
328                                }
329                        }
330                }
331        }
332
333        return S_OK;
334}
335
336
337//-------------------------------------------------------------------------------------
338HRESULT CDXUTEffectMap::SetWorldMatrix( D3DXMATRIXA16* pWorldMatrix, const WCHAR* strUnits )
339{
340    m_matWorld = *pWorldMatrix;
341    return UpdateTransforms( DXUT_World );
342}
343
344
345//-------------------------------------------------------------------------------------
346HRESULT CDXUTEffectMap::SetViewMatrix( D3DXMATRIXA16* pViewMatrix, const WCHAR* strUnits )
347{
348    m_matView = *pViewMatrix;
349    return UpdateTransforms( DXUT_View );
350}
351
352
353//-------------------------------------------------------------------------------------
354HRESULT CDXUTEffectMap::SetProjectionMatrix( D3DXMATRIXA16* pProjectionMatrix )
355{
356    m_matProjection = *pProjectionMatrix;
357    return UpdateTransforms( DXUT_Projection );
358}
359
360
361//-------------------------------------------------------------------------------------
362HRESULT CDXUTEffectMap::UpdateTransforms( DXUT_SEMANTIC eSemantic, const WCHAR* strUnits )
363{
364    HRESULT hr;
365
366    // Determine which transforms are required by the effect
367    bool bEffectContains[ NUM_DXUT_SEMANTICS ] = {0};
368    for( int iTransform = DXUT_World; iTransform <= DXUT_ProjectionInverseTranspose; iTransform++ )
369    {
370        bEffectContains[iTransform] = ( m_Bindings[ iTransform ][ DXUT_Geometry ][ 0 ].GetSize() > 0 );
371    }
372
373    if( eSemantic == DXUT_World )
374    {
375        // World matrix permutations
376        if( bEffectContains[ DXUT_World ] ||
377            bEffectContains[ DXUT_WorldInverse ] ||
378            bEffectContains[ DXUT_WorldInverseTranspose ] )
379        {
380            V_RETURN( SetStandardParameter( DXUT_World, DXUT_Geometry, 0, (float*)&m_matWorld, 16, L"", strUnits, L"World" ) );
381
382            if( bEffectContains[ DXUT_WorldInverse ] ||
383                bEffectContains[ DXUT_WorldInverseTranspose ] )
384            {
385                D3DXMATRIXA16 matWorldInverse;
386                D3DXMatrixInverse( &matWorldInverse, NULL, &m_matWorld );
387                V_RETURN( SetStandardParameter( DXUT_WorldInverse, DXUT_Geometry, 0, (float*)&matWorldInverse, 16, L"", strUnits, L"World" ) );
388           
389                if( bEffectContains[ DXUT_WorldInverseTranspose ] )
390                {
391                    D3DXMATRIXA16 matWorldInverseTranspose;
392                    D3DXMatrixTranspose( &matWorldInverseTranspose, &matWorldInverse );
393                    V_RETURN( SetStandardParameter( DXUT_WorldInverseTranspose, DXUT_Geometry, 0, (float*)&matWorldInverseTranspose, 16, L"", strUnits, L"World" ) );
394                }
395            }
396        }
397    }
398
399    if( eSemantic == DXUT_World ||
400        eSemantic == DXUT_View )
401    {
402        // WorldView matrix permutations
403        if( bEffectContains[ DXUT_WorldView ] ||
404            bEffectContains[ DXUT_WorldViewInverse ] ||
405            bEffectContains[ DXUT_WorldViewInverseTranspose ] )
406        {
407            D3DXMATRIXA16 matWorldView;
408            D3DXMatrixMultiply( &matWorldView, &m_matWorld, &m_matView );
409            V_RETURN( SetStandardParameter( DXUT_WorldView, DXUT_Geometry, 0, (float*)&matWorldView, 16, L"", strUnits, L"World" ) );
410       
411            if( bEffectContains[ DXUT_WorldViewInverse ] ||
412                bEffectContains[ DXUT_WorldViewInverseTranspose ] )
413            {
414                D3DXMATRIXA16 matWorldViewInverse;
415                D3DXMatrixInverse( &matWorldViewInverse, NULL, &matWorldView );   
416                V_RETURN( SetStandardParameter( DXUT_WorldViewInverse, DXUT_Geometry, 0, (float*)&matWorldViewInverse, 16, L"", strUnits, L"World" ) );
417           
418                if( bEffectContains[ DXUT_WorldViewInverseTranspose ] )
419                {
420                    D3DXMATRIXA16 matWorldViewInverseTranspose;
421                    D3DXMatrixTranspose( &matWorldViewInverseTranspose, &matWorldViewInverse );
422                    V_RETURN( SetStandardParameter( DXUT_WorldViewInverseTranspose, DXUT_Geometry, 0, (float*)&matWorldViewInverseTranspose, 16, L"", strUnits, L"World" ) );
423                }
424            }
425        }
426    }
427
428    if( eSemantic == DXUT_World ||
429        eSemantic == DXUT_View ||
430        eSemantic == DXUT_Projection )
431    {
432        // WorldViewProjection matrix permutations
433        if( bEffectContains[ DXUT_WorldViewProjection ] ||
434            bEffectContains[ DXUT_WorldViewProjectionInverse ] ||
435            bEffectContains[ DXUT_WorldViewProjectionInverseTranspose ] )
436        {
437            D3DXMATRIXA16 matWorldViewProjection;
438            D3DXMatrixMultiply( &matWorldViewProjection, &m_matWorld, &m_matView );
439            D3DXMatrixMultiply( &matWorldViewProjection, &matWorldViewProjection, &m_matProjection );
440
441            V_RETURN( SetStandardParameter( DXUT_WorldViewProjection, DXUT_Geometry, 0, (float*)&matWorldViewProjection, 16, L"", strUnits, L"World" ) );
442       
443            if( bEffectContains[ DXUT_WorldViewProjectionInverse ] ||
444                bEffectContains[ DXUT_WorldViewProjectionInverseTranspose ] )
445            {
446                D3DXMATRIXA16 matWorldViewProjectionInverse;
447                D3DXMatrixInverse( &matWorldViewProjectionInverse, NULL, &matWorldViewProjection );   
448                V_RETURN( SetStandardParameter( DXUT_WorldViewProjectionInverse, DXUT_Geometry, 0, (float*)&matWorldViewProjectionInverse, 16, L"", strUnits, L"World" ) );
449           
450                if( bEffectContains[ DXUT_WorldViewProjectionInverseTranspose ] )
451                {
452                    D3DXMATRIXA16 matWorldViewProjectionInverseTranspose;
453                    D3DXMatrixTranspose( &matWorldViewProjectionInverseTranspose, &matWorldViewProjectionInverse );
454                    V_RETURN( SetStandardParameter( DXUT_WorldViewProjectionInverseTranspose, DXUT_Geometry, 0, (float*)&matWorldViewProjectionInverseTranspose, 16, L"", strUnits, L"World" ) );
455                }
456            }
457        }
458    }
459
460    if( eSemantic == DXUT_View )
461    {
462        // View matrix permutations
463        if( bEffectContains[ DXUT_View ] ||
464            bEffectContains[ DXUT_ViewInverse ] ||
465            bEffectContains[ DXUT_ViewInverseTranspose ] )
466        {
467            V_RETURN( SetStandardParameter( DXUT_View, DXUT_Geometry, 0, (float*)&m_matView, 16, L"", strUnits, L"World" ) );
468
469            if( bEffectContains[ DXUT_ViewInverse ] ||
470                bEffectContains[ DXUT_ViewInverseTranspose ] )
471            {
472                D3DXMATRIXA16 matViewInverse;
473                D3DXMatrixInverse( &matViewInverse, NULL, &m_matView );
474                V_RETURN( SetStandardParameter( DXUT_ViewInverse, DXUT_Geometry, 0, (float*)&matViewInverse, 16, L"", strUnits, L"World" ) );
475           
476                if( bEffectContains[ DXUT_ViewInverseTranspose ] )
477                {
478                    D3DXMATRIXA16 matViewInverseTranspose;
479                    D3DXMatrixTranspose( &matViewInverseTranspose, &matViewInverse );
480                    V_RETURN( SetStandardParameter( DXUT_ViewInverseTranspose, DXUT_Geometry, 0, (float*)&matViewInverseTranspose, 16, L"", strUnits, L"World" ) );
481                }
482            }
483        }
484    }
485
486    if( eSemantic == DXUT_View ||
487        eSemantic == DXUT_Projection )
488    {
489        // ViewProjection matrix permutations
490        if( bEffectContains[ DXUT_ViewProjection ] ||
491            bEffectContains[ DXUT_ViewProjectionInverse ] ||
492            bEffectContains[ DXUT_ViewProjectionInverseTranspose ] )
493        {
494            D3DXMATRIXA16 matViewProjection;
495            D3DXMatrixMultiply( &matViewProjection, &m_matView, &m_matProjection );
496            V_RETURN( SetStandardParameter( DXUT_ViewProjection, DXUT_Geometry, 0, (float*)&matViewProjection, 16, L"", strUnits, L"World" ) );
497       
498            if( bEffectContains[ DXUT_ViewProjectionInverse ] ||
499                bEffectContains[ DXUT_ViewProjectionInverseTranspose ] )
500            {
501                D3DXMATRIXA16 matViewProjectionInverse;
502                D3DXMatrixInverse( &matViewProjectionInverse, NULL, &matViewProjection );   
503                V_RETURN( SetStandardParameter( DXUT_ViewProjectionInverse, DXUT_Geometry, 0, (float*)&matViewProjectionInverse, 16, L"", strUnits, L"World" ) );
504           
505                if( bEffectContains[ DXUT_ViewProjectionInverseTranspose ] )
506                {
507                    D3DXMATRIXA16 matViewProjectionInverseTranspose;
508                    D3DXMatrixTranspose( &matViewProjectionInverseTranspose, &matViewProjectionInverse );
509                    V_RETURN( SetStandardParameter( DXUT_ViewProjectionInverseTranspose, DXUT_Geometry, 0, (float*)&matViewProjectionInverseTranspose, 16, L"", strUnits, L"World" ) );
510                }
511            }
512        }
513    }
514
515    if( eSemantic == DXUT_Projection )
516    {
517        // Projection matrix permutations
518        if( bEffectContains[ DXUT_Projection ] ||
519            bEffectContains[ DXUT_ProjectionInverse ] ||
520            bEffectContains[ DXUT_ProjectionInverseTranspose ] )
521        {
522            V_RETURN( SetStandardParameter( DXUT_Projection, DXUT_Geometry, 0, (float*)&m_matProjection, 16, L"", strUnits, L"World" ) );
523
524            if( bEffectContains[ DXUT_ProjectionInverse ] ||
525                bEffectContains[ DXUT_ProjectionInverseTranspose ] )
526            {
527                D3DXMATRIXA16 matProjectionInverse;
528                D3DXMatrixInverse( &matProjectionInverse, NULL, &m_matProjection );
529                V_RETURN( SetStandardParameter( DXUT_ProjectionInverse, DXUT_Geometry, 0, (float*)&matProjectionInverse, 16, L"", strUnits, L"World" ) );
530           
531                if( bEffectContains[ DXUT_ProjectionInverseTranspose ] )
532                {
533                    D3DXMATRIXA16 matProjectionInverseTranspose;
534                    D3DXMatrixTranspose( &matProjectionInverseTranspose, &matProjectionInverse );
535                    V_RETURN( SetStandardParameter( DXUT_ProjectionInverseTranspose, DXUT_Geometry, 0, (float*)&matProjectionInverseTranspose, 16, L"", strUnits, L"World" ) );
536                }
537            }
538        }
539    }
540
541    return S_OK;
542}
543
Note: See TracBrowser for help on using the repository browser.