Is it possible to use different effects with the same model using the built-in renderer?
I have a switch model that I want to render in different color textures based on its state.
Thanks.
this would a simple process using custom effects (.FX)
Hi khayman,
To make these SceneObject effects unique you can loop through and clone them. As an example:
SceneObject obj = new SceneObject(model);foreach(RenderableMesh mesh in obj.RenderableMeshes){ mesh.Effect = mesh.Effect.Clone(); // you can do something to the unique effect here or later in code, and it will no longer affect any other object... // for instance change a player's diffuse texture to the team color texture (red, blue, ...)...}
Please note this affects batching. The effect(s) are no longer shared, so the object will not be batched with other objects, which can reduce performance if there are many objects with unique effects.
If you are creating groups of effects that are the same, for instance team materials (red, blue, ...), it's best to create one effect per group and assigned it to all objects in the group. This will batch all objects in the group and help optimize performance.
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos