• Advertisement
Sign in to follow this  

Shaders and Streams

This topic is 4427 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 currently have a keyframed mesh with each frame located in a different vertex buffer. What I'm trying to do is put the current frame in one stream using SetVertexStream( 0, ... and the next frame in another stream stream using SetVertexStream( 1, ... and then lerp between them using a cg vertex shader. Unfortunately, I can't figure out how to access the second frames components in a shader. POSITION1 etc doesn't seem to work. My suspicion is that this is because I am using FVF codes rather than using a D3DVERTEXELEMENT9 array. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
FVF doesnt make sence when using multiple streams and shaders, so u just need to create vertex declaration

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
FVF doesnt make sence when using multiple streams and shaders, so u just need to create vertex declaration

As the AP said - using FVF's with shaders doesn't really make much sense (I actually thought it'd complain at you if you did...).

Check out the D3DVERTEXELEMENT9::Stream field - that should do what you want [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Oh those crazy FVFs!
I actually find working with vertex declarations much easier. Not exactly sure why, since I'm mostly an OpenGL guy. That being said, however, I remember seeing an article/thread somewhere on GameDev about setting up custom vertex declarations; but, the link escapes me, for the time being. So, I went ahead and looked for other links on the subject.

Check out GameTutorial's little tutorial on vertex declarations.

If I happen across the article before anyone else, I'll add it to this post for you. I'm certain there was one here somewhere.

Addition: Here's something from circlesoft that might be of interest to you.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dorvo
I actually find working with vertex declarations much easier. Not exactly sure why, since I'm mostly an OpenGL guy.

Even though they require more code (the convienience of FVFs was that they could be produced in one line), vertex decls are generally well-liked since they are much easier to understand. However, even with their lower learning curve, they provide a lot more power and customization over the vertex structure.

Share this post


Link to post
Share on other sites
what is so different and better with vertex declerations? You replace the FVF with an array of elements and have a lot more code to write and i don't see any advantages right now. Can anyone explain me what's so cool about them?

regards,
m4gnus

Share this post


Link to post
Share on other sites
Quote:
Original post by m4gnus
what is so different and better with vertex declerations? You replace the FVF with an array of elements and have a lot more code to write and i don't see any advantages right now. Can anyone explain me what's so cool about them?

Quite simply they are more flexible.

FVF's, regardless of their definition, must have their vertex elements defined as predefined quantities in a predefined order. Declarations can, within reason, be arbitrary sizes in arbitrary orders.

All FVF's map to Declarations, but not all Declarations can map to FVF's.

When using the fixed function pipeline the case for Declarations over FVF's isn't quite so compelling, but as soon a you move into the programmable pipeline you'll quickly realise that they're a lot more "natural" and convenient. Especially if you want to start playing with more complex effects (e.g. multiple streams).

hth
Jack

Share this post


Link to post
Share on other sites
To mention some practical applications, things like instancing and morphing benefit greatly from having these vertex streams (and the declarations to use them). With the appropriate hardware, you can do this completely on the GPU which can drastically improve performance.

Share this post


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

  • Advertisement