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?


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).

  • \$\begingroup\$ I'm writing my own system with shaders, not using fixed-function or anything like that. \$\endgroup\$ – DeadMG Feb 11 '11 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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