Skip to content
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

glTF 2.0: New/modified KHR_materials_common extension #947

Closed
McNopper opened this issue May 7, 2017 · 66 comments
Closed

glTF 2.0: New/modified KHR_materials_common extension #947

McNopper opened this issue May 7, 2017 · 66 comments

Comments

@McNopper
Copy link
Contributor

McNopper commented May 7, 2017

Using the pbrMetallicRoughness and pbrSpecularGlossiness material "syntax", I have adapted the common materials. Again here by example:

{
  "materials": [
    {
      "commonConstant": {
        "ambientFactor": [
          0.2,
          0.2,
          0.2
        ]
      }
    },
    {
      "commonLambert": {
        "ambientFactor": [
          0.2,
          0.2,
          0.2
        ],
        "diffuseFactor": [
          1,
          1,
          1,
          1
        ],
        "diffuseTexture": 0
      }
    },
    {
      "commonPhong": {
        "ambientFactor": [
          0.2,
          0.2,
          0.2
        ],
        "diffuseFactor": [
          1,
          1,
          1,
          1
        ],
        "diffuseTexture": 0,
        "specularFactor": [
          1,
          1,
          1,
          1
        ],
        "specularTexture": 1,
        "shininessFactor": 0.5,
        "shininessTexture": 2
      }
    },
    {
      "commonBlinn": {
        "ambientFactor": [
          0.2,
          0.2,
          0.2
        ],
        "diffuseFactor": [
          1,
          1,
          1,
          1
        ],
        "diffuseTexture": 0,
        "specularFactor": [
          1,
          1,
          1,
          1
        ],
        "specularTexture": 1,
        "shininessFactor": 0.5,
        "shininessTexture": 2
      }
    }
  ]
}

Like the current PBR materials, they extend the "base" materials. So e.g. emissive would be inherited.

@stevenvergenz
Copy link

@McNopper Is this update work happening in public anywhere? I'm looking to implement these types in the UnityGLTF project, as they seem easier to work with on mobile than pbrMetallicRoughness.

@McNopper
Copy link
Contributor Author

McNopper commented May 25, 2017 via email

@stevenvergenz
Copy link

I've added a tentative lightmap implementation to the commonConstant material in UnityGLTF, since we use pre-computed lighting more routinely than PBR. What it looks like:

{
    "alphaMode" : "MASK",
    "doubleSided" : true,
    "emissiveFactor" : [
        0.0,
        1.0,
        0.0
    ],
    "emissiveTexture" : {
        "index" : 1
    },
    "name" : "Material",
    "commonConstant" : {
        "lightmapTexture": {
           "index": 0,
           "texCoord": 1
        }
    }
}

@McNopper
Copy link
Contributor Author

McNopper commented Jun 3, 2017

Does the lightmapTexture make sense in commonConstant, as its inflcuence is on the diffuse part? In my opinion it should be restricted to commonLambert, commonBlinn and commonPhong.

@stevenvergenz
Copy link

In the case of the constant material, a lightmap is simply a multiply texture, but is still incredibly useful to my use cases. It gives you the ability to 1) have multiple variations of emissive textures without having to bake lighting onto them, 2) specify a separate UV channel, so you can vary the lightmap texel resolution w.r.t. the emissive texture.

@McNopper
Copy link
Contributor Author

McNopper commented Jun 5, 2017

Ah, I see. Do you know, if other engines do have the same approach? Or it could be "easily" implemented?

@stevenvergenz
Copy link

I'm sure light maps as multiply textures are easy to implement on Unity and Three.js, as those are the platforms I use. Not sure about any others.

@donmccurdy
Copy link
Contributor

lightmaps are implemented in threejs, multiplied against indirect diffuse: https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl

@McNopper
Copy link
Contributor Author

McNopper commented Jun 5, 2017

Steven, seems my original assumption is correct. The lightmap is just applied to the diffuse part.
As this is probably the "normal" approach, we should go for this solution,

Can we make for your approach another extension?
Can you please post an image, to better understand your approach?

@stevenvergenz
Copy link

I don't want to derail this issue, which is meant for the materials definition. I'll write up a new issue with my proposal, we can discuss it there.

