Builtin "model" material doesn't apply world transform (DEF-2519) (SOLVED)

Hi there,

Just experimenting with placing 3D models in my scene. What I’m noticing is that the builtin “model” vertex program transforms by view and projection, but never applies a world matrix. This is analogous to the builtin “sprite” vertex program, except that sprites should already be defined in world space, so that makes sense. In the case of models however, shouldn’t the engine make the assumption that they need a world matrix applied to position them within the scene?

The way this manifests itself is that no matter where I position the game object that owns my model component, the mesh is rendered sitting at the origin. This seems like a bug to me, but maybe I’ve just made some mistaken assumptions.

A subsequent issue -

I cloned and modified the model shader so that it applies a worldview matrix instead of just a view matrix. Now, when the game runs, the mesh is correctly positioned in the scene. However, in the editor, the mesh is still displayed sitting at the origin. I guess my question is: The editor uses my actual material/shaders when it renders the scene doesn’t it? So at the very least, the editor and the game should show models in identical position/orientation, right?

Note: I’m using Editor2, so this could just be an oddity of the new editor that has yet to be sorted out. If that’s the case, I can report it as a github issue.

2 Likes

Hi! Yes this could indeed be an oddity of the new editor, we’ll discuss tomorrow!

1 Like

Hello again, I took the liberty of creating an issue for this: https://github.com/defold/editor2-issues/issues/521
Thanks!

1 Like

I ran into this bug today too.

It seems that the model component does not set the world transform matrix shader constant (positions must be multiplied on the CPU) so this is an engine bug as well.

Created an issue. DEF-2519

1 Like

Fixed in Defold 1.2.100

3 Likes