Finnally got effects Working

rifter1818

Well-known member
Joined
Sep 11, 2003
Messages
255
Location
A cold dark place
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?
 
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 Ive tried it one time in directX8
 
RobyDx said:
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 Ive 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 meshs 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.
 
You must declare in effect file (vertex shader).
I cant help anymore because this second way its so difficult that I
didnt spend any time to study it
 
Well Darn

RobyDx said:
You must declare in effect file (vertex shader).
I cant help anymore because this second way its so difficult that I
didnt 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.
 
Not to doubt RobyDx

rifter1818 said:
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.
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..
 
I havent done vertex tweening with multiple streams, but have other things working with multiple streams. So Ill 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.
 
Last edited by a moderator:
Kavan said:
I havent done vertex tweening with multiple streams, but have other things working with multiple streams. So Ill 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?
 
You cant 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 havent done tweening myself. Perhaps itll 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.
 
It all makes sence now,...

Kavan said:
You cant 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 havent done tweening myself. Perhaps itll 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.
 
Back
Top