Transforms in Multi-Pass effect (HDR sample)

Started by
1 comment, last by AnonymousTipster 18 years, 3 months ago
I've been working on a little application based on the HDRLighting sample included with the DX9August SDK. I've made some small changes, but I'm having trouble applying a transformation matrix to a mesh within the HDR Pass. An extract from the source looks like this: D3DXMATRIX mView = *g_Camera.GetViewMatrix();//N.B g_Camera is a CFirstPersonCamera D3DXMATRIX objectMat; objectMat = D3DXMATRIX( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 100.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f );//should translate 100.0f upwards g_pEffect->SetTechnique("RenderScene"); g_pEffect->SetMatrix("g_mObjectToView", &mView); hr = g_pEffect->Begin(&uiPassCount, 0); if( FAILED(hr) ) return hr; for (uiPass = 0; uiPass < uiPassCount; uiPass++) { g_pEffect->BeginPass(uiPass); // Turn off emissive lighting D3DXVECTOR4 vNull( 0.0f, 0.0f, 0.0f, 0.0f ); g_pEffect->SetVector("g_vEmissive", &vNull); // Enable texture g_pEffect->SetBool("g_bEnableTexture", true); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); g_pEffect->SetFloat("g_fPhongExponent", 5.0f); g_pEffect->SetFloat("g_fPhongCoefficient", 1.0f); g_pEffect->SetFloat("g_fDiffuseCoefficient", 0.5f); g_pEffect->SetBool("g_bEnableTexture", true); g_pd3dDevice->SetTexture(0, g_pTexGrass1 ); g_pd3dDevice->SetTransform(D3DTS_WORLD,&objectMat);//this appears to not have any effect g_pEffect->CommitChanges(); g_pMeshGroundPlane->DrawSubset(0); g_pEffect->EndPass(); } g_pEffect->End(); I thought that device->SetTransform() would work, but it seems that it is unaffected by this code. I'm using the HDRLighting.fx file, as it makes my end of the code smaller than doing it all in Cpp files. The way I would have expected it to work would be g_pEffect->SetMatrix("g_mWorldMatrix", &objectMat); but the only matrices in the .fx file are g_mObjectToView and g_mProjection. My question is: How can I apply a transformation matrix within this HDR setup? Thanks.
Advertisement
Quote:Original post by AnonymousTipster
The way I would have expected it to work would be g_pEffect->SetMatrix("g_mWorldMatrix", &objectMat); but the only matrices in the .fx file are g_mObjectToView and g_mProjection.


WorldMatrix * ViewMatrix should transform from object space to view space, which is why I guess you should put W * V in g_mObjectToView.

Ah, great. Thanks, I thought it would be something simple, but I didn't quite know what. Thanks for your help.

This topic is closed to new replies.

Advertisement