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 Answer 1

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\$
4
  • \$\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
    Commented Oct 17, 2017 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
    Commented Oct 17, 2017 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
    Commented Oct 17, 2017 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
    Commented Oct 17, 2017 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .