today, I start ready to learn write my own custom fragment shader in MaterialAppearance.But when I tried to pass user defined uniform color to custom fragment shader. Chrome tells me that color is undefined, how to pass it,please help!
here is my code:
var redColor = (56.0/255.0) + ((187.0/255.0) - (56.0/255.0))
Thank you for sharing this question with the community! To be candid, I do not have a lot of experience creating custom shaders. However, it seems like the best place to start would be to investigate how you are updating the color variable. For reference, here is our Color documentation
@sam.rothstein
Hi Sam, thanks for your answer.I have used the color variable like this and use it in MaterialAppearance.uniforms :
var redColor = (56.0/255.0) + ((187.0/255.0) - (56.0/255.0));
var greenColor = (139.0/255.0) + ((186.0/255.0) - (139.0/255.0));
var blueColor = (255.0/255.0) + ((236.0/255.0) - (255.0/255.0));
uniforms: {
testColor : new Cesium.Color(redColor,greenColor,blueColor,1.0)
},
But when i declare testColor in fragmentShaderSource as an uniform variable, program goes wrong and said “uniformMap[mu.name] is not a function”.Here’s my demo in sandcastle.
Well, in your shared example you’re creating uniforms for the Cesium.MaterialAppearance, but it doesn’t support that so that won’t work. I think the idea is to inject the shader into the same level where you’ve got a Fabric, that’s where the uniforms can be accessed. Haven’t played much with this part of Cesium, so grains of salt apply accordingly.