Timeline for Custom effects on Model in XNA
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Aug 16, 2022 at 14:40 | history | suggested | Glorfindel | CC BY-SA 4.0 |
broken link fixed, cf. https://meta.stackoverflow.com/a/406565/4751173
|
Aug 14, 2022 at 8:06 | review | Suggested edits | |||
S Aug 16, 2022 at 14:40 | |||||
Feb 1, 2016 at 22:57 | comment | added | Arek |
Also good to know: the default effect is a BasicEffect . You can cast part.Effect to it and get some mesh part data from it - the two you probably need are DiffuseColor (which is object color actually) and the texture.
|
|
Mar 27, 2011 at 23:36 | vote | accept | Olhovsky | ||
Mar 27, 2011 at 23:35 | comment | added | Olhovsky | Oh, nevermind, you're right, you CAN change the effect that way. Thanks! | |
Mar 27, 2011 at 23:30 | comment | added | Olhovsky |
Are you using XNA 4? part.Effect = newEffect; doesn't work because part.Effect has no setter.
|
|
Mar 27, 2011 at 16:05 | comment | added | Phil Dunstan |
I tried the first option and you can modify the effect at run-time using code like foreach (var mesh in model.Meshes) { foreach (var part in mesh.MeshParts) { part.Effect = newEffect; } } As for the second approach, doesn't the ability to change the technique at run-time give you the same functionality as changing the effect if you write a single effect that exposes the original multiple effects as separate techniques?
|
|
Mar 26, 2011 at 0:38 | comment | added | Olhovsky | "The first option is purely a run-time option: iterate over all of the model.MeshParts and directly modify the ModelMeshPart.Effect property to the new effect. I haven't tried this but I would expect it to work." Actually he's doing that at compile time (in a ContentProcessor) and you can't do that at run-time as far as I know. I think what you're trying to say is that I can assign an effect to the model and then just pick whatever technique I want in that effect at run-time. That's true but doesn't answer the question of: how do I use different effects on the same model at run-time? | |
Mar 25, 2011 at 18:57 | history | answered | Phil Dunstan | CC BY-SA 2.5 |