Material with transparency working in pview but not in game


I have been having some trouble getting a transparent material to work. It loads and looks fine in pview, but when loaded into my game the transparency is not there.

I am exporting from blender using yabee.
I have tried a handful of export settings, UV mapping, baking, I have also looked around the forum at similar issues but was unable to extrapolate how to clearly solve my issue. Does anyone have any insight to what I might be missing? Do I need to activate or attach something to my model once its in the scene of my game?

Thanks for your time!


Try applying this to the node.

Unfortunately thats not doing anything on my end.

Do you think its that something to do with exporting from blender? Though I wouldn’t understand why It would work properly in pview but not in the game scene? Thanks for your insight btw, I should have said that previously!

What is the output of after loading your model/scene? Are you using the auto-shader?

Here is the output from that:

PandaNode render S:(CullFaceAttrib LightAttrib RescaleNormalAttrib ShaderAttrib)
ModelNode camera T:(pos 0 60 1 hpr 0 -12.5 0)
Camera cam ( PerspectiveLens )
PerspectiveLens fov = 39.3201 30
Camera cam ( PerspectiveLens ) T:(pos 0 0 50 hpr 0 -45 0)
PerspectiveLens fov = 39.3201 30
ModelRoot terst.egg T:(pos 0 54 -3 hpr 90 0 0) S:(TransparencyAttrib)
GeomNode Icosphere.001 (1 geoms: S:(MaterialAttrib TransparencyAttrib)) T:m(pos 0.999991 -0.0247896 3.19136 hpr -126.973 3.94284 180)
GeomNode Icosphere (1 geoms: S:(MaterialAttrib TransparencyAttrib)) T:m(pos 0.999991 -0.0247896 0.917535)
GeomNode Cube (1 geoms: S:(MaterialAttrib TransparencyAttrib)) T:m(hpr 0 0 42.994)
PandaNode Armature T:(pos 0 54 -3 scale 0.5)
Character __Actor_modelRoot
GeomNode (3 geoms: S:(MaterialAttrib TransparencyAttrib))
CollisionNode player (1 solids)
PandaNode Armature T:(pos 0 50 -3 hpr 180 0 0 scale 0.5)
Character __Actor_modelRoot
GeomNode (3 geoms: S:(MaterialAttrib TransparencyAttrib))
PandaNode Armature T:(pos 0 52 -3 hpr 180 0 0 scale 0.5)
Character __Actor_modelRoot
GeomNode (3 geoms: S:(MaterialAttrib TransparencyAttrib))
PandaNode Armature T:(pos 0 54 -3 hpr 180 0 0 scale 0.5)
Character __Actor_modelRoot
GeomNode (3 geoms: S:(MaterialAttrib TransparencyAttrib))
PandaNode Armature T:(pos 0 56 -3 hpr 180 0 0 scale 0.5)
Character __Actor_modelRoot
GeomNode (3 geoms: S:(MaterialAttrib TransparencyAttrib))
AmbientLight ambient light:
color 0.2 0.2 0.2 1
DirectionalLight main light ( OrthographicLens ):
color 1 1 1 1
direction 0 1 0
CollisionNode wall (1 solids)
CollisionNode wall (1 solids) T:(pos 0 8 0)
CollisionNode wall (1 solids) T:(pos 0 8 0)
CollisionNode wall (1 solids) T:(pos 0 8 0)

terst.egg is the specific model i’m trying to make transparent, all of them have transparency in blender though and none of them in panda3D. Thanks for your help!

I see you’ve got a TransparencyAttrib set on the nodes, and I am guessing they are using M_alpha to do alpha blending. I also see that render has a ShaderAttrib; I am guessing that you’re using the auto-shader. There is a light in the scene, so this wouldn’t be an issue with unlit materials either. I feel that eliminates the usual suspects, so I’m out of ideas. Are you able to post your code and/or EGG file?

You say that in PView the transparency works as expected; does that remain so with PView’s light active (press “L” to toggle lighting, I believe), or with PView rendering with shaders (press “P” to toggle shader-based rendering, I believe)?

yes it remains active in pview with the lights on / it actually is just white without lights…

I am pretty inexperienced with panda3D, and blender TBH… I have been working on this game for the past 3-4 weeks for a term project, so I’ve become a lot more familiar with both of them. Pretty much lived in this discourse that whole time, but am now starting to run into some problems that are not answered in previous posts. Basically I apologize in advance for asking obvious questions or maybe not immediately understanding how to implement something.

Here is how I’m loading the model in the game:
self.environment = loader.loadModel(“MorgansModels/terst”)
nodePath = NodePath(self.environment)

Here is the .egg file attatched:
terst.egg (496.4 KB)

Did you try my second suggestion, rendering with shaders?

Opening your egg-file in PView on my end, I note that the model is transparent when shader-based-rendering(/per-pixel-lighting) is not active–but opaque when it is.

It thus may be that, however you’re applying your transparency, it’s a method that Panda’s fixed-function pipeline respects but that its auto-shader pipeline doesn’t. What that might be I’m not sure of; hopefully someone else will have some idea!

Thaumaturge, thanks for your continued help and insight with this.

I did not attempt that, I’m unsure if I know how to do that in panda, Im somewhat familiar with GLSL, if thats what you mean, like write my own shader with that?.. is there a way to render with shaders using the material attached to my exported blender object though?

1 Like

The help is my pleasure. :slight_smile:

If you mean “rendering with shaders”, I was referring to PView at the time, I believe: In PView, you can activate shader-based rendering by pressing “P”, if I’m not much mistaken.

In your program, the simplest way to render with shaders would be to activate Panda’s auto-shader system, via the “setShaderAuto” method. Are you calling that method (e.g. in “render.setShaderAuto()”) somewhere in your code?

(You could use a custom shader of your own, but for now I suspect that doing so is superfluous.)

Well, Panda should be using the exported material–I’d guess that it’s either a matter of how Panda is interpreting that material, or of some feature that’s handled differently under the auto-shader, or perhaps of some feature that’s been overlooked in the auto-shader.

I definitely feel very incapable right now because of this haha, I may be mistaken but assumed getting the objects out of blender into panda would be the easy part of things, as I didn’t think I was doing anything overly complex with model or material design.

Since you posted almost immediately after I did, I’m just posting to make sure that you’re aware of my reply, and didn’t miss it as a result of that timing. ^^;

haha thanks for that! I did not have a call to render.setShaderAuto() but just tried adding that below the rest of models code and doesn’t seem to affect the results either.

Okay, if you don’t have the auto-shader active, and if you’re not using custom shaders, then the transparency not working in your game is very odd indeed. o_0

Would you be willing to post a minimal test-program that, on your machine, exhibits the problem when applied to your model, please?

Sooo actually, when going to copy and paste some code to send to you I noticed I had another call to render.setShaderAuto() being called after lights in my scene. When I just commented that out to disable it and all other calls to it, the object became visible with its transparent material.

So it would seem that calls to render.setShaderAuto() actually interfered with the default material’s transparency being made visible. Anyways, that part is working now! I am very grateful.

On another note: I am unable to tell if the materials “reflectivity” is actively mirroring the space around it, I suppose thats the next thing I need to figure out. Feel free to drop some advice on that end if you have it, no pressure tho, very happy to at least get that other bit solved!

1 Like

Based on a bit of quick testing, it seems that the auto-shader doesn’t observe transparency derived from a material applied to an object (unless there’s a setting that I’ve missed), but that it does observe transparency derived from a texture applied to an object.

1 Like

There are no problems here, you use the transparency of the material. Obviously, the material is only active if there is a light source. You must have a color source in your scene.

Indeed, I’m also seeing this.

One workaround is to call set_alpha_scale on the model.

What results do you get with the following code? Are you seeing a smiley through a transparent green sphere?
All I see is an opaque green sphere. Maybe the code is missing something?

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):

    def __init__(self):


        dir_light = DirectionalLight("light")
        dir_light.set_color((1., 1., 1., 1.))
        light_np = self.render.attach_new_node(dir_light)
        light_np.set_hpr(-20., -20., 0.)
        self.render.set_shader_input("light", light_np)

        model = self.loader.load_model("smiley").get_child(0)

        # create a copy of the smiley model to show through the transparent model

        # clear the render state of the model to remove its texture
        model.node().set_geom_state(0, RenderState.make_empty())
        mat = Material()
        mat.set_diffuse((0., 1., 0., .5))
#        model.set_alpha_scale(.5)

app = MyApp()