@UX3D-nopper
Copy link
Contributor

Same with the current status of the common materials:

{
    "accessors" : [
        {
            "bufferView" : 0, 
            "componentType" : 5121, 
            "count" : 36, 
            "max" : [
                23
            ], 
            "min" : [
                0
            ], 
            "type" : "SCALAR"
        }, 
        {
            "bufferView" : 1, 
            "componentType" : 5126, 
            "count" : 24, 
            "max" : [
                1.0, 
                1.0, 
                1.0
            ], 
            "min" : [
                -1.0, 
                -1.0, 
                -1.0
            ], 
            "type" : "VEC3"
        }, 
        {
            "bufferView" : 2, 
            "componentType" : 5126, 
            "count" : 24, 
            "max" : [
                1.0, 
                1.0, 
                1.0
            ], 
            "min" : [
                -1.0, 
                -1.0, 
                -1.0
            ], 
            "type" : "VEC3"
        }, 
        {
            "bufferView" : 3, 
            "componentType" : 5126, 
            "count" : 24, 
            "max" : [
                1.0, 
                0.0, 
                0.0, 
                1.0
            ], 
            "min" : [
                0.0, 
                0.0, 
                -1.0, 
                1.0
            ], 
            "type" : "VEC4"
        }, 
        {
            "bufferView" : 4, 
            "componentType" : 5126, 
            "count" : 24, 
            "max" : [
                1.0, 
                2.0
            ], 
            "min" : [
                -1.0, 
                0.0
            ], 
            "type" : "VEC2"
        }, 
        {
            "bufferView" : 5, 
            "componentType" : 5121, 
            "count" : 6, 
            "max" : [
                3
            ], 
            "min" : [
                0
            ], 
            "type" : "SCALAR"
        }, 
        {
            "bufferView" : 6, 
            "componentType" : 5126, 
            "count" : 4, 
            "max" : [
                1.0, 
                0.0, 
                1.0
            ], 
            "min" : [
                -1.0, 
                0.0, 
                -1.0
            ], 
            "type" : "VEC3"
        }, 
        {
            "bufferView" : 7, 
            "componentType" : 5126, 
            "count" : 4, 
            "max" : [
                0.0, 
                1.0, 
                -0.0
            ], 
            "min" : [
                0.0, 
                1.0, 
                -0.0
            ], 
            "type" : "VEC3"
        }, 
        {
            "bufferView" : 8, 
            "componentType" : 5123, 
            "count" : 2880, 
            "max" : [
                503
            ], 
            "min" : [
                0
            ], 
            "type" : "SCALAR"
        }, 
        {
            "bufferView" : 9, 
            "componentType" : 5126, 
            "count" : 504, 
            "max" : [
                1.000000238418579, 
                1.0, 
                1.0000003576278687
            ], 
            "min" : [
                -0.9999998211860657, 
                -1.0, 
                -0.9999991655349731
            ], 
            "type" : "VEC3"
        }, 
        {
            "bufferView" : 10, 
            "componentType" : 5126, 
            "count" : 504, 
            "max" : [
                1.0, 
                1.0, 
                1.0
            ], 
            "min" : [
                -1.0, 
                -1.0, 
                -1.0
            ], 
            "type" : "VEC3"
        }, 
        {
            "bufferView" : 11, 
            "componentType" : 5126, 
            "count" : 504, 
            "max" : [
                0.9520357251167297, 
                0.9904618263244629, 
                0.3444094955921173, 
                1.0
            ], 
            "min" : [
                -0.9512326121330261, 
                -0.9901572465896606, 
                -0.34139394760131836, 
                1.0
            ], 
            "type" : "VEC4"
        }, 
        {
            "bufferView" : 12, 
            "componentType" : 5126, 
            "count" : 504, 
            "max" : [
                1.2534546852111816, 
                0.97004634141922
            ], 
            "min" : [
                0.0013766288757324219, 
                0.029953598976135254
            ], 
            "type" : "VEC2"
        }
    ], 
    "asset" : {
        "generator" : "Khronos Blender glTF 2.0 exporter", 
        "version" : "2.0"
    }, 
    "bufferViews" : [
        {
            "buffer" : 0, 
            "byteLength" : 36, 
            "byteOffset" : 0, 
            "target" : 34963
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 288, 
            "byteOffset" : 36, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 288, 
            "byteOffset" : 324, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 384, 
            "byteOffset" : 612, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 192, 
            "byteOffset" : 996, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 6, 
            "byteOffset" : 1188, 
            "target" : 34963
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 48, 
            "byteOffset" : 1194, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 48, 
            "byteOffset" : 1242, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 5760, 
            "byteOffset" : 1290, 
            "target" : 34963
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 6048, 
            "byteOffset" : 7050, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 6048, 
            "byteOffset" : 13098, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 8064, 
            "byteOffset" : 19146, 
            "target" : 34962
        }, 
        {
            "buffer" : 0, 
            "byteLength" : 4032, 
            "byteOffset" : 27210, 
            "target" : 34962
        }
    ], 
    "buffers" : [
        {
            "byteLength" : 31242, 
            "uri" : "04_common_materials.bin"
        }
    ], 
    "cameras" : [
        {
            "name" : "Camera", 
            "perspective" : {
                "aspectRatio" : 1.703595982340029, 
                "yfov" : 0.5033799409866333, 
                "zfar" : 100.0, 
                "znear" : 0.10000000149011612
            }, 
            "type" : "perspective"
        }
    ], 
    "extensions" : {
        "KHR_lights" : {
            "lights" : [
                {
                    "color" : [
                        1.0, 
                        1.0, 
                        1.0
                    ], 
                    "name" : "Directional", 
                    "type" : "directional"
                }, 
                {
                    "color" : [
                        0.0, 
                        0.0, 
                        0.0
                    ], 
                    "name" : "Ambient_Scene", 
                    "type" : "ambient"
                }
            ]
        }
    }, 
    "extensionsRequired" : [
        "KHR_materials_common", 
        "KHR_lights"
    ], 
    "extensionsUsed" : [
        "KHR_materials_common", 
        "KHR_lights"
    ], 
    "images" : [
        {
            "uri" : "04_crate.png"
        }
    ], 
    "materials" : [
        {
            "emissiveFactor" : [
                0.0, 
                0.0, 
                0.0
            ], 
            "extensions" : {
                "KHR_materials_common" : {
                    "ambientFactor" : [
                        1.0, 
                        1.0, 
                        1.0
                    ], 
                    "diffuseFactor" : [
                        1.0, 
                        1.0, 
                        1.0, 
                        1.0
                    ], 
                    "diffuseTexture" : {
                        "index" : 0
                    }, 
                    "shininessFactor" : 12.298039215686275, 
                    "specularFactor" : [
                        0.0, 
                        0.0, 
                        0.0
                    ], 
                    "type" : "commonPhong"
                }
            }, 
            "name" : "Crate"
        }, 
        {
            "emissiveFactor" : [
                0.0, 
                0.0, 
                0.0
            ], 
            "extensions" : {
                "KHR_materials_common" : {
                    "ambientFactor" : [
                        1.0, 
                        1.0, 
                        1.0
                    ], 
                    "diffuseFactor" : [
                        0.800000011920929, 
                        0.800000011920929, 
                        0.800000011920929, 
                        1.0
                    ], 
                    "shininessFactor" : 12.298039215686275, 
                    "specularFactor" : [
                        0.5, 
                        0.5, 
                        0.5
                    ], 
                    "type" : "commonPhong"
                }
            }, 
            "name" : "Plane"
        }, 
        {
            "emissiveFactor" : [
                0.0, 
                0.0, 
                0.0
            ], 
            "extensions" : {
                "KHR_materials_common" : {
                    "ambientFactor" : [
                        1.0, 
                        1.0, 
                        1.0
                    ], 
                    "diffuseFactor" : [
                        0.6400000190734865, 
                        0.0, 
                        0.0, 
                        1.0
                    ], 
                    "shininessFactor" : 12.298039215686275, 
                    "specularFactor" : [
                        0.5, 
                        0.5, 
                        0.5
                    ], 
                    "type" : "commonPhong"
                }
            }, 
            "name" : "Sphere"
        }
    ], 
    "meshes" : [
        {
            "name" : "Cube", 
            "primitives" : [
                {
                    "attributes" : {
                        "NORMAL" : 2, 
                        "POSITION" : 1, 
                        "TANGENT" : 3, 
                        "TEXCOORD_0" : 4
                    }, 
                    "indices" : 0, 
                    "material" : 0
                }
            ]
        }, 
        {
            "name" : "Plane", 
            "primitives" : [
                {
                    "attributes" : {
                        "NORMAL" : 7, 
                        "POSITION" : 6
                    }, 
                    "indices" : 5, 
                    "material" : 1
                }
            ]
        }, 
        {
            "name" : "Sphere", 
            "primitives" : [
                {
                    "attributes" : {
                        "NORMAL" : 10, 
                        "POSITION" : 9, 
                        "TANGENT" : 11, 
                        "TEXCOORD_0" : 12
                    }, 
                    "indices" : 8, 
                    "material" : 2
                }
            ]
        }
    ], 
    "nodes" : [
        {
            "camera" : 0, 
            "name" : "Correction_Camera", 
            "rotation" : [
                -0.7071067690849304, 
                -0.0, 
                0.0, 
                0.7071067690849304
            ]
        }, 
        {
            "children" : [
                0
            ], 
            "name" : "Camera", 
            "rotation" : [
                0.5730898976325989, 
                0.0, 
                -0.0, 
                0.8194926381111145
            ], 
            "translation" : [
                0.0, 
                12.0, 
                30.0
            ]
        }, 
        {
            "mesh" : 0, 
            "name" : "Cube", 
            "translation" : [
                0.0, 
                1.0, 
                -0.0
            ]
        }, 
        {
            "extensions" : {
                "KHR_lights" : {
                    "light" : 0
                }
            }, 
            "name" : "Correction_Directional", 
            "rotation" : [
                -0.7071067690849304, 
                -0.0, 
                0.0, 
                0.7071067690849304
            ]
        }, 
        {
            "children" : [
                3
            ], 
            "name" : "Directional", 
            "rotation" : [
                0.3535533845424652, 
                -0.3535533845424652, 
                0.1464466005563736, 
                0.8535534143447876
            ], 
            "scale" : [
                0.9999999403953552, 
                1.0, 
                0.9999999403953552
            ], 
            "translation" : [
                -8.0, 
                4.0, 
                8.0
            ]
        }, 
        {
            "mesh" : 1, 
            "name" : "Plane", 
            "scale" : [
                10.0, 
                10.0, 
                10.0
            ]
        }, 
        {
            "mesh" : 2, 
            "name" : "Sphere", 
            "translation" : [
                4.0, 
                1.0, 
                -0.0
            ]
        }
    ], 
    "samplers" : [
        {}
    ], 
    "scene" : 0, 
    "scenes" : [
        {
            "extensions" : {
                "KHR_lights" : {
                    "light" : 1
                }
            }, 
            "name" : "Scene", 
            "nodes" : [
                6, 
                2, 
                5, 
                4, 
                1
            ]
        }
    ], 
    "textures" : [
        {
            "sampler" : 0, 
            "source" : 0
        }
    ]
}

