L_Cayla
December 8, 2018, 10:53pm
1
Hi,
I have started using KHR_techniques_webgl in my gltf models and it works well so far on Cesium 1.50.
However I haven’t been able to find a way to change the uniform values so far. The material does not have a name apparently so I can’t call getMaterlal and therefore can’t access their values. In fact, I haven’t seen in the specs a name see :
"materials": [
{
"extensions": {
"KHR_techniques_webgl": {
"technique": 0,
"values" : {
"u_light0Color": [
0.8,
0.8,
1.0
]
}
}
}
}
]
Is there a way to achieve what I am trying to do (change uniform values of currently loaded model)? or am I missing something?
Thanks,
-Lionel
omar
December 11, 2018, 5:25pm
2
This seems like a missing feature as far as I can tell. You can see the engine actually keeps track of materials by ID here:
var gltf = model.gltf;
var buffers = gltf.buffers;
var bufferViews = gltf.bufferViews;
var sourceShaders = model._rendererResources.sourceShaders;
ForEach.shader(gltf, function(shader, id) {
// Shader references either uri (external or base64-encoded) or bufferView
if (defined(shader.bufferView)) {
var bufferViewId = shader.bufferView;
var bufferView = bufferViews[bufferViewId];
var bufferId = bufferView.buffer;
var buffer = buffers[bufferId];
var source = getStringFromTypedArray(buffer.extras._pipeline.source, bufferView.byteOffset, bufferView.byteLength);
sourceShaders[id] = source;
} else if (defined(shader.extras._pipeline.source)) {
sourceShaders[id] = shader.extras._pipeline.source;
} else {
++model._loadResources.pendingShaderLoads;
var shaderResource = model._resource.getDerivedResource({
url: shader.uri
});
But doesn’t expose a way to get it. Feel free to open up a feature request on the GitHub issues (https://github.com/AnalyticalGraphicsInc/cesium/issues ) to request this.
As a workaround, you could modify the glTF to give the material a name so you can access it.