This topic is now archived and is closed to further replies.


Problem setting the material

Recommended Posts

Ok I''ve got my program to load .ms3d models nice and dandy, but when they are untextured they are NOT drawn with their material, it''s very baffling... My code for setting the material looks something like this:

SetMaterial(&material); //material is an already filled pointer

//drawing routines below

device->Present(NULL, NULL, NULL, NULL);

the material is pointer already loaded from the .ms3d model, and i''ve verified that this works, and even when i manually make an all red material (diffuse, ambient, and specular), it fails to show this on screen, still using the default white material. I checked that SetMaterial returns D3D_OK, but it still uses the default WHITE. For the love of me, I can''t figure out why it''s doing that. Any help would be appreciated.

Share this post

Link to post
Share on other sites
1. Materials don''t do anything on their own. They''re part of the D3D lighting engine. When lighting is enabled, for each light in the scene, the influence of that light on each vertex is calculated. This influence is then multiplied by the material.
If you''re not intending on using any lights, you still need lighting enabled, and you''d be best putting the colour in the AMBIENT part of the material and then setting the AMBIENT renderstate to 0xFFFFFF (1.0, 1.0, 1.0).

2. The settings you''ve set for the texture pipeline affect where colours come from before they''re applied to polygons. This allows you to perform various maths on a combination of textures, diffuse vertex colour, specular vertex colour, constant colour etc. These are set with SetTextureStageState().

I suggest you read the "Lights and Materials" section of the docs to see how materials and lights interact in the fixed function pipeline. Also the "Textures -> Texture Blending" section to see how the fixed function texture cascade works.

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites