I wish to pass a float type value of ‘u_time’ from ‘material’ into ‘fragment shader’ as a uniform. However, when ‘u_time’ is utilized in ‘fragment shader’, an error occurs. I have provided the primary code and error message below. Could you identify any mistakes in this transfer method?
let material = new Cesium.Material({
fabric: {
type: 'Flow',
uniforms: {
image: '../image/blank.jpg',
time: 0.0,
u_time: 0.0,
},
source: `
czm_material czm_getMaterial(czm_materialInput materialInput) {
czm_material material = czm_getDefaultMaterial(materialInput);
...
material.diffuse = texture2D(image, newCoords).rgb;
return material;
}
`
}
});
let fs = getFS();
function getFS() {
source = `
uniform float u_time;
void main() {
czm_materialInput materialInput;
vec2 uv = gl_FragCoord.xy;
uv.y += u_time;
}
`;
return source;
}
viewer.scene.primitives.add(new Cesium.Primitive({
geometryInstances: coneInstance,
appearance: new Cesium.Appearance({
material: material,
renderState: {
blending: Cesium.BlendingState.ALPHA_BLEND,
depthTest: {
enabled: true
},
cull: {
enabled: true,
face: Cesium.CullFace.BACK
},
depthMask: true,
},
fragmentShaderSource: fs,
vertexShaderSource : vs,
}),
}));