Deferred shading: material ID

Hi all,

When I read documents about deferred shading, it is said that we need to store in the g-buffer, the following data:

  • normal
  • position
  • color
  • material ID

What is it the material ID? A pointer to a material, I guess! How get a material ID? How get data of the material in a fragment shader from a material ID?

Thank you in advance.

Sorry for my english: it isn’t my mothertongue :p[/b]

Material ID can be whatever you would like.
Usually the material ID is a simple integer value that will be evaluated in the light shaders and the lighting equation used to calculate the illumination value of the fragment will depend on this value.
E.g.:
material ID = 1 => basic Blinn diffuse model
material ID = 2 => full Phong specular model
material ID = 3 => isotropic Ward model
material ID = 4 => anisotropic Ward model

Anyway, using a material ID is optional as if you would like to do all your lighting with the classing Phong model when you don’t need it at all.
I hope this helped.

usually you can get away with just using specular intensity and specular roughness/power maps instead of material id, it makes the shader system simpler