Transparency Object Depth Sorting

well, it is the general cutscene feature for the game’s story, anything can happen
EDIT: let me disable the scene transparency to see if this is the fix, first

EDIT2: so disable all scene tranparency and now only the character, the spinning razor model, and some other actors flash red, tried it and the issue persist. what I forgot to mention is my debug text as well as the fps meter flash yellow.

What I’d suggest then is that you build in a feature to apply transparency to specific objects as called for.

In any case, having your entire scene be treated as transparent may have an impact on performance.

Since the character is still flashing red, it’s still being treated as transparent. (Again, this may be due to the textures having alpha-channels.)

For a quick-and-simple test, try calling the following: render.setBin("opaque", 1, 100)

That should force everything into the “opaque” bin, and apply an priority value of 100 to make it more likely that it will override other things in the scene-graph that might affect the result.

That’s normal, I believe–after all, text has transparency.

(The different colours have meaning, but I forget what they are offhand–you may find the answer in the manual, or on the forum somewhere.)

hmm, it provides different results each boot up, but kept trying until my character model was visible, and it seems to work, but I cannot use this because it’s random
EDIT: I am going to try locally on the actor only hold on.
EDIT2: well, it seemed to work locally but then she become the color of the sky, while a really cool effect, it is not the one I,am looking for, but it proves that setBin may be the answer

It’s hard to say exactly why that might be happening, without knowing more about the scene. Or at least, the answer isn’t coming to me right now!

But I don’t think that it means that “setBin” is the answer–rather, I feel that “setBin” is showing us a bit more evidence about the nature of the problem.

I still say that removing superfluous transparency is more likely the answer.

hmm, okay I will try disable all transparency involved except for the character

1 Like

Don’t forget to check your textures! If a texture has an alpha channel–even if the entire thing is fully opaque–Panda may still consider it to have transparency, as I recall.

what about onscreen images?

I’m not sure of how they’re binned, I’m afraid.

However, unless you have a lot of them, then I wouldn’t worry. I’m thinking more of textures applied to models–the environment, the characters, etc.

okay, so I commented out everything with setTranspency except the character and it seems the issue is still there, should I comment out the ones with setAlpha?

I don’t mean to harp, but what about your textures? As long as those remain, things may be automatically assigned to be “transparent”.

the textures are png images loaded through loader.loadTexture, then I simply use setTexture to load them, nothing more
EDIT: do you want me to disable textures too?
EDIT2: wait, my skybox has a effect to transitions to a new texture slowly as a weather effect
EDIT3: so I disabled the weather effect, and the issue is there, you said that tranparency may be automatically applied do you mean from “loader.loadTexture”, if so I would have to look into how to disable it.

No, I mean this:

Speaking roughly, a png image–in and of itself, unrelated to Panda3D, mind–can have various numbers of channels in each pixel. A basic png might have channels each for red, green, and blue. It may also have a fourth channel, for “alpha”, or “opacity”.

Now, if the texture has that fourth, “alpha” channel–regardless of the contents of that channel–then Panda will automatically treat is as having transparency.

Thus the trick is to remove that fourth channel.

There may be a number of ways to do this. In GIMP, one might open the png, select its layer, right-click to pull up the context-menu, and then select “Remove Alpha Channel”. That done, one should be able to save the png out with only the red, green, and blue channels present.

(If the option to “Remove Alpha Channel” is greyed out, and the option to “Add Alpha Channel” is available, then the texture presumably doesn’t have an alpha channel, and can likely be left as-is.)

hmm, okay, I don’t have gimp, I use macs preview program to edit my images, else, I get them blender 3d, I will try to check both programs.

but I was also looking around and found another post by you

you said in it that if the objects overlap, it can cause issue, each object that makes up my actor all have the same origin point, could that also cause the issue?

EDIT: so I removed all the alpha channels of the textures being used, and nothing different.

EDIT2: huh, so I decided to check the setBin portion of the manual in the meantime and tried my sorting the child trick

self.frobj[0].getChild(0).setBin("transparent", 0)

it does indeed work, as 0 is the first object in the cue right? But the setBin is global so it may effect others as soon as I turn on all the transparency, is there a way get a object’s bin cue number?

Okay, at least we’ve eliminated that.

Er, no, “setBin” affects only the NodePath on which it’s called, and all below that, I believe.

It can, but in the case in which your object was appearing to be sky-coloured, it would imply that the object was rendering as fully transparent for some reason.

Essentially, it suggests that:

  • The sky is being rendered
  • Then your object–which writes to the depth buffer
  • Then the environment

Since the environment is presumably further from the camera than your object, on checking the depth-buffer it finds that its depth is further than the recorded depth from the object, and so doesn’t render.

the skybox is parented to the camera, so that does make sense, infact the skybox is a little box that covers around the camera, so the order would be closer to the camera that goes first, the “setbin” seems global or else the character would have never became sky colored, I did a local test on the actor itself and got that result.

It’s likely still just affecting the binning of the object. However, that binning potentially affects its rendering order relative to other things.

It’s a bit like moving a single card to elsewhere in the deck: you’ve only acted directly on that card, but you’ve nevertheless changed its position relative to the others.

Well, I doubt that the camera is rendered, as such. :stuck_out_tongue:

(Also, the culling-bin system means that whether something is attached to the camera doesn’t really affect when it’s rendered, if I’m not much mistaken.)

Interesting, I can make small code bit if knew how to grab the render order of a object like

binord = []
for node in actor.getChildren():
  binord.extend([str(node.getBin(order))])
binord.sort(key=lambda tup:tup[0], reverse=False)
chlidx = 0
while len(binord) > 0:
  actor.getChild(chlidx).setBin("transparent", int(binord[0]))
  chlidx += 1
  del binord[0]

my code bit would get all the bin values of all the children of the actor then sort the bin values by numerical order then reapply those values to the child in order, but I do not know how to get the bin value. (sorry for the long response, I was researching how to sort lists by value in numerical order)

I’m not sure of why you need the original sort-order–why not just place them in the order that you want?

That said, the “transparent” bin automatically sorts its contents–the bin-order has no effect on objects placed within it, if I’m not much mistaken. For this to work, you’d want to use a bin that has the “BT_fixed” sorting mechanism (either the standard bin named “fixed” or one of your own).

See this manual page for more.

1 Like

the thing is I don’t know what order they are in (current position) the transparency bin, unless you are implying each actor has it’s own transparency bin?

Not quite: there’s one bin for “transparent” objects, but objects have no fixed order within it. Instead, their order is continually updated according to their position relative to the player. (This is one reason that having everything end up in the “transparent” bin can impact a game’s performance, I believe.)

Again, that manual page to which I linked above gives a bit more of a description of this, I think.