Do I need "materials"?

I’m wondering about the traditional color materials, which define ambient, diffuse, and specular color for an object, and wondering why I really need them.

In the game engine I’m designing, everything will be done in shaders - it’ll be completely core profile compatible, but ideally will be backwards compatible for OpenGL 2. I can’t honestly think of any object that I would want to render that I wouldn’t just use textures or vertex colors for, and for specularity, I intend to make specular (gloss) maps for textured objects (perhaps a uniform for when a spec map isn’t present?). Everything else that materials do is basically the same as what light does, correct?

So long story short, can I get away with simply not having materials for my meshes?

You are right on the cusp of breaking away from fixed-function thinking and properly entering the world of modern graphics programming.

Your lighting equation defines what surface characteristics matter. These surface characteristics are generally called “material parameters”. The lighting equation itself neither knows nor cares whether these characteristics come from textures, uniforms, or something else.

Therefore, the only question you need to answer is this: for each particular object, where does its material parameters come from? Does the diffuse color come from a uniform, or does it come from a texture? Or is it a combination of the two? Maybe it’s a combination of a per-vertex color and a texture value. Or does it come from combining a diffuse texture with a detail map? And so on; there are an infinite number of ways to get any particular material value.

Do not allow yourself to be bound by fixed-function thinking. This is programmable graphics; wield it as is best for your needs.

Usually, the color seen will be “Light + Diffuse texture + vertex color”, with normal/bump maps. Sometimes, a glow map will be used as well (basically just a diffuse texture blended over the object after lighting calculations are finished).

To be honest, I haven’t made any lighting equations yet, but I have a book and some other resources that can help with this. It’ll need to be per-fragment so I can use bump/normal/parallax mapping, and I’ll need a way to determine the 8 closest lights to the object (since the dungeon will more than likely have more than 7 torches, for example). If you’ve got any sites/books I could look at for making a flexible per-fragment lighting system, it would be really appreciated.

EDIT: Oh, and shadow mapping. That’s important too, but not a priority right now. I was looking into cascaded shadow maps for proper LOD, as well as nvidia’s “pecentage close soft shadows” shader.

I’m guessing I’d have to make a shadow map for each light, then when rendering an object I use the shadow map from each light that applies to the object, and use the shadow map to determine what fragments get lit by the diffuse and which don’t? I digress, I’m not ready to dive into shadow mapping yet.

When you get to that point and know more of your requirements, let us know and we’ll point you to some techniques. Cascaded Shadow Maps (aka Parallel-Split Shadow Maps) is a good one for shadow LOD, but plenty to think about getting them implemented well even without fancy shadow filtering. As far as PCSS, …expensive. When you get to that point, suggest you try built-in hardware PCF first, and then if you need it, check out EVSM (Exponential Variance Shadow Map filtering).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.