Create a shader from a fragment snippet that defines void mainImage(out vec4 c, vec2 uv)
fragmentCode string
const fade = new Shader(`
void mainImage(out vec4 c, vec2 uv)
{
c = texture(iChannel0, uv);
float fade = .5 + .5*sin(iTime);
c.a *= fade;
if (premultipliedTexture) c.rgb *= fade; // a tile layer, or any image with tilesPixelated false
}`);
obj.shader = fade;
In 2D, write what mainImage gives as it is, with the draw's alpha, leaving out the
draw's color and additive color, for data rather than a picture, as the light system's normal pass does;
set it before the shader first draws, its program is built then
The 2D program, compiled by the first draw that needs it, read only
The 3D program, compiled by the 3D plugin the same way, read only
Let go of this shader: its compiled programs are freed and it leaves the engine's list of shaders, which
keeps every one made for a lost context, so a scene made again and again, or an editor trying snippets, does
not keep them all; calling it again does nothing, and a draw with it afterwards compiles it again and takes it
back, so only let go of one no object still draws with when it should stay freed