Billboards and Their Locations

I’m doing some 3D modelling, and want to include a billboarded element in the model in question.

For the most part this seems to be working–it called for a few minor edits to YABEE, but nothing serious, I believe.

However, the resulting egg-geometry, while correctly billboarded, is not located in its intended position.

Here’s an illustration of the issue, using a pair of simple models–specifically, a cube surrounding a plane. The plane is billboarded, while the cube is not. Both are placed into the “fixed” bin, and their draw-orders set such that the plane should render first, if I’m not much mistaken. Furthermore, depth-writing is disabled on the plane.

In the first example, the two objects are located at (0, 0, 0); in this case, the result is as expected:

Blender:

PView:

In the second example, the objects have been moved upwards a little–and now the billboarded plane is offset beyond the cube, despite their being in the same place in Blender:

Blender:

PView:

And finally, here’s an egg-file that displays the issue, on my machine at least:
billboardTest.egg (5.2 KB)

Does anyone know why this is, and what might be done about it?

(Short of carefully offsetting the billboarded object to compensate, I suppose. I’m wary of doing so: not only is it untidy, it incurs the potential for the model to become incorrect should changes be made, and the result in Panda to become incorrect should this billboarding behaviour be changed.)

[edit]
It occurs to me that t he problem might be that the billboarded object is rotating around the origin. However, I would expect it to rotate around its local origin (so that billboarded objects work when placed elsewhere than the origin), and parenting it to the cube (thus giving it a local position of (0, 0, 0) doesn’t seem to fix the problem.

This problem was discussed in the discord, if you want, I will give you a link to the dialog.

However, you can try replacing it.

  <Group> Cube {
    <Scalar> bin { fixed }
    <Scalar> draw-order { 1 }
    <Transform> {
      <Matrix4> {
        1.0 0.0 0.0 0.0 
        0.0 1.0 0.0 0.0 
        0.0 0.0 1.0 0.0 
        0.0 0.0 2.221245050430298 1.0 
      }
    }

On:

  <Instance> Cube {
    <Scalar> bin { fixed }
    <Scalar> draw-order { 1 }
    <Transform> {
      <Matrix4> {
        1.0 0.0 0.0 0.0 
        0.0 1.0 0.0 0.0 
        0.0 0.0 1.0 0.0 
        0.0 0.0 2.221245050430298 1.0 
      }
    }

Hmm… Discord is being a bit of a pain to me right now, and the change that you suggest doesn’t seem to be working–if I’m implementing it correctly.

Could you summarise the conclusion of the Discord channel, please? (Or link me to somewhere else that might have that conclusion?)

The problem is that the billboard effect is handled differently by the EGG, It’s all about the vertex displacement that occurs when the matrix is applied. For the billboard, when exporting, you should ignore the world coordinates.

@Maxwell175, found this solution.

The dumb workaround is to just not use the world matrix for the verticies

        if self.obj_ref.billboard:
            co = self.obj_ref.data.vertices[vidx].co
        else:
            co = self.obj_ref.matrix_world @ self.obj_ref.data.vertices[vidx].co

but only for billboard
which makes no sense to me yet

@rdb, offers.

It makes sense for YABEE to do that, recognising a “billboard” tag or something
Or you could tag it and then apply it in Panda

for node in model.findAllMatches("**/=billboard"):
    node.setBillboardAxis()

However, when I change the group to Instance, I get a coordinate match.

And a message in the console about an unknown tag.

Ah, I see–thank you!

I’ve made appropriate changes to my version of YABEE (I’m checking for a game-property called “billboard” rather than a billboard variable).

And indeed, having done so, the model now works as expected!

So thank you again for your help! :slight_smile:

(It is strange that a billboarded object should so ignore the world-matrix. o_0)

As to the code-approach, I’m trying to make a model that works “out of the box”, so a code-solution doesn’t work for me, I fear. Modifying YABEE suits much better!

Ah, trying it again, it looks like I misunderstood: I thought that I was to change the billboarded object’s “Group”-tag to be an “Instance”-tag, but it seems that it’s instead the other object that’s to be changed!

That said, while doing so does sort-of work, as soon as I tilt the camera vertically around the objects they once again separate.

Ah, yes, I think that I gave my “depth-write” tag an invalid value. ^^; Sorry about that!

If you’d like you can check the exact changes I made here:

I also have support for Blender 2.8+ set up if you’re interested in that.

1 Like

Thank you!

I’ve already made my own modifications to YABEE, as it happens, but I am interested to see what you’ve done and do appreciate the offer. :slight_smile:

Looking at your code, I’ve done pretty much what you did in “collect_vtx_xyz”, I believe.

Conversely, I see that you have a very different approach to applying scalars, etc., including the “billboard” tag–I’m guessing as a result of the changes made in Blender. In particular, I think that I recall that newer versions of Blender lack the “game properties” of older versions, thus making those no longer a viable source of object-tags.

That’s very interesting!

If I may ask, are you taking over support of YABEE, then, or is this a once-off update? And how does the feature-set of this version of YABEE compare with the old–are there things no longer supported by it?

I don’t know if I have the time to completely take over YABEE, but I do use it regularly so I fix issues that I come across.

In order to make it work for Blender 2.8+ I added a new panel to Object properties called Panda3D that just has a bunch of textboxes for various egg options. I also updated the blender egg importer (GitHub - Maxwell175/blender-egg-importer: Add-on for Blender to import Panda3D .egg models.) to import those options properly.

Ah, I see! Thank you!

And does your version support animations, and vertex-colours?

I don’t think i changed anything in those areas from mainline YABEE. I have used animation a number of times and it worked with no issues.vertex colors should work as well if I recall correctly.

Okay, that’s reassuring! I might try out your version at some stage, then, should I move over to a newer version of Blender! :slight_smile:

1 Like