Archived

This topic is now archived and is closed to further replies.

Materials and texturing?

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

well.. how to manage them in a easy way?! at the moment I have a script that says how the material is, Ambient,Diffuse,Specular,Shininess and a texture. that''s all my script has at the moment becouse I don''t know how to get any futher yet. I have some kind of shader system that finds a shader for the material to render and then only that shader knows how to render that type of material.. but I don''t really know how to define what shader goes with what material?! how to classify them so that I don''t have to write like one shader for each material.. I want something like this FindShaderForMaterial( cMaterial *mat ) { for ( s=shader in list of shaders ) { if( s->CanRender( mat ) ) { mat->Shader = s; } } } but then.. what if I have a material with a nice texture and no transparency then that shader can be rendered with lets say shader A.. but then if I have a Material with a texture and transparencey then I have to write a new shader B that supports Texture And transparency.. and if I have a Material with no texture but transparency then I need a shader C that can render materials without texture but with transparency what if I have one Shader that can enable transparency then I Shader A can call that shader when it has an material that needs transparency.. and so can the NoTexturue shader do this way I only need to code one transparency shader and one Texture shader and one NoTexture shader.. don''t really know how to achive that though..

Share this post


Link to post
Share on other sites
Looks like at the moment, the best solution would simply be to ditch the shader idea and simply set the parameters directly based upon what you have specified in the script. This way you don''t need to worry about multiple shaders, duplicating the same effects.

Of course if you wanted to keep the shader structure(i.e. your engine relies on it too much already) then you need to make a system whereby you can set parameters for your shader. E.g. transparency may be common enough to all your basic opaque effects that you could set this as a parameter in each shader, and simply enable blending via a conditional if the parameter is set.

Hope that helps
James

Share this post


Link to post
Share on other sites