Jump to content
  • Advertisement


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


HLSL, multiple streams and the effect framework

This topic is 5430 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 have been searching all over the world, litterally, for how to do this. i'm using HLSL and the Effect framework (all managed) and want to, somehow, send multiple streams to the vertex shader. how do i do this? i know how to do it te "regular" way - the way you find everywhere - that is to create a decl[] and using this when creating the vertex shader. but now i'm using the effect framework, and HLSL. please help... [edited by - apanjocko on November 9, 2003 3:39:04 PM]

Share this post

Link to post
Share on other sites
In your decl, put a stream(0) tag, specify everything from stream 0, put a stream(1) tag, specify everything from stream 1, etc.

In DX8 your shader and decl are compiled as one, so if you have the same data, but arrange it 2 different ways you''ll need two shaders. The DX8 decl specifies the source streams, the data types and which registers it should go to.

In DX9 your shader and decl and seperate. If you arrange the data in two ways, you have two decls but only 1 shader. The DX9 decl specifies the source streams, the data types, and then then shader maps the types to various registers.

Using various streams depends on:
1. Your decl.
2. SetStreamSource(n, ...)
3. SetVertexShader/SetVertexDeclaration
4. Actually putting data into various vertex buffers.

Share this post

Link to post
Share on other sites
The way i do it is like this:

i have a meshdata class which is a variety of streams in it, for example:

stream1: position stream
stream2: normal stream
stream3: texture stream

when you want to draw these streams you create a vertex buffer for each one and set them set all of them using SetStreamSource().

Then you can set your pixel/vertex shaders up making sure all the vertex declaration (which you can create from analysing the meshdata class and then cache) matches up with the pixel/vertex shaders. Set your constants and draw!

I''m working on a C# engine using dx9. If your interested msg me on msn (jon@voodooextreme.com).


Share this post

Link to post
Share on other sites
i''m sorry,
but i am using the Effect framework! you do not use SetVertexDeclaration! I have done that numerous times. It is not the same thing! I think you declare it inside the HLSL file but i do not know how.

Even if it would work with SetVertexDeclaration (which it don''t using the Effect framework), I can only access the sources using the ASM vertex language, not HLSL, I don''t know the syntax. I think you somehow put second stream into TEXCOORn variables for input.


Share this post

Link to post
Share on other sites
thanks for the input,
im very interested in how you set up the vertex declaration without using SetVertexDeclaration; that is, inside the HLSL file (or whatever u use in the Effect framework).


Share this post

Link to post
Share on other sites
Hi. Are you using DX8 or DX9?

In DX9 you dont have a vertex declaration inside the FX file, you just have a vertex type. For example, in my rain effect file I have the type:

struct VS_INPUT
float3 Pos : POSITION;
float age : TEXCOORD0;
float2 axes : TEXCOORD1;


that is the input to my shaders. The vertices could be from a single stream or from multiple streams, but the effect file assumes they are always mapped onto the same type. The vertex declaration is what actually maps stream elements onto elements of VS_INPUT. This doesnt reside within the effect file. They are seperated so that you can use the same effect file with different stream setups. So, you should still be calling SetVertexDeclaration in your source code. If you are doing that and the effect isnt working then you should check all your return codes and the debug output. Have you validated the technique you''re using within the effect? Is the technique successfully applied?

Just as an example, here is my vertex declaration for the rain shader.

D3DVERTEXELEMENT9 vertexDecl[] =


Share this post

Link to post
Share on other sites
thank you
i just assumed the SetVertexDeclaration was not needed, as I have done multiple vertex shaders (using effects) and never used SetVertexDeclaration (transparent moving water, lightning on terrain and so forth).

on to the VS_INPUT struct, becuase then that is the only thing that I don't know how it looks like using multiple streams. Do you just put if after ? i mean like this:

struct VS_INPUT
// stream 0
float4 position : POSITION;
float3 normal : NORMAL;
float4 color : COLOR;
// stream 1
float4 position2 : TEXTCOORD0
float3 normal2 : TEXTCOORD1
float4 color2 : TEXTCOORD2

is this allright then? assuming i send two vertexbuffers with the same type of content. do you use TEXTCOORD for everything on stream2 and above?

thank you so much seems im getting closer now.

(managed DX9)

[edited by - apanjocko on November 11, 2003 12:03:54 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!