-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finishing KHR_materials_common #632
Comments
This can be easily done via
Can be done later (1.1+) via something like
A separate extension should be proposed for such case to keep |
@lexaknyazev I agree with your thoughts for doing things later in #632 (comment). Is there anything short-term here that you need input from @tparisi or me? |
This one (btw, COLLADA doesn't have such limits):
There are several still unaddressed small fixes (regarding |
I am OK with this. @tfili do you remember if this was discussed at all for KHR_materials_common?
Are these all in #633? If not, do some need more discussion here? |
They aren't. I can make one more PR. |
Yes, please. |
(1) OK and (2) up to you. |
@tparisi can you please do a final review of this and #633? @lexaknyazev is there anything else you are waiting on? |
A little comment about As far as I understand, its purpose is to assist client runtime in alpha-blending/sorting operations. So maybe we can add two restrictions:
What do you think? |
Both are OK with me. |
In the core glTF spec there is no requirements on attributes types. This makes sense when using custom shaders but can lead to runtime confusion when using
Not sure about usage of |
FRAUNHOFER_materials_pbr extension uses different parameters for "diffuse texture" and "diffuse factor". |
One comment since the extension is not being ratified yet. There is an inconsistency in the handling of material types with light types (or for that matter other types like camera). The main issue is that the material values are copied into the values dictionary, but that makes it very loose and hard for an automatic validation. Compare that to the handling of light types, that uses different objects for the different light types. Camera types works the same way. The current spec follows the technique specification for values where arbitrary values makes are defined to support binding uniforms for arbitrary shaders. This extension though defines fixed values per-type, so placing the values into the values dictionary might not be optimal. Let me elaborate.
Let me suggest a simple modification that is backward compatible with the previous model but allows for schema validation and automatic codegen from the schema. I follow the same semantic as light/camera type.
If this has any hope for traction, I would be happy to write a proposal and schema, test the schema and update Collada2gltf converter myself within the next month. Please let me know what you think. |
@xelatihy thanks for the offer. To start, I think it would be useful to see some short before/after examples. |
Here is a first, trivial example, taken from Samples/Box/gltf-MaterialsCommon/Box.gltf. Current JSON for material, reformatted to make it clearer to compare. "KHR_materials_common": {
"doubleSided": false,
"jointCount": 0,
"technique": "PHONG",
"transparent": false,
"values": {
"diffuse": [0.8,0,0,1],
"shininess": 256,
"specular": [0.2,0.2,0.2,1]
}
} Proposed new format to match the above definition. "KHR_materials_common": {
"type": "PHONG",
"phong": {
"doubleSided": false,
"jointCount": 0,
"transparent": false,
"diffuse": [0.8,0,0,1],
"shininess": 256,
"specular": [0.2,0.2,0.2,1]
}
} The difference is minimal in the example, but the schema definition can now be explicit. For example, I can have a schema file for the object phong, like material.phong. I would then have a different schema for LAMBERT, for example for the following example. "KHR_materials_common": {
"type": "LAMBERT",
"lambert": {
"doubleSided": false,
"jointCount": 0,
"transparent": false,
"diffuse": [0.8,0,0,1],
}
} |
The one concern with the above definition is that material values are not shared between material types, and this might not be desirable. A different approach is to keep the values dictionary, but make the value object strongly typed via a schema for value. For example, one such schema would define properties for diffuse, specular, etc. by giving them strong types, like for example the translation/rotation/scaling in the node type, but disallowing to have any value contained in the values array (like it is supported for values in techniques). To be more clear, the values in technique.parameters are defined as {
"properties" : {
"value" : {
"anyOf" : [{"type" :["number", "boolean", "string"]}, { "$ref" : "arrayValues.schema.json" }]
}
}
} My second proposal would be to define the schema for this extension as {
"properties" : {
"value" : {
"allOf" : [{"$ref" : "material.value.schema.json" }]
}
}
} and defined each variable specifically in another file, like {
"properties" : {
"diffuse" : {
"type" : "array",
"description" : "The node's non-uniform scale.",
"items" : {
"type": "number"
},
"minItems" : 4,
"maxItems" : 4,
"default" : [ 0.0, 0.0, 0.0, 0.0 ]
}
....
}
} The difference between this and my previous post is just that
The first proposal instead specified each material type independently. Both, to my eyes, are better than having and arbitrary list of variables like techniques.parameter. Hope this helps. I would be happy to write down the spec following this proposal too. |
One last common on values definition. One concern I have is that many values are either colors or textures (in the schema either arrays with min and max length equals to 4), or strings. This makes is very hard to do two things:
Similar concerns have been voiced in the PBR thread. Would be great to have something like "diffuse" and "diffuse_texture". Hope this helps. |
Big re-edit of this extension. Changelog:
Couple new questions:
Known Issues
|
It's definitely not AO in COLLADA's terms (it's just a dedicated "receiver" of ambient light sources). |
Thanks @lexaknyazev. Note that I am not the authority here, but I will provide some input to try to help move this forward.
No, it is reasonable to shade things like point clouds, and I don't think disallowing this buys much.
OK with me.
I dunno. Sounds like a lot of work. Is it? In practice, when will people use this extension? I would rather everyone move to PBR. Will people use this often enough to justify the work for these maps (not just spec and tools, think of the engines: how much code can be shared with the two rendering paths).
Go with whatever you think the industry runtime standard practice is. In Cesium, we usually have an RGBA texture with diffuse/transparency; I don't know that this is done broadly. |
OK
My initial thought was that engines already have such features, so adding them to spec shouldn't be much bother for implementations. However making that stuff reliable and consistent across different runtimes can take some time.
COLLADA's definition of opaque/transparency is very vague (look at related collada2gltf issues).
Single alpha-channel in diffusion map works usually, but such setup prevents user from having emission-only material with transparent parts. Here's what could be done to make alpha handling simpler;
|
OK with me. |
Should I update the spec or wait for more comments on removing One more question:
What's expected treatment of |
I'm not sure how much more feedback you are going to get given how long this extension has been in draft. Let's just move forward.
Sounds reasonable to me. |
Some more comments regarding compatibility with existing engines (so this extension could be rendered with engine's existing materials): Material models:
Properties:
Additional notes
Questions
Proposals to increase compatibility
|
OK with me.
Perhaps not...or require Phong.
I don't know enough to say. Why?
No, sounds like a significant implementation burden for what is supposed to be a simple material.
OK
OK |
It's about documenting rendering pipeline. Specifying colorspace for images helps achieving consistency across implementations. Otherwise, we could just add informal note. |
Whatever you think is reasonable. |
Unless I'm missing something, this extension has the same multi-uv issue as the PBR extension (#742). Are there plans to add multi-uv support to this extension, or just the PBR one? |
glTF 2.0 will have multi-UV support in the core spec, so this extension will be updated to reflect that. |
@lexaknyazev Also, should this extension support normal maps? Normal maps are fairly common, but, if you're using this extension, I don't think there is a way to supply them via glTF. |
@Moguri normal maps will be part of the core spec. The thinking is that this extension can also use the maps from the core spec similar to what the specular-glossiness extension in #842 is doing. |
Main discussion was in #424.
Small fixes:
transparent
anddoubleSided
flags insidevalues
. COLLADA2GLTF puts them just into the extension object.jointCount
property.JOINTMATRIX
semantic because it's a uniform parameter not attribute. KHR_materials_common #633light.distance
was once removed, then returned back (by mistake?). JSON schemes don't have it. KHR_materials_common #633direction
for Directional and Spot lights in descriptions after Table 2. KHR_materials_common #633quadraticAttenuation
for Point and Spot lights in descriptions after Table 2. KHR_materials_common #633light.color
type is defined as FLOAT_VEC4 in spec, but FLOAT_VEC3 in JSON schemes. KHR_materials_common #633light.color
value is defined as[0, 0, 0, 1]
in spec, but[1, 1, 1]
in JSON schemes. KHR_materials_common #633CONSTANT
shading could be improved. It says: "a material that describes a constantly shaded surface that is independent of lighting". However, reflected color depends actually onambient
light contributions.Since Extension hasn't been ratified yet, maybe it's possible to discuss a few more things:
light.color
values over1.0
?The text was updated successfully, but these errors were encountered: