Open el-dee opened 5 years ago
Setting gl-version 3 2
will disable the fixed-function pipeline, including alpha testing. It is then expected that you use shaders to render your scenes. Panda3D will apply a default shader that is good for rendering simple, single-textured nodes, but is not very capable and cannot handle such things as materials, fog or lighting.
It is our plan to address this in Panda3D 1.11 with a better set of shaders, but in the meantime, if you wish to use a core profile context, it is likely that you will have to use your own GLSL shaders in order to render anything but the simplest scenes (or use a shader framework like tobspr's RenderPipeline or wezu's deferred shaders).
That said, adding alpha testing to the default shader sounds like an easy, harmless and useful change, so I will look into that, which will address this specific issue.
I guess I oversimplified the problem by using pview : in my program I'm actually using a hand made shader to render the tree, and the transparency is properly handled when running on Linux or Mac without gl-version. The problem seems that the alpha channel is stripped from the texture when gl-version is explicitly specified.
I will make a minimal code, with shader, to demonstrate it (or maybe to findi a bug in my own code ;) )
Okay, thanks. On Linux, with gl-version 3 2
and a properly functioning driver, you should also expect to see the alpha channel ignored without special alpha blending or alpha testing applied; it usually involves adding something like this to the bottom of your shader:
if (color.a < 0.5) {
discard;
}
…possibly in combination with adding a transparency mode to address semitransparent areas. Since it looks like your models use premultiplied alpha, something like this:
model.set_transparency(TransparencyAttrib.M_premultiplied_alpha)
But, if the behaviour is different with the same settings and the same Panda versions on different systems, we may need to investigate that.
My code is parsing the object tree to detect the TransparencyAttrib to know if alpha blending should be applied or not. But the attribute is set on the GeomNode and not on the NodePath owning it and so my code overlooked it and assumed there was no transparent part in my object at all.
Without "gl-version 3 2", if I understood you correctly, Panda3d is configuring the blending function and equation, that would explain why the code looked like it behaved properly as there was some transparency, though done outside of the shader.
Side question, would SceneGraphReducer simplify the object tree parsing by putting the TransparencyAttrib on the relevant NodePath ?
I retested this carefully and indeed there is also no transparency on Linux when using gl-version 3 x.
I'm also able to retrieve the TransparencyAttrib by looking at the RenderStates of the GeomNode and forward the config to my shader, so the problem was indeed entirely on my side and now solved :)
@el-dee Can you upload the model with which you've produced this issue, or is this not a bug in Panda and can this be closed?
For me it can be closed unless you want to implement basic transparency support in the default shader, as you suggested in your first comment https://github.com/panda3d/panda3d/issues/473#issuecomment-445780105 :
That said, adding alpha testing to the default shader sounds like an easy, harmless and useful change, so I will look into that, which will address this specific issue.
When specifying "gl-version 3 2" on MacOS, transparency is no longer honored.
Here is a basic tree model rendered using pview :
The same model, but with "gl-version 3 2" set in etc/Config.prc, the leafs are no longer transparent :
I captured the log with 'spam' level, but sadly I did not see anything outstanding : log.txt