@donmccurdy
Copy link
Contributor

donmccurdy commented Jun 9, 2017

This looks reasonable to me — @UX3D-nopper are you able to share a complete model (with the .bin and textures) in this format, or is this structure not reflected in the Blender exporter yet? I'd like to mock up an implementation in three.js.

@UX3D-nopper
Copy link
Contributor

You can use this scene:
https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/scenes/04_common_materials.blend
Also, set in the experimental section the common material to 'Phong'.

Basically, every scene based on Blender Render materials can be exported like that.

@mlimper
Copy link
Contributor

mlimper commented Jun 14, 2017

Hey, great to see this!

Just my 0.02$, after thinking again about this material model:

Comparing to the PBR one, the materials_common model should be as simple as possible - which is also what @stevenvergenz names as a motivation to implement it (in this case for mobile):

I'm looking to implement these types [...], as they seem easier to work with on mobile than pbrMetallicRoughness.

Apart from that, I think one reason why it might be nice to have it is that many "traditional" pipelines and viewers (such as X3D viewers) built on a common model that became popular through standardization in the old OpenGL fixed function pipeline, offering ambient, diffuse, and specular material properites.
I think the standard OpenGL implementation would use Blinn (with halfway vector, as opposed to Phong with reflected view vector), but I'd need to check again. My main point here is:
Instead of offering to choose between Blinn and Phong, it could ease adaption to just limit this model to one of them (-> probably rather use Blinn?). In our CAD review apps, we clearly just use one of them (blinn), and there is no need to have two slightly different models for specularity.
Also, I would guess that, if people want more sophisticated materials, they will use the PBR model anyway.

