java - How many shaders should i use? -
i've written own 3d game engine in java want rewrite optimization.
my engine looks this:
there abstract superclass called rendersystem. code :
public abstract class rendersystem<t> { public abstract void addelement(t element); public abstract void enablesystem(); public abstract void disablesystem(); protected abstract void cleanup(); }
every rendersystem extends "rendersystem". every different material there render system , therefore shader. i've created enum stores parts of material enabled (bump_map, displacement_map etc.)
it looks this: (i missed out getter , setter stuff) code :
public enum materialtype{ color_mat (1,false,false,false,false,masterrenderer.entity_system,null); private materialtype(int index, boolean use_bump_map, boolean use_displacement_map, boolean use_normal_map, boolean use_specular_map, rendersystem<?> default_system, rendersystem<?> instanced_system) { this.index = index; this.use_bump_map = use_bump_map; this.use_displacement_map = use_displacement_map; this.use_normal_map = use_normal_map; this.use_specular_map = use_specular_map; this.default_system = default_system; this.instanced_system = instanced_system; } private final int index; private final boolean use_bump_map; private final boolean use_displacement_map; private final boolean use_normal_map; private final boolean use_specular_map; private final rendersystem<?> default_system; private final rendersystem<?> instanced_system; //...................
in example, stored 1 material in it, not use of maps except color_map (which enabled). furthermore, stores systems deals kinds of entities use material. code : masterrenderer.entity_system
this done else, add skydome material, particle material etc. straight forward question is, shaders need ?
shall write 1 shader every entity, (entities created using obj. file, no particles etc. included) or 1 shader normal rendering without bump_maps , stuff, , 1 shader material normal_map ? mean render every entity 1 shader, if not have of maps has calculate stuff.
furthermore want add bonesystem characters. guess that's should have own shader ? below list shaders create:
- entityshader (only colormap)
- entityshader (colormap , normalmap)
- entityshader (colormap , specularmap)
- entityshader (colormap, normalmap , specularmap)
- entityshader (colormap, bumpmap, displacementmap, normalmap, specularmap)
- charactershader (only colormap bones)
- skydomeshader (only colormap), renders sky
- particleshader (probably colormap instanced!!)
- terrainshader (probably own material stuff blending)
- shadowshader (takes entities , no other map, renders depth framebuffer)
- watershader (if bored , have nothing else do)
- and finally: instancedentityshader (only colormap instanced)
i might add postprocessing effects that's not safe yet.
i want know if structure okay , effective or should change anything?
also, how many shaders used in games?
Comments
Post a Comment