Cg interfaces.

Started by
-1 comments, last by bluntman 16 years, 9 months ago
I currently have a shader/material model that loads shaders from DLLs, and CgFx files, where each shader creates a seperate effect. I have been looking into Cg interface's and it seems like all shading could be done easily with a single composite shader that passes an input struct through a series of interfaces, for each type of effect to be applied. Then for each interface I implement a version which applies the effect (light mapping, texture, normal map, displacement map, etc etc), and a version that just passes straight through. Then all effects can be created using a single CgFx program and binding either the pass through or the effect to each interface. I just have a few questions about this approach: Is the Cg compiler good enough to completely optimize out a pass through version of an interface? Has anyone implemented shaders like this and had good results? Am I missing something that will stop this approach from being able to handle all types of effects? Is there any reason why this approach would be less efficient than using a different shader for each effect? Thanks!

This topic is closed to new replies.

Advertisement