so I’ve read about the concept of model space and world space in glsl.
As far as I understand it, the model space is the space used when the model gets created in blender or viewed in .j3o and the word space is the space of the whole scene, isn’t it?
As an experiment, I tried to set the coordinates of some vertices to the origin of the model space. This should be equal to the position of the model in the scene, if I’m not mistaken.
So I wrote this small vertex shader node, which I place right before the CommonVert node:
This is before the CommonVert Node, so every transformation should take place in model space.
However when I look at the result, the concerned vertices are placed in the origin of the whole scene, not the origin of the object!
I hope I didn’t misunderstand model and world space.
To make it clear, Model space is the space which origin is the origin of the model. That’s not really related with blender or j3o files.
World space is the space which origin is the center of your scene.
Your assumption sounds about right, now if it’ snot working something else may be wrong.
Could you post the generated shader?
Just to be clear: The origin of the model is 0,0,0. If you have a vertex in the mesh at 0,0,0 then it will be located IN WORLD SPACE where the Geometry is located IN WORLD SPACE. If the Geometry is located at 45, 67, 123135 then that is a contribution to the WORLD SPACE of the Geometry.
Maybe this can be useful for someone who has the same problem:
I found a way to work around the batching limitations.
I store the position of the objects as texture coordinates in the meshes of my objects. This way every object has the same material and can still be batched.
However this technique requires deepClones of the objects, so performance is reduced a bit. But it’s still not as much as when you don’t use batching.
If your objects are of relatively decent size (and the same) then you might be able to get away with instancing, too. Then the only information per object could be the world transform (or position if that’s all it takes).