Jump to content
  • Advertisement
Sign in to follow this  
digital_phantom

D3D8 Materials Not Working

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

I'm trying to enable materials in Direct3D8 for my textures, but it won't do anything. I've read somewhere that lighting must be enabled to use materials. Is this true? I don't want to use lighting in my application because it's a object editor, and I only want to use materials, so is there anyway to do this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Materials define how a surface is influenced by lighting, in terms of ambient, diffuse, specular and emissive components. Without lighting, materials are quite useless. What do you want to do? If you are using only ambient lighting, then the ambient component is for you.

Greetz,

Illco

Share this post


Link to post
Share on other sites
A material is set directly to the DX Device, and yes that book was correct. This is not a hinderance though, since ambient lighting is ample enough for materials to work properly. You really notice them though when you set a point or spot light.

Since a material is done with Ambience, Specular, Diffuse, and Emissive, these parms behave based on the light( s ) set in the scene.

Don't forget to call "device.SetMaterial(material);
to make it work properly.

Since this is an object editor, you can simply set an ambient light using this call in a renderstate, and all materials applied will work.

Device->SetRenderState(D3DRS_AMBIENT, 0xffffffff); (for a white light)

Share this post


Link to post
Share on other sites
Most 3d modeling programs use a "default light" if the user hasn't defined any. The said light is usually directional, and more often than not fixed in direction to shine from top-left to bottom-right, z to the screen in camera space.

A background light is generally also useful in determining the silhouette of the model. You could define it by reversing the first light's direction, as 3DS Max or Maya does.

Share this post


Link to post
Share on other sites
Well what I want to do is I don't want to use lights in each room, so I want to use a material for a room (set of vertices) to adjust the britness that way, way pretty much a unrealistic cheating way.

Share this post


Link to post
Share on other sites
Then you can use a single and global ambient light by setting the corresponding redner state, like RhoneRanger explained. The color at each point can be determined in two ways: a color component stored at each vertex or a material that is supplied to the device. Note that only the ambient component will be effective. If you just want basic flat colors, I'd suggest you set up materials like green, red, blue, yellow and so on. If you use per-vertex color components, you have to watch out for consistency -- if not consistent the colors will interpolate between vertices and you will get colors fading from one to another in between.

Greetz,

Illco

[Edited by - Illco on April 27, 2005 8:02:08 AM]

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!