-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Test model for KHR_materials_specular and KHR_materials_ior #268
Conversation
I experimentally added this model to gltf-test and tested it. The display results of some WebGL libraries are as follows.
|
three.js hasn't implemented these extensions yet, so I doubt we're correct. 😇 |
@proog128 Babylon.js is close to a path-traced result, but the windshield is not transparent, is that correct? Is transparent the correct answer? |
There is no alphaMode specified in the glTF so opaque should be correct. |
The transparency on the windshield comes from KHR_materials_transmission (KhronosGroup/glTF#1698). The surface is opaque, but it has a transparent material. See Section about blend modes in KHR_materials_transmission. Another test model for transmission is provided in #265. |
Yup, totally missed that extension. |
But the transmissionFactor is undefined so defaulting to 0 according to the spec. @proog128 shouldn t it kind of disable the extension or "kind of" ? Also I am seeing 6 in the ior extension which sounds a bit high ? |
Hi, there. I'm called by my friend cx20. @sebavan Hi, IOR 6 is not so unusual in metals. |
Shouldn't the clearcoatFactor be set to 1? The clearcoatFactor is currently unspecified, which means it will be disabled according to the spec. |
Oh, you are right, the factors are missing. I'll fix that. Thanks! The car paint is a special case. Usually, an IOR of 6 is too high for dielectrics, and for metals you should use metalness=1. But in the car paint we have a layered mix of dielectric and metal with different colors for each of them. We use an unusually high IOR to increase the contribution of the metal (top layer) over diffuse (base layer). |
Perfect this i all expected as to completely work we also need to render to texture the none transparent parts which is what we have as a work in progress here: BabylonJS/Babylon.js#8623 @MiiBond is taking care of enabling it in our loader, so we are at the correct state at this point :-) |
The only strange part is the clear coat ior on the path tracer. @proog128 it looks like on the path traced model the ior of 6 is applied to the top layer ??? not the metallic one, I kind of assume looking at the render. Should it be ? |
@sebavan With top layer you mean clear coat? No, the clear coat IOR is 1.5. Semantically, the following happens:
(There is no "IOR stacking", the IORs do not influence each other). A few more images, maybe helpful for debugging:
|
This would explain why in Babylon we see such a difference then :-) Is it part of the spec that they do not influence each other (I might have missed this part) ? so that I ll modify our material accordingly. Thanks a lot again for your reactivity. |
@sebavan Ah ok, that explains why the base layer is so much brighter in Babylon. This is what you mean? The spec doesn't mention IOR stacking, the example code in the implementation sections doesn't use it. Although I like the idea (after all it's more physically-plausible), it will require the material to be set up with "valid" values for the IOR. And this will break use-cases such as the car paint, where IOR is used in a kind-of spec-gloss workflow. I think it will also reduce compatibility to material models in other renderers, especially if they come from spec-gloss or high IOR for metal etc. For this reason I think we should keep IOR stacking for later, when we have a node-based material system with layering in glTF :-) |
Filament is actually closer to Babylon.js for the windows: Note that the transmission extension is currently not supported in ubershader mode when too many other extensions are also in use (clear coat in this case). We run out of samplers… We haven't implemented _specular and _ior yet. I'm surprised the stripes don't show through the front window. Are the stripes an opaque material? |
Ah I see, the whole car is a single material, which prevents our real-time implementation from working properly. The way it works is:
Is there any chance we could change the reference model to draw the windows separately? It would make the model correct in real-time renderers. |
Yup did not catch this part at first, but we will have the exact same in Babylon or most of the real time renderers. |
@proog128 can you make the change @romainguy mentions? For the sake of realtime renderers, the non-transmissive portions of the car will need to be a separate material without any transmission applied. This allows these parts to be rendered separately as needed. |
Yes, I will separate the materials. |
…prove support for real-time renderers.
f550a20
to
5348631
Compare
Non-transmissive parts are now separated and branch is rebased (merge conflicts resolved). |
My team will have a look at it @UX3D-becher |
What is the IBL used in all the reference images btw? I'd like to replicate the same lighting. |
Actually, we still do have this option turned on as well :-) @Popov72 Could you see if it is possible to add an option to disable it for GLTF ? |
@bghgary @sebavan It seems that Babylon.js
|
What is the mode file used in the screenshot? It seems it is not the ToyCar from the glTF sample repo as the latter one has no stripes. |
The This is a different version from the following model, although the name is the same and therefore confusing. Perhaps |
Between alpha 18 and alpha 20 we have implemented the KHR_materials_specular extension as described here. That means Car: "KHR_materials_specular" : {
"specularTexture" : {
"index": 4,
"texCoord": 0
},
"specularColorTexture" : {
"index": 4,
"texCoord": 0
}
}, Fabric: "KHR_materials_specular" : {
"specularColorFactor": [0.729, 0.071, 0.078],
"specularTexture" : {
"index": 8,
"texCoord": 0
},
"specularColorTexture" : {
"index": 8,
"texCoord": 0
}
} |
@cx20 That's a good question. Although not as polished as the other version with sheen, I think it's still a nice test model to check the specular extension and its interaction with the IOR and clearcoat extensions. In particular the combination of specular and clearcoat is not covered by any other test as far as I know. Meanwhile I renamed the model from ToyCar to ToyCarSpecular to distinguish the two models. |
@proog128 Thanks for fixing the file name. |
@cx20 Oops, you are right, thanks. Fixed it. |
The ToyCar model in this PR is a better test-case for the interaction of the specular, ior and clearcoat extensions. I am a bit hesitant to abandon it, because it already found bugs in implementations that are not covered by other test models (as far as I know). Some ideas:
Any opinions? |
I think this might be the best choice, although I'm open to other opinions (@cx20?). I think having a few sample shapes alongside some samples of the correct answers (where possible) can allow folks to more easily spot problems without a trained eye. Also it avoids the "car is different colors in different engines" issue seen in the first few shots on this thread. It would be better for the sample model to highlight an implementation getting the wrong answer, rather than showing an assortment of different interpretations. Can we start by making a detailed list of which features / interactions need testing? |
I agree with @emackey. |
|
@proog128 : This PR uses a branch that has conflicts. We are trying to resolve all PRs in this repo in the next week. If it can be resolved in that time, please do so. |
Based on the discussion above, I'd suggest to close this pull request. I will come up with a simple test model based on this list. |
This is a sample model for KHR_materials_specular (KhronosGroup/glTF#1719) and KHR_materials_ior (KhronosGroup/glTF#1718). It also makes use of KHR_materials_clearcoat and KHR_materials_transmission.