Jump to content
  • Advertisement
Sign in to follow this  

SetFloat, SetVector, SetMatrix have no effect

This topic is 2170 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'm having trouble setting shader variables, as in I'm unable to.  In the FX file, I have:


//cbuffer ExplosionData : register(b0) // BUGBUG consistent casing
float    secondsLifetime;
float    secondsRemaining;
float    explosionSpeed;
   float4x4 worldViewProjection;
   Texture  particleTexture;
float3   startPosition;


I get the D3DXHANDLEs to them by name, and they come back with valid handles.  As you can see I originally had them in a cbuffer but moved them out just to see if it made a difference, which it did not.  This is all vs3_0 and ps3_0 stuff.


_hSecondsLiftime       = _ptrEffect->GetParameterByName(0, "secondsLifetime");
_hSecondsRemaining     = _ptrEffect->GetParameterByName(0, "secondsRemaining");
_hExplosionSpeed       = _ptrEffect->GetParameterByName(0, "explosionSpeed");
_hWorldViewProjection  = _ptrEffect->GetParameterByName(0, "worldViewProjection");
_hParticleTexture      = _ptrEffect->GetParameterByName(0, "particleTexture");
_hStartPosition        = _ptrEffect->GetParameterByName(0, "startPosition");
In my render code I do BeginScene, SetTechnique, abd BeginPass.  Then I SetVertexDeclaration, SetVertexShader, SetPixel shader, all good so far.  Then I start to set my shader variables.
In PIX, however, I can see this:
IDIRECT3DDevice9::SetFloat(0xFEFE5B7B, 0.000f);
IDIRECT3DDevice9::SetFloat(0xFEFE5B23, 0.000f);
IDIRECT3DDevice9::SetMatrix(0xFEFE5A73, 0x3FE7C3B5)

The problem, as you can see, is that no matter values (and I've walked it and verified they are non-zero at the call) get passed through as zero, and my worldViewProjection winds up as an empty matrix.


The question, then, is:  "What could I be doing wrong based on the above to cause setting my shader variables to do nothing?"


I've stuck a RAR of the PIX file at the end, for what that's worth!  Many thanks for any tips!


Share this post

Link to post
Share on other sites

You're making your Set calls after BeginPass so you need to call ID3DXEffect::CommitChanges before you can draw.


See http://msdn.microsoft.com/en-us/library/windows/desktop/bb205817%28v=vs.85%29.aspx



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.

Edited by mhagain

Share this post

Link to post
Share on other sites

My issue turned out to be a pretty basic one - not calling effect->Begin(...) on the effect itself, although I had called Begin on the scene and on the pass.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!