Advertisement Jump to content
Sign in to follow this  

render to multi-target

This topic is 3036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to use shader once to render to multi-target right now the first texture is correct but the last two seems not working

struct PSFRT_OUT {
float4 Col0 : COLOR0;
float4 Col1 : COLOR1;
float4 Col2 : COLOR2;
PSFRT_OUT PSFRT(float2 infor2: TEXCOORD2,float2 infor3: TEXCOORD3,float2 infor4: TEXCOORD4,float2 infor5: TEXCOORD5,float2 infor6: TEXCOORD6){
Out.Col0 = float4(infor2,infor3);
Out.Col1 = float4(infor4,infor5);
Out.Col2 = float4(infor6,0.0f,1.0f);
return Out;

m_pNewPosTexture->GetSurfaceLevel( 0, &m_pNewPosSurf );
hr = m_pDevice->SetRenderTarget(0,m_pNewPosSurf);

m_pNewVelTexture->GetSurfaceLevel( 0, &m_pNewVelSurf );
hr = m_pDevice->SetRenderTarget(1,m_pNewVelSurf);

m_pNewAttributeTexture->GetSurfaceLevel( 0, &m_pNewAttributeSur);
hr = m_pDevice->SetRenderTarget(2,m_pNewAttributeSur);

hr = mFX->CommitChanges();

//Begin passes
UINT numPasses=0;
m_pDevice->SetStreamSource(0, m_pVBQuad, 0, sizeof(INFORMATION));
m_pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2110);

plus i have checked the number of target I cud use which is 4 and the output of pixel shader is surely correct
D3DCAPS9 Caps;
bool multitarget = true;
m_pDevice->GetDeviceCaps( &Caps );
if( Caps.NumSimultaneousRTs < 2 )
multitarget = false;

so where am I wrong?

Share this post

Link to post
Share on other sites
Hope you didn't forget to;
* write mFX->EndPass(); and mFX->End(); lines.
* restore render targets.

Also, there's no need to call mFX->CommitChanges(); before any rendering operation. Because it's purpose is updating all the data in your effect sent from software (like textures, floating point values etc.) between ID3DXEffect::BeginPass(); and ID3DXEffect::EndPass() lines.

Share this post

Link to post
Share on other sites
thanks I wrote mFX->EndPass(); mFX->End(); and restore render targets.
so that means I need to call mFX->CommitChanges(); when I update the effect like

bool MyParticleSystem::Update(D3DXVECTOR3 CameraPos, float Time,D3DXMATRIX View, D3DXMATRIX projection){

vp = View * projection;

return true;

when i swap the textures that will used in effect do I need to do that as well?

Share this post

Link to post
Share on other sites
If you pass any data after calling ID3XEffect::BeginPass(), you need to call ID3DXEffect::CommitChanges().

m_pEffect->SetMatrix ( blah blah blah);
m_pEffect->SetTexture( blah blah blah);
m_pEffect->BeginPass (0);
m_pEffect->SetInt ("someInt", someInt);
m_pEffect->CommitChanges (); //call this for clearly setting "someInt" variable.

So, if you swap any texture that will be sent to the shader, you must send it again. And if you do it after calling ID3DXEffect::BeginPass(), you also need to call ID3DXEffect::CommitChanges().


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!