Again, just my opinion, you know I'm not a material expert - wondering if anyone had similar thoughts on this?

@McNopper
Copy link
Contributor Author

I personally think, we should call the common material just Phong or Blinn and "kick" out *Lambert and *Constant, as they can be described by using zero factors in Phong and/or Blinn.
I also agree, that we should take either the Blinn or Phong formula, as this would simplify the whole material.

If someone wants to use sophisticated materials, one is using PBR nowadays anyway.

Also, regarding PBR, we also did not fully specify(?), which terms should be used in the BRDF formula, see
http://simonstechblog.blogspot.de/2011/12/microfacet-brdf.html

@pjcozzi
Copy link
Member

pjcozzi commented Jun 15, 2017

I personally think, we should call the common material just Phong or Blinn and "kick" out *Lambert and *Constant, as they can be described by using zero factors in Phong and/or Blinn.

+1 from me. I think the original extension basically just copied COLLADA, which was not as simple as possible.

@pjcozzi
Copy link
Member

pjcozzi commented Jun 15, 2017

My main point here is:
Instead of offering to choose between Blinn and Phong, it could ease adaption to just limit this model to one of them (-> probably rather use Blinn?). In our CAD review apps, we clearly just use one of them (blinn), and there is no need to have two slightly different models for specularity.
Also, I would guess that, if people want more sophisticated materials, they will use the PBR model anyway.

