Archived

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

Some questions on D3D (VBs & Shaders)

This topic is 5583 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

Ok a few things, mostly simple stuff I think: 1)If I fill a VB with untransformed data and call DrawPrimitive on that data, what actually happens? Does all the data get copied to the videocard and fiddled with, or do the transformed vertices get stored in place of the untransformed ones? 2)If I''m using shaders, how do I eliminate having to transfer data from the RAM to the video card? Only the whole point of them is make the GPU do more without impinging on the normal CPU, right? 3)Can I use a Fixed function vertex shader with a custom pixel shader, to allow per-pixel stuff but not bother rewriting lighting/transform stuff? How would I know what arguments are stored where? 4)The vertex shaders relpace the transformations and lighting effects right? So does that mean the SetLight functions are useless, and I can use my own light structures? How do I get the vertex shader to know about the lights and how do I emulate D3D by selecting the 8 most relevant lights for each vertex? 5)Another post talks about using multiple streams simultaneously - one for x,y,z coords, one for colour, one for tex coords etc. I asked about this recently and was told you cannot use more than one stream at the same time. How would you do it - you can only set the vertex shader to one FVF, using many streams like this with different FVFs seems to break this.
Read about my game, project #1 NEW (13th August): A new screenshot is up, plus diaries for week #3
John 3:16

Share this post


Link to post
Share on other sites
1.) It depends on your hardware. Cards with hardware transformation and lighting have their vertices sent to the card first. Cards that don''t support it, get processed on the CPU using optomized assembly.

2.) Don''t worry about the data transfer because if you plan right, it shouln''t make much of a difference. You have to send some data to the card no matter what. And sending the data usually doesn''t slow the CPU down tooo much although if you have a lot of data, it will.

3.) Yes. It''s not common though because you don''t have control over many options. Usually a vshader and pshader are used with each other if both are used.

4.) Yes they replace t&l. And yes, SetLight, SetTransform, etc are all useless with vshaders. You can use your own light structures if you want. You have control so that''s your decision. By the way, 8 lights isn''t the limit with vshaders. It was only that way with regular t&l. But if you want to select the 8 most relevant lights, you have to do that manually in your code.

5.) Of course you can use multiply streams and it''s helpful when you only want to change certain data in the vertices. You need to change your declaration, and you shader code has to be modified for multiple streams but then it should work. It''s all in the SDK.

---
My Site-My Tetris Clone w/Source
Come join us on IRC in #directxdev @ irc.afternet.org

Share this post


Link to post
Share on other sites
Could I ask for an example of multiple streams? Lets say I have one FVF for position, another for normals, and two for different texture coordinates. How do I set everything up? Can I for instance have one FVF using index buffering and the others not?

How would I choose which lights to use, since I''d have to do all this in shader language and conditional logic isn''t supported (no if-else yet)?



Read about my game, project #1
NEW (13th August): A new screenshot is up, plus diaries for week #3


John 3:16

Share this post


Link to post
Share on other sites