# What is a good way of handling shaders?

I'm currently reading this book and are at the chapter about the rendering subsystem of a game engine.

Now, the book suggests that a material is a structure that provides information on how to shade a mesh. So the material contains visual properties and also what information to send to the shader prior to rendering.

My question is: What is a good tructure/syntax of such a material model?

My current ideas are that the material holds info such as specularity, diffuse colors, textures and so on. The (to me) tricky part comes when a shader needs multiple render passes.

A simple material could be something a long the lines of:

Transform info:
ModelMatrix : get_from_model
ViewMAtrix: get_from_camera
ProjectionMatrix: get_from_camera

Textures:
diffuse: get_from_file
normalmap: get_from_file
glossmap: get_from_file

Lighting:
direction: get_from_somewhere
.
.
.


But for instance, if I want to render the reflection of a mirror, need a good way to tell the engine that I want to render the scene with the camera flipped in the mirror plane, and perhaps with a lower LOD. Is there a well know good way to encode this in the interface between user-data and the shader program?

Also, in general, are there well proven methods for mapping in-game data to shaders without too much manual instruction on where to find the data?

Thanks in advance : )

• 3D Game Engine Design by David Eberly is what I truly TRULY recommend. A lot of game design books sell false hope and dreams and I hate them for it. I looked at your one in a library once - it gave me that sense. I really recommend the first book - that truly is saying something as there are only 5 non maths books I actually vouch for. Sep 21 '15 at 21:00
• Due to lack of feedback, good faith and any response to my partial answer, I'm deleting not fixing it. Good luck! (Genuinely) Sep 22 '15 at 9:29
• Sorry for the lacking feedback. It's not that I don't appreciate it at all! Though, I was hoping for a less sourcecode-intensive response. More of an architecture angled view on what classes are responsible for setting which variables and how to streamline the process of rendering in an extendable fashion that allows these multipass renders and some degree arbitrary configuration of shader programs. Sep 22 '15 at 10:28