Jump to content
  • Advertisement
Sign in to follow this  
tokaplan

Vertex declaration vs. D3D fixed pipeline

This topic is 4841 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

After using arbitary vertex declaration with shaders, I'm trying to switch back to the fixed pipeline. I turn on the light, adjust the material, but leave previously set vertex declaration intact. But for some reason, the diffuse lighting does not work (ambient and specular are OK). Do I need to set any particular vertex declaration in order for the fixed pipeline to work properly? And if I do, how must it look like? Thank you

Share this post


Link to post
Share on other sites
Advertisement
Hi there tokaplan,
How are you doing?

[The Problem]
Shaders...

[The Solution]
I am going to try and be more constructive here so bare with me.

The outline is, You jump from using the Fixed Function Pipeline to Shaders with one of the following methods.

Invoking this means that you are enabling shaders for the device
IDirect3DDevice9::SetVertexShader()

Or...

Rendering using Effects.
ID3DXEffect::Begin
ID3DXEffect::BeginPass
Then rendering primitives/meshes etc...
ID3DXEffect::EndPass
ID3DXEffect::End

Now,
The Vertex Declaration:
"A vertex declaration defines the vertex buffer layout and programs the tessellation engine."

This just essentially means that you are declaring what the structure of each vertex has. You can either use the Flexible Vertex Format Constants such as
D3DFVF_XYZ, D3DFVF_DIFFUSE, etc...

[What to look for]
Make sure you aren't still rendering in the effect loops.
Make sure that if you are using Vertex Shaders that your device is not currently set to use one.

I hope this helps.
Take care, keep cool

Share this post


Link to post
Share on other sites
Does this mean that Fixed Function Pipeline is not activated while rendering in effect loop, even if shaders are not used inside effect?

Share this post


Link to post
Share on other sites
Hi there again Tokaplan,
Whenever you are rendering inside an effect, you are rendering using the effect (shaders).

So yes, even if you don't want to render using the shader, you are.

Share this post


Link to post
Share on other sites
Maybe it's just the way you put it, but I want to make it as clear as possible.
Let's say we have an effect:

technique TSimpleTechnique
{
pass P0
{
Lighting = true;

VertexShader = NULL;
PixelShader = NULL;
}
}

We just set the lighting state and do not use any shaders. I figure that pipeline needs some algorithm to process vertices - whether fixed function or shader. We haven't specified any shader here, on the contrary, we set it to NULL. So what will D3D do?

Share this post


Link to post
Share on other sites
Which brings us back to where we started: what vertex format should be set to let the fixed-function pipeline do its job?

Share this post


Link to post
Share on other sites
It depends on what you want do:

- Show a mesh other than all vertices at the origin. This will require a position for each vertex.
- Show a lit mesh. This will require normals.
- Show a textured mesh. This will require texture coordinates.

Etc. So the almost bare minimum is positions. Greetz,

Illco

Share this post


Link to post
Share on other sites
Actually, my problem is that I can't make my mesh to be lit properly. Position and texture coords work all right, and the normals too, as far as I can see, because the vertices that must be lit are lit, but the diffuse color is very strange - the mesh is lit with all colors of a rainbow, while diffuse color for each vertex is set to red. Maybe I shouldn't set the diffuse component for a vertex and use SetMaterial instead?..

Share this post


Link to post
Share on other sites
I solved this. It was nothing. I just got in mind that vertex must have a diffuse component in its declaration. But it's not so, fixed-function pipeline uses material diffuse value, set by SetMaterial.
Thanks for your patience with me ))

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!