-
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
technique.parameter.type compatibility #789
Comments
My intention reaction was that it should match the value stored in the buffer. If, for example, the buffer has ints and the shader declares a float, how could we access the buffer values in JavaScript since glTF says they are floats when they are really ints? |
|
Ah, right. Yes, this clarification is good with me. It could go into 1.1, or even 1.0 if you prefer. |
@pjcozzi This naturally leads us to the next question: right now, with glTF 1.1 attribute parameters can have only {
"techniques" : {
"technique_id" : {
"parameters": {
"ambient": {
"type": 35666,
},
"diffuse": {
"type": 35678
},
"modelViewMatrix": {
"semantic": "MODELVIEW",
"type": 35676
},
"projectionMatrix": {
"semantic": "PROJECTION",
"type": 35676
},
"normalMatrix": {
"semantic": "MODELVIEWINVERSETRANSPOSE",
"type": 35675
},
"jointMatrix": {
"semantic": "JOINTMATRIX",
"type": 35676
}
},
"attributes": {
"a_position": "POSITION",
"a_normal": "NORMAL",
"a_texcoord0": "TEXCOORD_0",
"a_joint": "JOINT",
"a_weight": "WEIGHT"
},
"program": "program_id",
"uniforms": {
"u_ambient": "ambient",
"u_diffuse": "diffuse",
"u_modelViewMatrix": "modelViewMatrix",
"u_projectionMatrix": "projectionMatrix",
"u_normalMatrix": "normalMatrix",
"u_jointMatrix": "jointMatrix"
}
}
}
} |
It would be nice to get rid of the indirection. Cesium does use Do you think there is another way to achieve this? |
Sorry, but I see only uniform usages in that code. Or am I missing something? |
Ah, yes, I agree. It is not used in Cesium! |
I've found (made up) a very controversial case for Let's say we've got two meshes: the first one with vertex positions and vertex colors, while the second with vertex positions only. {
"meshes": {
"mesh_with_colors": {
"primitives": [
{
"attributes": {
"POSITION": "accessor_pos",
"COLOR_0": "accessor_col"
},
"material": "material0"
}
]
},
"mesh_without_colors": {
"primitives": [
{
"attributes": {
"POSITION": "accessor_pos2"
},
"material": "material0"
}
]
}
},
"materials": {
"material0": {
"technique": "technique0",
"values": {
"color": [0.8, 0.8, 0.8]
}
}
},
"techniques": {
"technique0": {
"parameters": {
"position": {
"semantic": "POSITION",
"type": 35665
},
"color": {
"semantic": "COLOR_0",
"type": 35665,
"value": [0.5, 0.5, 0.5]
}
},
"attributes": {
"a_pos": "position",
"a_col": "color"
},
"program": "program0"
}
}
} With such scheme, we would be able to use gl.vertexAttrib3fv(colorLocation, material.values.color); |
I didn't have
If this is right (and technically possible) then this looks like a very good reason to keep the parameter mapping (at least for me, and I'm curious what others think). Although such a generic attribute value at the first glance only makes sense for the color, I think that sophisticated shaders may have additional attributes that can optionally be fed with such a constant value. The alternatives would then be to create a (potentially large) accessor/bufferView that only contains constant value, or a definition of a (potentially complex) technique that only differs in how this single attribute is handled. |
That's correct.
Maybe, it's possible to reduce indirection (and simplify finding needed object) without compromising flexibility? |
I lean towards simplifying the spec and getting the breaking change into 1.1, but don't have a strong preference. |
@pjcozzi What's your perspective on "default" attribute values? Is it still the same? |
It is the same. Certainty useful for some cases, but perhaps not enough to justify it. |
Will the |
I don't think it is necessary. |
@lexaknyazev any actions left here? |
We'll revisit this (or similar) issue during WebGL extension development. |
via @lilleyse from CesiumGS/cesium#4684 (comment)
Couple things to consider here:
vertexAttribPointer
, all integers are converted to floats (exact conversion process depends on the value ofaccessor.normalized
).I propose to add following clarification:
parameter.type
accessor.type
float
GL_FLOAT
"SCALAR"
vec2
GL_FLOAT_VEC2
"VEC2"
vec3
GL_FLOAT_VEC3
"VEC3"
vec4
GL_FLOAT_VEC4
"VEC4"
mat2
GL_FLOAT_MAT2
"MAT2"
mat3
GL_FLOAT_MAT3
"MAT3"
mat4
GL_FLOAT_MAT4
"MAT4"
CC @pjcozzi
The text was updated successfully, but these errors were encountered: