{"action":"created","issue":{"url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models/issues/8","repository_url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models","labels_url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models/issues/8/comments","events_url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models/issues/8/events","html_url":"https://github.com/KhronosGroup/glTF-Sample-Models/issues/8","id":190535680,"number":8,"title":"Error in techniques for VC model","user":{"login":"javagl","id":5597569,"avatar_url":"https://avatars.githubusercontent.com/u/5597569?v=3","gravatar_id":"","url":"https://api.github.com/users/javagl","html_url":"https://github.com/javagl","followers_url":"https://api.github.com/users/javagl/followers","following_url":"https://api.github.com/users/javagl/following{/other_user}","gists_url":"https://api.github.com/users/javagl/gists{/gist_id}","starred_url":"https://api.github.com/users/javagl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javagl/subscriptions","organizations_url":"https://api.github.com/users/javagl/orgs","repos_url":"https://api.github.com/users/javagl/repos","events_url":"https://api.github.com/users/javagl/events{/privacy}","received_events_url":"https://api.github.com/users/javagl/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-20T02:54:15Z","updated_at":"2016-11-24T16:01:02Z","closed_at":"2016-11-24T16:01:02Z","body":"This may be a *very* specific issue, and awfully hard to debug (that's why I'm writing this at 3:30am). \r\n\r\n- The VC model contains many texture images, but only one of them is a PNG that contains transparency (https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/1.0/VC/glTF/prop128.png - the propeller of a helicopter)\r\n- The texture with this image is only used in a material that is called `__-_Default_2` ( https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/1.0/VC/glTF/VC.gltf#L11182 ) (yes, odd names....)\r\n- The technique of this material is called `technique1`. It contains `states`, but these states do **not** involve `GL_BLEND`. But, to my (limited) understanding of OpenGL, when using a transparent texture, then `GL_BLEND` is required - and some additional `technique.states.functions` settings.\r\n\r\nThere are other techniques that involve transparency (for example, for the windows of the aircrafts), and they contain the proper `technique` states with `GL_BLEND`, as well as the `technique.states.functions`. I also have an old copy of the VC model (from ~6 months ago, where it was still called `vc`, with lowercase names), and there, the technique that is used for this transparent texture image seems to be right. \r\n\r\nI 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.\r\n\r\n---\r\n\r\nPossibly unrelated, but the context in which I noticed this:\r\n\r\nI tried to get rid of the infamous \"boxes\" that have been reported in https://github.com/KhronosGroup/glTF/issues/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 \r\n- do **not** appear in Three.js, Babylon.js and Cesium.js\r\n- **do** appear in xeogl and GLBoost (and in JglTF - I'm working on that)\r\n\r\nIt has something to do with transparency, blending, rendering order etc. I noticed that when changing the blend functions from 1 and 771 (`GL_ONE` and `GL_ONE_MINUS_SRC_ALPHA`) in the technique state functions...\r\n\r\n                    \"blendFuncSeparate\": [\r\n                        1,\r\n                        771,\r\n                        1,\r\n                        771\r\n                    ],\r\n\r\n...to 770 (`GL_SRC_ALPHA`) and 771\r\n\r\n                    \"blendFuncSeparate\": [\r\n                        770,\r\n                        771,\r\n                        770,\r\n                        771\r\n                    ],\r\n\r\nit seems to render properly. But this was just found out with trial-and-error. I thought that https://github.com/KhronosGroup/glTF/pull/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` and `A_ZERO` opacity modes, where \"transparency\" sometimes means \"transparency\", and sometimes \"transparency\" means \"opacity\" **(!!!)**. (Frankly: This is a mess...)\r\n\r\nHowever, 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.  \r\n\r\n(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)\r\n\r\n**Edit:**\r\n\r\nSince 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 https://github.com/javagl/JglTF/issues/6 \r\n\r\n**And another edit:**\r\n\r\nFor a test, I uploaded the model from https://github.com/javagl/JglTF/issues/6 to http://cesiumjs.org/convertmodel.html and it looks nice and correct. However, it also looks nice and correct when using\r\n\r\n    \"blendFuncSeparate\": [ 0, 0, 0, 0],\r\n\r\nso 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 \r\n\r\n    \"blendFuncSeparate\": [ 1, 771, 1, 771],\r\n\r\n(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. \r\n\r\n**And a last edit - sorry about that:**\r\n\r\nThe 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 with `GL_ONE` (!)), and an opaque red destination (multiplied with `GL_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 be `GL_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..."},"comment":{"url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models/issues/comments/262807260","html_url":"https://github.com/KhronosGroup/glTF-Sample-Models/issues/8#issuecomment-262807260","issue_url":"https://api.github.com/repos/KhronosGroup/glTF-Sample-Models/issues/8","id":262807260,"user":{"login":"javagl","id":5597569,"avatar_url":"https://avatars.githubusercontent.com/u/5597569?v=3","gravatar_id":"","url":"https://api.github.com/users/javagl","html_url":"https://github.com/javagl","followers_url":"https://api.github.com/users/javagl/followers","following_url":"https://api.github.com/users/javagl/following{/other_user}","gists_url":"https://api.github.com/users/javagl/gists{/gist_id}","starred_url":"https://api.github.com/users/javagl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javagl/subscriptions","organizations_url":"https://api.github.com/users/javagl/orgs","repos_url":"https://api.github.com/users/javagl/repos","events_url":"https://api.github.com/users/javagl/events{/privacy}","received_events_url":"https://api.github.com/users/javagl/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T16:01:02Z","updated_at":"2016-11-24T16:01:02Z","body":"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\r\n\r\n    gl_FragColor = color;\r\n    gl_FragColor = color * u_transparency;\r\n    gl_FragColor = vec4(color.rgb * diffuse.a, diffuse.a * u_transparency);\r\n    gl_FragColor = vec4(color.rgb * diffuse.a * u_transparency, diffuse.a * u_transparency);\r\n\r\n(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.\r\n\r\n \r\n\r\n\r\n"}}
{"actor":{"display_login":"javagl"}}