• Advertisement
Sign in to follow this  

dynamicly choose effect shaders..

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

I have been fighting with a way to dynamicly create a render path for my mesh depending on the hardware almost like the Material/Shader-thread stuff... but with the difference that I have small effect shaders that does a small part of the entire material, for exampel Ambient lighting is only one part of the material and texturing is another part, so I create a set of EffectShaders that will enable the state of the mesh and then the engine will draw it having this set of effects to choose from: Lighting - just enable the closest lights (how many is dependent on the shader) materialcolor - just set the material color properties DiffuseTexturing - bind the diffuse textures Depthmap - activate the depthmap testing Bumpmap - activate bumpmapping with the above list of effects (there are probibly more) I can create a list of shaders that can set the state that the mesh needs, for exampel if I have a lit diffuse textured mesh that cast/recive shadows it will resolve the lighting,diffusetexture and depthmap effects and the shaders that can set theese states it can be one that does it all or 3 different. for exampel bumpmapping is dependent on the lighting so then an effectshader that does bumpmapping can also set the lighting of that object in one pass I do like this: for( oes=old effect shaders used for previous mesh ) { // disable all shaders that isn't needed anymore if( !(oes->EffectID() & mesh->pass[THIS_PASS]->EffectID) ) oes->Disable(); } for( es=effect shader for this mesh ) { // this will enable "global" stuff that doesn't change between 2 objects // if they use the same shader if( !es->IsEnabled() ) es->Enable(); // here it will enable "local" stuff, like bind texture set color // depending on the EffectShader es->Process( mesh->pass[THIS_PASS] ); } // just draw g_pRenderCore->Draw( mesh->VertexBuffer ); the effects can be split up alot more, so that you can have different shaders for diffuse lighting and specular lighting if you want to. the problem I have got myself into is that I can't figure out a good way to create a multipass setup with this aproach, I can't find a good way to determin if a shader should be done in this pass or that pass, and if that shader maybe need some other passes to change? for exampel shadowmapping needs one ambient pass and then a none-ambient pass with depthmap checking on so in that case there is 2 passes for that object, but if it didn't need shadowing it can be done in one pass.

Share this post


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

  • Advertisement