Vertex declaration vs. D3D fixed pipeline
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
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
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
Does this mean that Fixed Function Pipeline is not activated while rendering in effect loop, even if shaders are not used inside effect?
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.
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.
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?
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?
Which brings us back to where we started: what vertex format should be set to let the fixed-function pipeline do its job?
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
- 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
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?..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement