0
\$\begingroup\$

When I load a model in Monogame using ContentManager, the model contains effects on each mesh (mesh.Effects). This is confusing to me since models seem to be directly tied to their rendering, rather than existing as standalone 3D models. Further, this makes applying custom effects more difficult in code, since I have loop through each ModelMeshPart and assign effects. The comparison to 2D would be a Texture2D containing its own SpriteBatch settings, which wouldn't make sense. Why are models tied to effects, and how can I separate them?

\$\endgroup\$
1
\$\begingroup\$

I believe this is is mainly for greater flexibility with model's materials (over just textures) and is derived from the FBX standard which allows for effects in this manner.

Also, remember that effects tell the GPU how to render a specific piece of geometry, SpriteBatch is a tool for batching GPU calls.

That said, this is probably not a feature you want in your games (You'll probably want unified effects and effect batching), so you should probably write your own Draw calls

\$\endgroup\$
  • \$\begingroup\$ Thanks for the answer. I understand that effects are needed for drawing, but I'd like to write effect.Apply(), then mesh.Draw(), such that the model is logically separated from the effect used to draw that model. I don't know how that's possible without setting effects on ModelMeshPart. \$\endgroup\$ – Grimelios Oct 17 '17 at 6:40
  • \$\begingroup\$ If you want to not use the effects in a model mesh you will need to manually render the model mesh parts (vertex+index buffers), setting the effects yourself \$\endgroup\$ – CobaltHex Oct 17 '17 at 6:56
  • \$\begingroup\$ I'm still confused. I'm working on shadow mapping, meaning that I'll need to render the same models multiple times using different effects. It seems like this is a very common requirement for a game, yet effects seem baked into models. That's what confuses me, and I'm wondering if I'm missing something obvious. \$\endgroup\$ – Grimelios Oct 17 '17 at 7:58
  • \$\begingroup\$ I believe it was a design decision, but here is an example of shadow mapping and how they handle it (you may not want to do this): xbox.create.msdn.com/en-US/education/catalog/sample/… \$\endgroup\$ – CobaltHex Oct 17 '17 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.