Let's get more input here. It would be great to simplify this, but will it create challenges for exporters or runtimes?

@lexaknyazev @bghgary @javagl?

@javagl
Copy link
Contributor

javagl commented Jun 15, 2017

Due to a limited understanding of the technical implications (also for the application cases, or even details like shader performance), I don't have a strong opinion here, but iff I understood this correctly, then

  • Blinn can approximately emulate Phong (by using a higher exponent)
  • Phong and Blinn can both emulate Lambert and Constant (by using some zero factors)

Then, one could only support Blinn, because it is a good trade-off between simplicity and power (in terms of capability to emulate the others). It would be nice if the differences could be covered with default values. I'll have to re-read some details, but ... wouldn't it be possible to boil this down to something like this (roughly equivalent to what @McNopper posted initially) :

materials : [

  // This is a "constant" material, because all other values are 0.0
  {
    ambient: [1,0,0,0].
  },

  // This is a "lambert" material, because all other values are 0.0
  {
    abmient: [1,0,0,0].
    diffuse: [1,0,0,0].
  },

  // This is a "blinn" material, because all other values are 0.0
  {
    abmient: [1,0,0,0].
    diffuse: [1,0,0,0].
    specular: [1,0,0,0].
    shininess: 10 // Multiply this by 4 to approximate "phong"
  },
]

