The Material design has some problems to improve the performance

Software: Away3D 4.x

bxc, Newbie
Posted: 24 March 2014 12:45 PM   Total Posts: 19

If a lot of meshes use the same material,they will be rendered under the same render state to improve the performance.I mean that activatePass once,then renderpass one renderable after another.
However,I found at least 2 problem here.
1.For shadow mapper.although the depth map pass is almost always under the same state for all meshes,now they have to change the render state again and again because they belong to different materials.
2.For light picker.Even the same object,like 2 basketball,because they are in diffent place where there are diffent lighting,I have to give 2 materials not 1.
So if you have many objects with the same material,if they are movable,and you have diffent lights in different places,you have to give them each one by one material instance,which means they have to change render state when rendering.I mean maybe just the light color is diffent,the render state maybe do not need to change,but this design based on material makes it hard to control.

   

bxc, Newbie
Posted: 29 March 2014 03:18 AM   Total Posts: 19   [ # 1 ]

I have a simple solution.I think it will save lots of memory and time.
1.I define a MaterialSetting.Stuff like diffuseColor is included there.
2.I give the materialSetting to IMaterialOwner who’s extended by IRenderable
3.So when drawRenderable,setRenderState will visit the renderable’s materialSetting and reset stuff like diffuseColor which is diffent is current material.
4.I will use Material as type of material.More rendables will share the same
Material while have their own materialsetting.The material will have default setting,usually the texture.However it may be replaced when drawRenderable
5.I define some type of light pickers which will dynamic collect lights when drawRenderable.They have diffent programes to do the collecting.
6.Another Material will only be necessary when
  a.AGAL programe is different.
  b.render state is different.I mean stuff like blend mode,depth test.
  c.animateset is diffent.Maybe this can be considered but a little complex.
  d.lightpicker is diffent.
  e.Lots of renderables share the same materialsetting and one type of material,so their material is not allowed to be shared.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X