Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to setup the vertex declaration for this vertex format?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 lucky6969b   Members   -  Reputation: 624

Like
0Likes
Like

Posted 19 November 2012 - 02:56 AM

// input from application for Vertex Shader
struct VS_InputStruct {
half4 position  : POSITION;
half2 texCoord  : TEXCOORD0;
half2 texCoord2  : TEXCOORD1;
half2 texCoord3  : TEXCOORD2;
float3 vertcol  : TEXCOORD3;
float vertalpha  : TEXCOORD4;
half3 tangent  : TANGENT;
half3 binormal  : BINORMAL;
half3 normal  : NORMAL;
};

Any small code snippet is enough.
One small additional question is when I pass "vertcol"s not the material colors for xoliulshader.fx, would the scene look exactly the same as 3dsmax?
Thank you

Jack

Edited by lucky6969b, 19 November 2012 - 02:58 AM.


Sponsor:

#2 Steve_Segreto   Crossbones+   -  Reputation: 1540

Like
0Likes
Like

Posted 19 November 2012 - 01:38 PM

Is your question focused more on how to use D3DVERTEXELEMENT9 and CreateVertexDeclaration() or is it focused more on how to describe the "half" data types in a vertex declaration?

#3 lucky6969b   Members   -  Reputation: 624

Like
0Likes
Like

Posted 20 November 2012 - 12:36 AM

Is your question focused more on how to use D3DVERTEXELEMENT9 and CreateVertexDeclaration() or is it focused more on how to describe the "half" data types in a vertex declaration?


Focus on CreateVertexDeclaration().
Thanks Steve, you have been helping us a lot
Jack

#4 Hodgman   Moderators   -  Reputation: 31112

Like
0Likes
Like

Posted 20 November 2012 - 01:01 AM

You need to make an array of D3DVERTEXELEMENT9's, one element for each item in your vertex input structure, plus one extra for the "end" marker.
D3DVERTEXELEMENT9 endMarker = D3DDECL_END();
D3DVERTEXELEMENT9 elements[10];
//todo - fill in elements[0] - elements[8]
elements[9] = endMarker;
IDirect3DVertexDeclaration9* result = 0;
HRESULT hr = device->CreateVertexDeclaration(elements, &result);
//todo - check hr for error/success

For each element, you set the Usage and UsageIndex to match the HLSL semantic, e.g.
//element for "half2 texCoord3 : TEXCOORD2;"
D3DVERTEXELEMENT9 element;
element.Usage = D3DDECLUSAGE_TEXCOORD;
element.UsageIndex = 2;
However, the rest of the settings aren't based on your HLSL code; these settings are based on your model data format (i.e. how your vertex data is laid out):
element.Method = D3DDECLMETHOD_DEFAULT; //pretty much always use default method...
element.Stream = ...;
element.Offset = ...;
element.Type = ...;
To fill these out, you'll have to tell us how your vertex data is stored in memory.

One small additional question is when I pass "vertcol"s not the material colors for xoliulshader.fx, would the scene look exactly the same as 3dsmax?

You've been asking lots of questions about this xoliulshader thing, but you've got to assume that we don't know what xoliulshader is... Can you give us some context?

Edited by Hodgman, 20 November 2012 - 01:08 AM.


#5 lucky6969b   Members   -  Reputation: 624

Like
0Likes
Like

Posted 20 November 2012 - 01:41 AM

Hello, xolilshader is a viewport shader. It is basically an effect (fx) file in text format, I want to use it in my project so my game looks pretty.
As far as I know xolilshader gives some effect similar to 3ds max viewport in your game viewport (or exactly)
So these parameters are copied from the fx file, I want to upload these parameters from my C++ program to this fx file.
That's why I am asking the vertex declaration stuff.
http://www.laurensco.../viewportshader

If you have noticed something about it (if you also downloaded it), you'll find that there are no material colors for this shader. Only vertex colors,
I am worried about this, because I don't use textures for the time being.

A third question, is this declaration an absolute necessity to be done? If I leave that out, will my application still run normally?

Forth Question, Do I have to specify the vertcol in my .x file? because without this info, how does my application know the color of the vertex? :S

Thanks Hodgman, you have been great help too
Jack

Edited by lucky6969b, 20 November 2012 - 03:01 AM.


#6 Steve_Segreto   Crossbones+   -  Reputation: 1540

Like
0Likes
Like

Posted 20 November 2012 - 04:15 PM

Hmmm, I had a look at the xoliulshader link you post. I think calling it a "viewport" shader is strange, it makes more sense for me to think of it as a scene shader. Anyway it looks like its basically a super shader for 3DS Max/Maya and probably RenderMonkey too. It will require your art assets and your rendering pipeline to work in very specific ways to achieve the same visual effects you see in 3DStudio Max however.

I wasn't able to download it, I didn't want to install WinRAR on my office computer. I don't understand your concern about the lack of a material parameter for the shader. Vertex colors can supply the same behavior and produce better results. You don't need textures to see the effects of either a material color or a vertex color. The material color is going to be the same for all pixels of a primitive, whereas the vertex colors could allow better fading between different colors. However, you will need to supply accurate vertex color data in your vertex stream for that effect. If you want to imitate a material color, simply set the vertex color for every vertex to the same value as the material color.

You need the declaration, either in the form of a VertexDeclaration or an FVF because otherwise the framework cannot map your input stream source to the vertex shader in the FX file correctly.

Yes you should specify the vertcol in your .X file (if that is how you are filling in the vertex buffer). As I mention above, you could just use the same value over and over again to emulate a material color.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS