Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Stopped paying attention changed nothing then they worked... Odd but not the point.

My Question is this How do i pass 2 positions and 2 normals to my Vertex Shader in an effect,im trying to Create a tweening EFFECT.(just to start)

lets say i have my vertex data in streams 0 and 1, and for this example they are PositionNormalColor, and i want to pass 2 of each Variable (position,normal and color) (one from each stream) to my effect. How do i do it?

VertexDecleration = New vertexDeclaration(device,new vertexelements(){new vertexelement(0,0,Float3,Position,0),new vertexelement(1,0,float3,Position,0),........?

then in my effect

void VS(in float3 Pos1 : POSITION,

in float3 Pos2 : POSITION,........

or am i way off track here?

Posted

I solved in this way:

I used a format like this

position

normal

binormal (the second normal)

tangent

textureCoordinate

memory access and it works.

But I remember that is possible to pass two vertexbuffer to device.setStream n

and declare position0 and position1 for the two vertex position (idem for normals).

The first is sure (I used it in my 3DEngine), the second it should work but I've tried it one time in directX8

Posted
I solved in this way:

I used a format like this

position

normal

binormal (the second normal)

tangent

textureCoordinate

memory access and it works.

But I remember that is possible to pass two vertexbuffer to device.setStream n

and declare position0 and position1 for the two vertex position (idem for normals).

The first is sure (I used it in my 3DEngine), the second it should work but I've tried it one time in directX8

Where would i declare POSITION0,Position1? the vertex declaration or in the Effect file? The first option is nice but not possible as i want to use this for mesh's where i cant controll the vertex format. I know this is covered in the dolphinVS example but the vertexShader there is allready compiled (i think) and i cant understand it at all.

Posted

Well Darn

 

You must declare in effect file (vertex shader).

I can't help anymore because this second way it's so difficult that I

didn't spend any time to study it

However i must say thank you once again as without your help i wouldnt even be this close, However i am asking if theres anyone here who does know this "second" way of doing it well enough to give me an example.

Posted

Not to doubt RobyDx

 

However i must say thank you once again as without your help i wouldnt even be this close' date=' However i am asking if theres anyone here who does know this "second" way of doing it well enough to give me an example.[/quote']

But in the vertex Declaration, you can set the stream of vertex elements,... so might my elements:

new vertexelement(){new vertexelement(0,0,float3,default,position,0),new vertexelement(1,0,float3,defaule,position,0).......} Could this be on the right track? I assume there is something more that must be done in the vertex shader (effect file) but i have no idea what that would be, so please help if you can, im looking into it myself but if i think i need help even finding the right help/tutorials/examples..... Thanks for all the help youve given me over the last year, im quite impressed with this forums members..

Posted (edited)

I haven't done vertex tweening with multiple streams, but have other things working with multiple streams. So I'll just tell you the general procedure of moving things to multiple streams.

First make it work with one stream as RobyDx said. Then all you have to do is change the stream index in vertex declaration for the appropriate vertex elements and modify offsets to reflect real offset in the corresponding vertex buffer. Then just set stream source to each of the vertex buffers and it should work.

Edited by Kavan
Posted
I haven't done vertex tweening with multiple streams, but have other things working with multiple streams. So I'll just tell you the general procedure of moving things to multiple streams.

First make it work with one stream as RobyDx said. Then all you have to do is change the stream index in vertex declaration for the appropriate vertex elements and modify offsets to reflect real offset in the corresponding vertex buffer. Then just set stream source to each of the vertex buffers and it should work.

So something like

VertDec = New VertexDeclaration(Device,New VertexElements(){new vertexelement(0,0,float3,default,position,0),new vertexelement(1,0,float3,default,posotion,0),......} question with this is how does it which is position0,position1, just goes by stream number?

Posted

You can't have two elements with same usage and usage index combination. I guess you have to use position, normal, binormal (the second normal), tangent as RobyDx suggested. As I said I haven't done tweening myself. Perhaps it'll work if you just use position for both but with different usage index (0 and 1). Of course you still need correct stream index and offset.

 

Hope this makes sense.

Posted

It all makes sence now,...

 

You can't have two elements with same usage and usage index combination. I guess you have to use position, normal, binormal (the second normal), tangent as RobyDx suggested. As I said I haven't done tweening myself. Perhaps it'll work if you just use position for both but with different usage index (0 and 1). Of course you still need correct stream index and offset.

 

Hope this makes sense.

THanks very much so as far as i can gather (im trying to test it write now but my HLSL isnt very good so it may be a while, however as far as i can gather, VE = new vertexelements(){new vertexelement(0,0,float3,default,position,0),new vertexelement(1,0,float3,default,position,1),new vertexelement(0,12,float3,default,Normal,0),new vertexelement(1,12,float3,default,normal,1)......} should be what i need passing Position0,normal0 from the first Keyframe (stream0) and position1,normal1 from the second keyframe (stream1) thanks for all your help.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...