jit.gl.model and group rendering order

radiotonga's icon

Hello,

I want to read a model file with multiple groups, and apply different alpha textures to each of these groups. I don't want to have multiple instances of this model, because my computer is already demanded. Is it possible to choose the rendering order of different groups within a single [jit.gl.model] instance?

Thanks in advance.

Bas van der Graaff's icon

Hmm I've never heard of that before. Maybe splitting up the model is a decent alternative? Or matrixoutputting all the groups in the model into jit.gl.mesh objects once when loading the model? That gives you some flexibility...

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

can't you achieve what you want with the texgroup message?

radiotonga's icon

Thanks rob, but I've already been playing with texgroup.

It works well if you're facing the model from a certain perspective, even better if you leave depth_enable on.

However, if you swing 180 degrees around the Y axis from that point, alpha stops working. I guess it's because of group commanded by the .OBJ file.

The only workaround I've managed so far is rather crude way: Load 2 differently ordered .OBJ models depending on your "standing point", with "alpha" and "depth" enabled.

Am I missing something, perhaps?

Rob Ramirez's icon

this is just the nature of opengl.
when you render objects with transparency, you must disable depth testing (@depth_enable 0).
however, this requires you to simulate depth by explicitly specifying draw order based on distance from the camera (@automatic 0).
the problem is, there is no way to do this with multiple drawgroups in a single gl.model.

perhaps something we can think about for future versions, but for now, you may have to abandon your drawgroups, and load multiple obj's with single drawgroups.

you will still be required to do your own depth distance calculations and draw sorting.