-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Error in techniques for VC model #8
Comments
@javagl thanks for all the research. Is this now duplicate with KhronosGroup/glTF#576? Should we consolidate these issues? |
They are related, at least. This issue only refers to the fact that a technique that eventually refers to a semi-opaque PNG does not contain the If it contained the The issue 576 asked about these boxes. They appear in "non-sopisiticated" renderers (that do not use OIT or other fancy stuff). The reason of why the boxes appear is what I currently consider as an error in the glTF file: I think that that I wondered about where to report this: Here in EDIT: From a quick glance, at least the |
So I'll have read more about premultiplied alpha (which is ENabled in WebGL by default, but DISabled in OpenGL usually), find the answer to the question of whether the fragment shader should be
(or whatever) in conjunction with the premultiplied alpha setting, and figure out how to render two assets at the same time, one with premultiplied alpha and one without. But all this is probably only an issue of the renderer implementation, and not of the sample models. Sorry again for the noise caused by my lack of knowledge here. The texture is still rendered in "opaque black" in cesium, but maybe this is not an issue. |
This may be a very specific issue, and awfully hard to debug (that's why I'm writing this at 3:30am).
__-_Default_2
( https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/1.0/VC/glTF/VC.gltf#L11182 ) (yes, odd names....)technique1
. It containsstates
, but these states do not involveGL_BLEND
. But, to my (limited) understanding of OpenGL, when using a transparent texture, thenGL_BLEND
is required - and some additionaltechnique.states.functions
settings.There are other techniques that involve transparency (for example, for the windows of the aircrafts), and they contain the proper
technique
states withGL_BLEND
, as well as thetechnique.states.functions
. I also have an old copy of the VC model (from ~6 months ago, where it was still calledvc
, with lowercase names), and there, the technique that is used for this transparent texture image seems to be right.I tried to go though the Git history, but it's hard to track this down, because there are some renamings and cases where all models have been re-generated. Someone with advanced Git-foo might have more luck here.
Possibly unrelated, but the context in which I noticed this:
I tried to get rid of the infamous "boxes" that have been reported in KhronosGroup/glTF#576 and that also still appeared in JglTF. Comparing the renderers from https://github.com/cx20/gltf-test (nice project, btw) showed that the boxes
It has something to do with transparency, blending, rendering order etc. I noticed that when changing the blend functions from 1 and 771 (
GL_ONE
andGL_ONE_MINUS_SRC_ALPHA
) in the technique state functions......to 770 (
GL_SRC_ALPHA
) and 771it seems to render properly. But this was just found out with trial-and-error. I thought that KhronosGroup/glTF#747 (and the linked pulls/issues) might be related, but the order of the parameters seems right. I read more about all this in the OpenGL docs, started looking at the .DAE input files and reading the COLLADA spec, and the section about "Determining Transparency (Opacity)" contains lots of information about the different cases, talking about
A_ONE
andA_ZERO
opacity modes, where "transparency" sometimes means "transparency", and sometimes "transparency" means "opacity" (!!!). (Frankly: This is a mess...)However, I'll probably try to create another "minimal example", consisting of two triangles, one opaque and one semi-transparent (and maybe something with a semi-transparent PNG). These examples could allow to quickly and easily check whether a renderer shows the intended behavior in regards to transparency handling. Right now, it's hard to say what the "intended behavior" is.
(BTW: Note that, in the renderer comparison mentioned above, Cesium.js also renders the heli propeller texture as a completely opaque one, although it should be transparent - but this is likely only caused by the error in the input file)
Edit:
Since I'm not sure whether this is an issue of glTF and the spec, the sample models (where VC unfortunately is the only one that uses
technique.states.functions
!), or the renderer implementation, I opened another issue detailing all this (and including a "simple test case") at javagl/JglTF#6And another edit:
For a test, I uploaded the model from javagl/JglTF#6 to http://cesiumjs.org/convertmodel.html and it looks nice and correct. However, it also looks nice and correct when using
so I guess that this property is not taken into account at all. And at the moment, I think if it was taken into account, the settings
(that are currently used in the VC model) would cause the output to look like the first screenshot in the JglTF issue. But I might be utterly and embarassingly wrong here.
And a last edit - sorry about that:
The nice, correct rendering in Cesium is achieved by the order independent transparency. When disabling OIT, it looks like expected: With
FUNC_ADD
, and a completely transparent blue source (multiplied withGL_ONE
(!)), and an opaque red destination (multiplied withGL_ONE_MINUS_SRC_ALPHA
), the result is magenta. I don't think that this is the "right" way of blending, and think that the source factor should beGL_SRC_ALPHA
(because that's what the alpha is for), but I think it is reasonable to say that, without OIT, there is no "right" way of blending anyhow...The text was updated successfully, but these errors were encountered: