defold / editor2-issues

DEPRECATED
44 stars 4 forks source link

Builtin “model” material doesn’t apply world transform #521

Closed erikangelin-king closed 7 years ago

erikangelin-king commented 7 years ago

http://forum.defold.com/t/builtin-model-material-doesnt-apply-world-transform/5445

ericsroy

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.

ericroy commented 7 years ago

And here are my version details, if that's of any use:

Defold version1.2.98
Defold sha6725d7a9bc8fc85b3d6759eb5ed7dfb9df2cf9fb
Build time2017-02-21T10:13:40.438078
OS nameWindows 10
OS version10.0
OS archamd64
Java version1.8.0_102-b14
erikangelin-king commented 7 years ago

Hi!

The models already have their world transform applied in order to improve batching. This has been discussed in the team and eventually there may pop up an option for this. For now, we've made sure the world transform is also applied in the editor so you should at least see the same thing in the editor and the game. Some related issues: https://github.com/defold/editor2-issues/issues/537 https://github.com/defold/editor2-issues/issues/536

Closing this for now as it's no longer an "Editor 2" issue. Please reopen if you feel otherwise.

Thanks!