Or more specifically: Is it worth to differentiate between

  "commonConstant": {
  "commonLambert": {
  "commonPhong": {
  "commonBlinn": {

when the shader implementation will basically be the same in all cases?

@donmccurdy
Copy link
Contributor

An implementation note from three.js: we do not have an ambient property in our Phong shader. It was removed (mrdoob/three.js#6501) and is now inferred from diffuse, because (1) having both caused confusion for some users, and (2) it more closely resembles physical materials.

Instead of offering to choose between Blinn and Phong, it could ease adaption to just limit this model to one of them (-> probably rather use Blinn?).

Can Phong approximate Blinn? I'm not sure I understand the difference, THREE.MeshPhongMaterial implements a "Blinn-Phong" model. Other than that confusion, +1 on the idea of having a single model, assuming it is OK for exporters.

@McNopper
Copy link
Contributor Author

I think we should just support Blinn-Phong, as if an engine does support non-PBR, in most (all?) cases it is this shading model.
So, let's define and finalize commonBlinnPhong. If at a later point of time someone really needs Phong, we can still add it as another extension - like we did for pbrSpecularGlossiness.

jamesgk added a commit to jamesgk/assimp that referenced this issue Jul 3, 2017
This is now using the structure from
KhronosGroup/glTF#947 (comment),
though perhaps liable to change soon this is what's currently used by
Three.js.
@steveghee
Copy link

From what I can pick up form this thread (and related), you seem to be converging on a model which effectively does the following

diffuseTerm = * ? // extension ; texture is optional.
specularTerm = * ? // extension
shineTerm = * ? // extension
emissiveTerm = * ? // part of core Materials spec

Textures are optional, and if provided, will modulate the base Factor value?

color = emissiveTerm +
ambientFactor * aL +
diffuseTerm * max(N * L, 0) +
specularTerm * max(H * N, 0)^shineTerm

where N (normal) can be geometric or can be provided by tangent-space normalTexture (part of core material spec).

Is that a fair assessment?
I like this model as it is simple (to generate and implement) and covers most cases.

I ask because we're building a pipeline and viewer based around glTF2.0 and we've got a ton of 'old' (pre-PBR) model data which we'd like to get converted, and it would be nice to have a clear definition to build against.

@UX3D-nopper
Copy link
Contributor

Basically. it is what you have written, but the ambientTerm/ambientFactor is equal to the diffuseTerm:
color = emissiveTerm +
diffuseTerm * aL +
diffuseTerm * max(N * L, 0) +
specularTerm * max(H * N, 0)^shineTerm

Please also have a look at the Khrons Blender glTF 2.0 exporter:
https://github.com/KhronosGroup/glTF-Blender-Exporter
During export, you can enable experimental Blinn-Phong export.

@steveghee
Copy link

Thanks for confirming.

Interesting decision to drop ambient and replace with fixed diffuse term. Will be interesting to see how that looks.

And just to double check, textures will multiply, not add/replace?
Texture modulation is pretty typical for diffuse (red plastic, green plastic etc.) but its not clear from the spec if these will be modulated, or if the texture replaces the factor term. Perhaps it is modulate for diffuse, replace for all others? Hopefully the final spec can make this clear e.g. write the full equation out pseudo-fashion as I did above.

@andreasplesch
Copy link
Contributor

Here is a nomenclature comment concerning 'Blinn', 'Phong', 'BlinnPhong' which is probably the result of my ignorance but which I could not resolve after going through the Blinn, 1977 paper:
http://dl.acm.org/citation.cfm?id=563893
https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common#blinn cites a formula which in the paper is actually being attributed to Phong, 1975. So this is confusing. My working hypothesis is that the formula is a streamlined reformulation of the original Phong, 1975, formulation and is what elsewhere is referred to as 'BlinnPhong' ? So this would mean that 'Blinn' (in the draft) and 'BlinnPhong' (here) refers to the same method ?
https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common#phong is then perhaps the original Phong, 1975 formulation ? But then why have two essentially identical techniques ? (Perhaps for historical reasons).
Finally, the Blinn, 1977 paper actually is about and promotes the Torrance-Sparrow, 1967 model. So 'Blinn' in discussions may actually refer to 'Blinn-Torrance-Sparrow'?
Since 'Blinn-Torrance-Sparrow' was mentioned here, should it become a distinct Material Common extension ?
It looks like this extension will be exclusively about a single shading method, eg. 'BlinnPhong'. I thought providing the formula and shininess implementation note in the current draft were very helpful to minimize confusion.

@McNopper
Copy link
Contributor Author

McNopper commented Aug 8, 2017

I did not do so much deep research, but it will be the Blinn-Phong lighting model, as it is the default shading model for - fixed - OpenGL and DirectX:
https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model
People are "visually" used to it.

For the future, if someone really needs Phong:
https://en.wikipedia.org/wiki/Phong_reflection_model
we can create the cmnPhong extension.

But from my undersatnding, in the old spec, Blinn should be called BlinnPhong. So the Blinn in the old spec will be BlinnPhong in the current/future one.

Also, it seems that you already invested much time in it. So my suggestion:
Fork my repo, add your name and your specification elements you want to have in. Make a pull request to the offical repository and finally we can end this discussion :-)

@andreasplesch
Copy link
Contributor

Thanks for the links which confirm what I had started to put together.
Well, it looks like if you have to start to work with shaders and want to understand what some code is trying to do, you end up with reading the source texts anyways.
Not sure if there is a need to end discussions but I can see if I can add anything to the existing language. Incremental improvement may be an appropriate strategy.

@andreasplesch
Copy link
Contributor

@McNopper : see https://github.com/UX3D-nopper/glTF/pull/1 . By official repo, did you mean this repo here ?

@McNopper
Copy link
Contributor Author

Official repo is this one:
https://github.com/KhronosGroup/glTF/

Process is like this: You make a fork, make changes and then do a pull request to the official, original one.
If the changes are merged, the spec will be reviewed for ratification.

@stevepg
Copy link

stevepg commented Aug 15, 2017

not sure i've seen this discussed in any thread, but is the 'technique' really needed for materials_common? With the correct default values, blinn, constant and lambert are all achievable by simply providing the appropriate values e.g. if you want 'constant' (baked) material effect, simply provide the emissiveFactor/texture values ; the other terms will multiply out to 0.

@McNopper
Copy link
Contributor Author

@steveghee
Copy link

@McNopper - do you want us to fork this one or fork the master?

@McNopper
Copy link
Contributor Author

Please work on this one, as far as I know this is the latest one. Like the light extension, of course still some stuff to specify.

@andreasplesch
Copy link
Contributor

andreasplesch commented Aug 16, 2017

#1075 is https://github.com/UX3D-nopper/glTF/pull/1 against this repo.

@stevepg
Copy link

stevepg commented Sep 12, 2017

there appear t be two KHR_common material definitions ongoing.
we have a working exporter but need to know which format to generate. Can i just double check - is this the latest : https://github.com/UX3D-nopper/glTF/tree/master_lights_blinnphong/extensions/Khronos/KHR_materials_cmnBlinnPhong

@donmccurdy
Copy link
Contributor

@stevepg the page you link to is the latest, yes. Viewers do not support this yet, and some spec discussion is ongoing, so it may be a bit early to implement that extension yet.

@donmccurdy
Copy link
Contributor

donmccurdy commented Sep 12, 2017

@stevepg
Copy link

stevepg commented Sep 12, 2017

@donmccurdy i have my own viewer and i need to get test data into it asap so i might need to punt on one of these. Personally i think cmnBlinnPhong is good enough for what we need - i think its better to have the material typed like this, instead of a generic _common with a type=blabla field.

I don't see much discussion on the specs to be honest ; there were questions a few weeks back, folks asked for input, there are pull requests waiting with that feedback.

@donmccurdy
Copy link
Contributor

Oops, #1075 is the one I meant to reference. There are more recent comments there. What I mean to say is that it's not necessarily decided yet whether KHR_materials_cmnBlinnPhong or KHR_materials_common will be ratified, more likely the first after some further changes, but it will only be one or the other.

I would advise against putting either into a publicly-available exporter without at least an "experimental" option to enable/disable the extension, to avoid circulation of invalid models. The Blender exporter does something along these lines now.

@stevepg
Copy link

stevepg commented Sep 12, 2017

this is internal so i'm not worried about models getting out there. not yet. thanks for the pointer to the other thread. i'll head over there....

@McNopper
Copy link
Contributor Author

Closing, as discussed in several threads.

@chipweinberger
Copy link

What is the current state of this extension? Which viewers support it and what format are they using? Thanks!

@donmccurdy
Copy link
Contributor

I know you saw this already @chipweinberger, but copying zellski's response (#1207 (comment)) here for future readers:

There's been copious discussion about what to replace KHR_common_materials with for glTF 2.0, e.g. #947 and #1095, culminating most immediately in #1163.

For lights, specifically, there's #945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests