Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When specifying the material (ambient/diffuse/specular) for use in lighting calculations, what level of detail is the material specified at? Per vertex, mesh, bone?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Generally, in a stateful graphics API, a material's settings will apply to anything rendered after the material state is set to the API. Whether or not the effect of that material will be per-vertex or per-pixel depends on the actual vertex and fragment shading programs that execute for the rendering of each individual primitive.

If you're using the materials built in to fixed function D3D9 pipeline, then the resulting object color is vertex-oriented, but the material's impact will be apparent for every object you render until you change the material.

Writing your own material system can allow you to embed material data into the vertex attributes, if you so choose (either directly into the vertex stream or indirectly via texture lookups) and thus have finer control over the material properties of an object without having to render that object in multiple draw batches just to swap out material data.

Materials rarely apply to bones in any significant fashion (although that might make for an interested system to write: assigning materials to bones, blending material effects using the vertex weights).

share|improve this answer
    
I'm writing my own system with shaders, not using fixed-function or anything like that. –  DeadMG Feb 11 '11 at 17:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.