• Create Account

### #ActualSHilbert

Posted 30 June 2012 - 02:40 PM

Looks like maybe it's because you're calling SetTexture inside Begin/EndPass.

If the application changes any effect state using any of the Effect::Setx methods inside of a ID3DXEffect::BeginPass/ID3DXEffect::EndPass matching pair, the application must call ID3DXEffect::CommitChanges to set the update the device with the state changes. If no state changes occur within a ID3DXEffect::BeginPass and ID3DXEffect::EndPass matching pair, it is not necessary to call ID3DXEffect::CommitChanges.

So one option is to call mFX->CommitChanges().

I don't think you actually need to manually change the texture per pass at all, though. If you just define 3 texture uniforms, instead of the single gTex you have now, and just fill them in with your 3 different textures before you begin drawing, and sample from the right one in each VS, the effect system will sort it all out for you.

EDIT: FYI, to further clean up your effect rendering loop, you can specify the blend modes in your FX file too, by setting states inside the passes:


technique TerrainMultiTexTech
{
pass P0
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = FALSE;
}
pass P1
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = TRUE;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
}
pass P2
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = TRUE;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
}
}


### #3SHilbert

Posted 30 June 2012 - 02:40 PM

Looks like maybe it's because you're calling SetTexture inside Begin/EndPass.

If the application changes any effect state using any of the Effect::Setx methods inside of a ID3DXEffect::BeginPass/ID3DXEffect::EndPass matching pair, the application must call ID3DXEffect::CommitChanges to set the update the device with the state changes. If no state changes occur within a ID3DXEffect::BeginPass and ID3DXEffect::EndPass matching pair, it is not necessary to call ID3DXEffect::CommitChanges.

So one option is to call mFX->CommitChanges().

I don't think you actually need to manually change the texture per pass at all, though. If you just define 3 texture uniforms, instead of the single gTex you have now, and just fill them in with your 3 different textures before you begin drawing, and sample from the right one in each VS, the effect system will sort it all out for you.

EDIT: FYI, to further clean up your effect rendering loop, you can specify the blend modes in your FX file too, by setting states inside the passes:


technique TerrainMultiTexTech
{
pass P0
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = FALSE;
}
pass P1
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = TRUE;
DestBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;
}
pass P2
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = TRUE;
DestBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;
}
}


### #2SHilbert

Posted 30 June 2012 - 02:39 PM

Looks like maybe it's because you're calling SetTexture inside Begin/EndPass.

If the application changes any effect state using any of the Effect::Setx methods inside of a ID3DXEffect::BeginPass/ID3DXEffect::EndPass matching pair, the application must call ID3DXEffect::CommitChanges to set the update the device with the state changes. If no state changes occur within a ID3DXEffect::BeginPass and ID3DXEffect::EndPass matching pair, it is not necessary to call ID3DXEffect::CommitChanges.

So one option is to call mFX->CommitChanges().

I don't think you actually need to manually change the texture per pass at all, though. If you just define 3 texture uniforms, instead of the single gTex you have now, and just fill them in with your 3 different textures before you begin drawing, and sample from the right one in each VS, the effect system will sort it all out for you.

EDIT: FYI, to further clean up your effect rendering loop, you can specify the blend modes in your FX file too, by setting states inside the passes:


technique TerrainMultiTexTech
{
pass P0
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = FALSE;
}
pass P1
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = TRUE;
SrcBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;
}
pass P2
{
// Specify the vertex and pixel shader associated with this pass.

AlphaBlendEnable = TRUE;
SrcBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;
}
}


### #1SHilbert

Posted 30 June 2012 - 02:33 PM

Looks like maybe it's because you're calling SetTexture inside Begin/EndPass.

If the application changes any effect state using any of the Effect::Setx methods inside of a ID3DXEffect::BeginPass/ID3DXEffect::EndPass matching pair, the application must call ID3DXEffect::CommitChanges to set the update the device with the state changes. If no state changes occur within a ID3DXEffect::BeginPass and ID3DXEffect::EndPass matching pair, it is not necessary to call ID3DXEffect::CommitChanges.

So one option is to call mFX->CommitChanges().

I don't think you actually need to manually change the texture per pass at all, though. If you just define 3 texture uniforms, instead of the single gTex you have now, and just fill them in with your 3 different textures before you begin drawing, the effect system will sort it all out for you.

PARTNERS