vec4 color;
vec4 diffuse;
float alpha;
// diffuse
diffuse = texture2D(u_diffuse, v_texcoord0);
// sum
alpha = diffuse.x; // take alpha from red channel
color = vec4(vec3(1.0, 1.0, 1.0) * alpha, alpha); // pre multiply alpha
gl_FragColor = color;
}
**3. Context. Why do you need to do this? We might know a better way to accomplish your goal.**
I use this shader to generate opacity from a JPG file without alpha channel
**4. The Cesium version you're using, your operating system and browser.**
Cesium 1.50 on Windows10/Chrome
Which mainly support more extensions, so I’m not sure off the top of my head what would have caused this. If you can share a Sandcastle or just a code snippet I can run across the versions that’ll help.
I see what you mean now. I did a little bit of digging, and looks like this was a breaking change that slipped through the cracks and wasn’t mentioned in CHANGES.md. I opened a bug report with a bit more detail here:
This was driven by glTF 2 not supporting premultiplied alpha. But since this is a breaking change I think it might be something worth fixing (or at the very least mentioning it in CHANGES). For your case, it looks like changing this line:
color = vec4(vec3(1.0, 1.0, 1.0) * alpha, alpha); // pre multiply alpha
``
to:
color = vec4(vec3(1.0, 1.0, 1.0), alpha);
``
Makes it look as intended? Does that look right to you?