Closed tparisi closed 6 years ago
@tparisi Also, I also don't think we need distance
. That is the point of attenuation. You get the distance from the fragment to the light and using the attenuation values you compute the light's contribution to the scene.
Indeed. I just forgot to remove it. On it;
Fixed distance
and added some language describing how direction and position are calculated (or ignored) per- light type. b03b4b8
I think we have the following issues left to finalize this extension:
@tparisi @tfili can you confirm
confirmed, hope to get to this today
@tparisi any movement here? We want to finalize our implementation (both COLLADA2GLTF and Cesium).
@pjcozzi Need some input:
@pjcozzi ok taking another look at Blinn and clearing up the language.
@pjcozzi Simplified Blinn language, I think this is right. 12910f7
@pjcozzi Simplified Blinn language, I think this is right. 12910f7
This is perfect!
@pjcozzi Great. Checked that one off the list.
On to the final two issues. I'm still not convinced. Please pow-wow with @tfili
- [ ] Expand parameter values - https://github.com/KhronosGroup/glTF/issues/424#issuecomment-148774205
I still agree with this. For example, this:
"KHR_materials_common" : {
"technique" : "PHONG",
"values": {
"diffuse": [ 1, 1, 0, 1]
}
}
would become:
"KHR_materials_common" : {
"technique" : "PHONG",
"values": {
"diffuse": {
"value": [ 1, 1, 0, 1],
"type": 35666 // FLOAT_VEC4
}
}
}
This avoids the implicit type checks in the code example above, which we do not rely on anywhere else in glTF (everything has an explicit type
). I'm surprised you haven't ran into this in Three.js. For example, how does the code know the difference between a constant diffuse value and a diffuse texture?
I would also consider renaming values
to parameters
since this has much better symmetry with techniques than materials, which is OK. The older details
approach still had a technique
- now we do not.
@tfili for this one:
List attributes (could be part of the above) - #424 (comment)
Instead of explicitly listing the attributes as I suggested or searching the meshes/primitives as our implementation does now, could the extension spec specify that:
CONSTANT
lighting requires only POSITION
attributes.LAMBERT
, BLINN
, and PHONG
require POSITION
and NORMAL
attributes.In any case where a parameter is a string (e.g., a texture), then TEXCOORD_0
attribute is also required. Note that this could even happen for CONSTANT
since emission
can be a texture.
Given this (and ignoring skinning), couldn't the shaders be generated?
As for skinning, perhaps we could add a jointCount
property to the material, which is zero for no skinning, and non-zero with skinning?
@pjcozzi Adding a type sounds reasonable and it's not too onerous... but I still disagree in principle. If an implementation supports this extension, it should know what types to expect for each values and it should have built-in shaders to handle it.
Disagree about renaming values
, those are values they're not parameter descriptions. We have values
when techniques are instanced in the material, so the current proposal is symmetric to that.
I'm OK with the language about attributes.
Why do you need a jointCount?
it should know what types to expect for each values and it should have built-in shaders to handle it.
Yes, but it needs to know the type. The current approach is clunky, look at the code: https://github.com/KhronosGroup/glTF/issues/424#issuecomment-148774205
I'm OK with the language about attributes.
OK, let's wait for @tfili to confirm that it will work.
Why do you need a jointCount?
So the vertex shader can declare the maximum size of the attribute array.
I don't think having to do a typeof check is that big of a deal.
For the transparent
idea, why not just have a transparent
boolean on the material itself rather than a property of the texture? This would be separate from the transparency
value, just a flag that indicates to the engine to turn on alpha blending and alpha-sort the object.
I don't think having to do a typeof check is that big of a deal.
As I said above, it is not consistent with the rest of glTF - and is, well, a bit hacky.
For the transparent idea, why not just have a transparent boolean on the material itself rather than a property of the texture?
Might be OK. @tfili would this work?
@pjcozzi @tparisi Actually that may be better, since I don't care what texture has transparency, I just need to set the blend state correctly.
@tfili right and that's what you see in a lot of engines, a transparent
flag on the material itself. very simple so let's do that. It's separate from the transparency
flag which is the actual value to multiply the alpha by when you have RGB's.
@pjcozzi agreed, hacky. but balance this against verbosity of the JSON. that being said your latest https://github.com/KhronosGroup/glTF/issues/424#issuecomment-150708983 is a pretty concise way to do it.
@tfili right and that's what you see in a lot of engines, a transparent flag on the material itself.
Let's do it.
@pjcozzi agreed, hacky. but balance this against verbosity of the JSON. that being said your latest #424 (comment) is a pretty concise way to do it.
I agree it is reasonable. I suggest we do it and then I think we are good to go with this extension (other than finishing our implementations and the schema).
@pjcozzi OK you won me over. I'll start implementing when @tfili gives the go-ahead on converter and converted content.
Ok, that works for me. I'm working on the implementation now.
I've finished the converter and Cesium implementations. The things that should be updated in the spec are:
doubleSided
to the material (this was discussed and implemented before but never put in the spec).transparent
to the material.type
& value
@tparisi @pjcozzi Is there anything else?
Nothing else from me.
Hi @tfili good catches.
Do you or @pjcozzi definitively know the render states that go with both of these flags? If so I'll also add that language. Pretty sure it's CULL_FACE
disabled for doubleSided
, what about for transparency? I imagine it's a combo, please advise on spec language...
@tparisi see @tfili maps these to render states here: https://github.com/AnalyticalGraphicsInc/cesium/pull/3039/files#diff-8fd2167b1c1a0711731254f9aa4b45c9R532
@tfili @pjcozzi LMK when we have the models converted and I'll start on the Three.js loader. Are we doing it in master or the materials branch?
OK, we'll open a pull request into master with the models. The issue is #448.
I think the PR should be off the materials branch and then we'll merge back into master once everything is sorted out with the Three.js importer
OK, we'll target the pull request to the materials branch.
PR in #468
Just checked in language for doubleSided
and transparent
please review @pjcozzi
transparency
update looks good. doubleSided
needs to mention to flip the normal for backfacing triangles. For example, here is @tfili's implementation:
if (khrMaterialsCommon.doubleSided) {
fragmentShader += ' if (gl_FrontFacing == false)\n';
fragmentShader += ' {\n';
fragmentShader += ' normal = -normal;\n';
fragmentShader += ' }\n';
}
To finish this, I believe there are the following outstanding issues:
type
, #523
@tparisi @tfili @mlimper is there anything else?
I think that's it
We can close #510 and #509 - but #523 are we sure about removing type? see my comment
On Tue, Jan 12, 2016 at 1:36 AM, Max Limper notifications@github.com wrote:
I think that's it
— Reply to this email directly or view it on GitHub https://github.com/KhronosGroup/glTF/issues/424#issuecomment-170851864.
Tony Parisi tparisi@gmail.com Follow me on Twitter! http://twitter.com/auradeluxe Read my blog at http://www.tonyparisi.com/ Learn WebGL http://learningwebgl.com/ Mobile 415.902.8002 Skype auradeluxe
Read my books! Learning Virtual Reality http://www.amazon.com/Learning-Virtual-Reality-Experiences-Applications/dp/1491922834
Programming 3D Applications in HTML5 and WebGLhttp://www.amazon.com/Programming-Applications-HTML5-WebGL-Visualization/dp/1449362966 http://www.amazon.com/Programming-Applications-HTML5-WebGL-Visualization/dp/1449362966WebGL, Up and Running http://www.amazon.com/dp/144932357X
If it would be updated in the examples, it would facilitate implementation and increase compatibility (Basically, we are staying with your initial proposal https://github.com/KhronosGroup/glTF/issues/424#issuecomment-150713235)
We are going to update the samples, see https://github.com/KhronosGroup/glTF/issues/523#issuecomment-171015245
Hello! Does KHR_materials_common support normal map? I don't see the field in KHR_materials_common. Thank you~
It doesn't. It's meant to mimic Collada's common profile that supports basic lighting models (constant, lambert, blinn and phong). For more advanced techniques you'll have to provide shaders.
Thanks for your reply.
For more advanced techniques you'll have to provide shaders.
provide shaders? You mean that I should use the shader generated by gltf converter? Or How can I provide shader?
In my case, I just want to use my shader generated by my engine instead of using the shader provided by gltf converter. My shader supports normal map. So How can I read normap map data from .gltf file? Could you give me some suggestions? Thanks.
Hi YYC
You will need to create your own extension. Info here:
https://github.com/KhronosGroup/glTF/blob/master/extensions/README.md
Yours would be a "vendor extension."
I can envision that we would someday add normal maps to the common materials extension. So maybe you can think about designing your extension for eventual inclusion in a future version of the KHR_ extension. We can't make about promises about that right now, but please keep the idea in mind while you are designing your feature and let's talk about it soon...
OK, I get it, thanks a lot~
@McNopper OK to close as duplicate with #947 and #945?
I believe this it is OK to close this as now duplicate with #1163 and friends.
@donmccurdy please let me know if you think otherwise.
https://github.com/KhronosGroup/glTF/tree/KHR_materials_common/extensions/Khronos/KHR_materials_common
Comments:
1
and1.0
are used. Arrays are sometimes on the same line and sometimes one element per line.index_of_refraction
->indexOfRefraction
. glTF uses camel case for property names.constant_attenuation
,linear_attenuation
,falloff_angle
, andfalloff_exponent
.CONSTANT
needs all those properties? How is each used?FLOAT_VEC4
orSAMPLER_2D
-> In glTF, what is sampler 2D? Shouldn't this be a string (texture id)? We need to precisely define where the texture coordinates come from, e.g., if bothdiffuse
andspecular
are texures, do they use the same or different set of texture coordinates?technique
- why does this have a default? Perhaps it should be required. We should also make this separate from the table and say the table is for thevalues
object."relective": "texture_envmap"
- glTF does not support cube maps.Maybe, but I did to finish the core spec reference doc first. Will let you know later this week.