Hi,in XNA,
it seems it's better to clone effect (material = effect) instead of sharing an effect instance and having material setting continuously the different parameters.
Question 1: Can i clone effect to avoid setting parameters like textures etc everytime, and sharing the instance between meshparts, but when drawing the part setting only the world matrix..........or do you thing changing the world matrice it too costly too and if two parts do not use the same world matrice i should also clone the effect.....
So, it seems the defaut of the content pipeline processor, will share the same effect instance among meshpart that use the same material and world matrice when loading a model.
With this you can draw your model meshparts by material order to limit states change.....
do the content importer share same instance of the same effect among meshpart of different loaded models or do it only share the instance between parts of ONE model......
if it is the case do you thing it would be better if i separate loading model geometry and creating material instance (wood, blue eye, rock, white skin) and affecting the same materiel instance among all meshparts of all models composing my scene and then having a render loop looking like that:
foreach (material in allMaterials)
{
foreach (meshpart in allMeshpartFromAllModelsUsingThisMaterials)
{
material.World = ...;
Draw(meshpart)
}
}
This aproach is different than the standard xna where the render loop look like this:
foreach (model)
{
foreach (effect in model)
{
effect.World = ...;
}
foreach (meshpart in model)
{
Draw(meshpart)
}
}
Many thanks in advance for your advices....
Show differencesHistory of post edits
#1Arthegal
Posted 15 January 2012 - 06:08 AM
Hi,in XNA,
it seems it's better to clone effect (material = effect) instead of sharing an effect instance and having material setting continuously the different parameters.
Question 1: Can i clone effect to avoid setting parameters like textures etc everytime, and sharing the instance between meshparts, but when drawing the part setting only the world matrix..........or do you thing changing the world matrice it too costly too and if two parts do not use the same world matrice i should also clone the effect.....
So, it seems the defaut of the content pipeline processor, will share the same effect instance among meshpart that use the same material and world matrice when loading a model.
With this you can draw your model meshparts by material order to limit states change.....
do the content importer share same instance of the same effect among meshpart of different loaded models or do it only share the instance between parts of ONE model......
if it is the case do you thing it would be better if i separate loading model geometry and creating material instance (wood, blue eye, rock, white skin) and affecting the same materiel instance among all meshparts of all models composing my scene and then having a render loop looking like that:
foreach (material in allMaterials)
{
foreach (meshpart in allMeshpartFromAllModelsUsingThisMaterials)
{
material.World = ...;
Draw(meshpart)
}
}
This aproach is different than the standard xna where the render loop look like this:
foreach (model)
{
foreach (effect in model)
{
effect.World = ...;
}
foreach (meshpart in model)
{
Draw(meshpart)
}
}
Many thanks in advance for your advices....
it seems it's better to clone effect (material = effect) instead of sharing an effect instance and having material setting continuously the different parameters.
Question 1: Can i clone effect to avoid setting parameters like textures etc everytime, and sharing the instance between meshparts, but when drawing the part setting only the world matrix..........or do you thing changing the world matrice it too costly too and if two parts do not use the same world matrice i should also clone the effect.....
So, it seems the defaut of the content pipeline processor, will share the same effect instance among meshpart that use the same material and world matrice when loading a model.
With this you can draw your model meshparts by material order to limit states change.....
do the content importer share same instance of the same effect among meshpart of different loaded models or do it only share the instance between parts of ONE model......
if it is the case do you thing it would be better if i separate loading model geometry and creating material instance (wood, blue eye, rock, white skin) and affecting the same materiel instance among all meshparts of all models composing my scene and then having a render loop looking like that:
foreach (material in allMaterials)
{
foreach (meshpart in allMeshpartFromAllModelsUsingThisMaterials)
{
material.World = ...;
Draw(meshpart)
}
}
This aproach is different than the standard xna where the render loop look like this:
foreach (model)
{
foreach (effect in model)
{
effect.World = ...;
}
foreach (meshpart in model)
{
Draw(meshpart)
}
}
Many thanks in advance for your advices....