Jump to content
  • Advertisement
Sign in to follow this  
YannikLambert

Render loop and effect instance

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

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....

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!