Advertisement Jump to content
Sign in to follow this  

Shader system design

This topic is 4895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi We are currently designing our new game engine (not a high end one :) ), and trying to implement some fancy shaders. Now the plan is to edit almost as much as we can, onfly in the game. The idea is to edit the shaders inside the game. But it requires some extra functionality, to be able to set vertex attributes (for example inverse tanget matrix) and uniform variables onfly. To accomplish this, we want define a base class. And for every variable settings, calculating the buffer values if necessary and setting the vertex attributes, setting the uniform variables, etc... we are derivating a class. When rendering an object with a shader, we would call 1-5 derived class throu the base class virtual functions. What do you think about this approach? Will it result an extremly slow rendering phase? We are planning to use similar approach to achive morph, matrix, and uv animations. Is it that a good approach or is there a better way to do this? Peter Balogh

Share this post

Link to post
Share on other sites
in other words you led the virtual functions of the shader set the render states and render the mesh after setting the states

if you want to modify the game on the fly I would do it on a slightly different way
with your approach you define which variables and so on can be altered from outside the engine

In my engine I handle shaders so that I provide a basic interface of what can be done outside in shader script file

and in the script file I handle the order of state changes this might sound a little bit slow but most of the statechanges can be put into display lists to eas things up :) and display lists can be encapsulated into display list hierarchies

I also put vertex and pixel shader programs into the shader scripts

basically I plan that you can customize the rendering pipeline from outside the engine to keep it modable from outside

but i will also add some predefined render paths to avoid redundancy when customizing shaders
the flexibility of shader modified pipelines will be implemented near the end of the project since most of the rendering can be done with predefine render paths and spending a lot of time for special purpose implementation is a wast of time as long as the project isn t finished

so my advice keep it simple and get something going but take care that it is extentable

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!