Archived

This topic is now archived and is closed to further replies.

Pixel + Vertex Shader problem

This topic is 5144 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''ve got an issue with a small program that I am running that contains a simple pixel shader that displays a texture that turns all black values transparent- that I am trying to couple with a vertex shader that is (for the moment) only trying to shade an object with your normal colors. And while each in its own right is working great, when I combine the pixel shader and vertex shader in the same program, bad things are happening. I turn the PS on, and map my texture, then turn it off. Then I turn the VS on, draw my happy little box, and turn it off. And the problem that I am facing is that my box that I''ve drawn with my vertex shader is TOTALLY black- only a sillouhette. But what is most frustrating about this is that for the split second (maybe only the first frame) in which the box has been drawn before the shader is turned on again appears to work flawlessly. Only a split second into the program does the box turn black again. Any help would be appreciated, since I admit that I am not by any means an expert on these shaders or even the pipeline... so assistance or clarification is welcome.

Share this post


Link to post
Share on other sites
quote:
Original post by Beserkerfork
I turn the PS on, and map my texture, then turn it off. Then I turn the VS on, draw my happy little box, and turn it off. And the problem that I am facing is that my box that I''ve drawn with my vertex shader is TOTALLY black- only a sillouhette.


The above is a tad confusing. Can you post some pseudocode of what you''re doing? Do you mean:

EnablePS();
dev->SetTexture( blah );
DisablePS();
...
EnableVS();
dev->Draw*Primitive*( blah );
DisableVS();



If that''s what you have, then that''s your problem, D3D doesn''t quite work that way - it isn''t blocking/synchronous - what you pass in to the Set* calls is simply flagged until Draw* time - that''s when things actually start happening.

You should have something like:

EnableVS();
EnablePS();
dev->SetTexture( blah );
dev->Draw*Primitive*( blah );
DisablePS();
DisableVS();


The two Disables are also unnecessary.


If that isn''t the problem, try using the DEBUG D3D runtimes with the level slider up high and see if D3D tells you anything in the debug output.

Additionally try a ValidateDevice() call immediately before you Draw* to see if the driver is unhappy over something in your pipeline setup.

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
Thanks, you had the idea right- and how I was trying to work the shaders was incorrect.

I think more of the problem was involved with me not wanting to actually tackle the two together yet... and so I tried to get one at a time.

So your response was helpful, thank you- mostly due to the fact that you stated what I didn''t want to hear... "you can''t slack your way past this one". And so, with a lot of effort on it this morning I made huge steps of progress combining the two shaders together with success (for the moment).

So crisis averted! Thanks!

Share this post


Link to post
Share on other sites