Sign in to follow this  

An easy shader based architecture

This topic is 3378 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

About a shaders based architecture, I'm thinking of using effects and materials and I'll present some current idea, in the hope that others will post their thoughts or details about how they do this. I have portability and simplicity as main targets, then speed. Sorry for the long post. Effects are to be handled by a manager in the render module with reference count and so, and materials will say for each mesh/model what effect to use and what parameters to customize for it. The common global parameters, like View or World matrices, the effect will get them from render module, when it's used. Probably this is the most common way to use effects, unless you want to go for an effect for each mesh, which would result in a lot of effects changes, and that might slow down the frame rate. Anyway, I'd like to bring in discussion a few aspects of implementing the link between properties in the material and the effect they refer to. 1. The material text file will only list values for those parameters (given by name) that it wants to customize in the effect. Usually that's the diffuse texture, and eventually the normal map texture. But it can also include a diffuse color, or some other custom parameters that the effect would support. This is to avoid listing all parameters of the effect, in each material file. For a generic material, that would be quite redundant. 2. Now, at run time, each instance of a mesh/model has it's own instance of the material requested by the model when loaded, keeping the parameters values it customize. In fact it can keep all of them, the rest with default values (to be decided). The user can change these values for each particular instance. For example if you want to color in red one specific instance of a model, or if you want to change a texture, or if you have an animation affecting one of these parameters. 3. When painted, the material will set these custom parameters to the effect and the effect will check if the rest of the parameters are having default values. To avoid having a previous material changing a parameter that the current material expects as default. So the effect keeps the list with exposed parameters, their default values, internal handlers, and other tricks for change detection (like current set value, time of last change, etc). QUESION: How do you manage changes of effect's parameters? Do you use a D3DX effect pool for global parameters, or it can be coded with the same efficiency. In fact these have to go into the effect's registers at draw time, one way or another. I don't know if CG effects have such pool feature, but I don't want to depend too much on DX. 4. Another issue I want to mention are the effect parameters semantics (or their names), like these for World, View, Proj, ViewProj, etc. I see there isn't a common naming convention for them and the DX SAS doesn't appeal to me either. I have no problem having my own notation, but I was wondering how do you do it? QUESTION: Do you choose to use these notations from FXComposer or RenderMonkey, and create or import shaders from the editor in cause? Or do you stick with whatever 3DS Max shader pluggins you have, and whatever they name they use? Do you use the parameters names or do you check for their semantics? 5. The example shaders in FXComposer look too complex in syntax to use in a simple engine, where you need something that you can write in notepad. They have a lot of defines and stuff. QUESTION: Does anyone builds his engine to use such shaders in that format directly, or you just cut and paste the right pieces of code, to keep it simple and clear. Thanks!

Share this post


Link to post
Share on other sites

This topic is 3378 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this