Materials and texturing?

Started by
0 comments, last by McZ 20 years, 4 months ago
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..
Advertisement
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

This topic is closed to new replies.

Advertisement