Jesse-V/iVoxely

Generate shaders on the fly

Jesse-V opened this issue · 1 comments

The C++ code supports creating RenderableObjects which a variable number of DataBuffers. However, since GLSL doesn't support the #include directive, much of the shader code is duplicated across multiple objects, violating a main programming principle. The C++ code should generate the appropriate shader for use by the RenderableObject. Perhaps each DataBuffer should have its own shader code that it utilizes. This would improve organization and flexibility, while avoiding duplicating GLSL code.

Shader code basically has three portions to it: fields, method declarations, and a call from the main method. A class could assemble these snippets together and create the shader on the fly.

One of the problems here is that blending the colors and the lights involves a lot of dependencies. One way to resolve this is to have an array of colors for the material, and an array of lights. Then just loop through these and blend them using weighted averages or something like that. Perhaps there could be up to 8 colors that define how the surface looks, and then up to 16 lights. Those values dynamically passed down as needed, or just defined as needed.