• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
lucky6969b

How to setup the vertex declaration for this vertex format?

5 posts in this topic

[code]
// 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;
};
[/code]

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
0

Share this post


Link to post
Share on other sites
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?
0

Share this post


Link to post
Share on other sites
[quote name='Steve_Segreto' timestamp='1353353884' post='5002417']
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?
[/quote]

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

Share this post


Link to post
Share on other sites
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.
[code]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[/code]

For each element, you set the Usage and UsageIndex to match the HLSL semantic, e.g.
[code]//element for "half2 texCoord3 : TEXCOORD2;"
D3DVERTEXELEMENT9 element;
element.Usage = D3DDECLUSAGE_TEXCOORD;
element.UsageIndex = 2;[/code]
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):
[code]element.Method = D3DDECLMETHOD_DEFAULT; //pretty much always use default method...
element.Stream = ...;
element.Offset = ...;
element.Type = ...;[/code]To fill these out, you'll have to tell us how your vertex data is stored in memory.

[quote name='lucky6969b' timestamp='1353315397' post='5002288']
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?
[/quote]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
0

Share this post


Link to post
Share on other sites
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.
[url="http://www.laurenscorijn.com/viewportshader"]http://www.laurensco.../viewportshader[/url]

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
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0