I have a relatively simple setup with custom shader and a custom blend mode:
- A
Sceneand aPerspectiveCamera - An
IcosahedronBufferGeometry - A custom
new THREE.ShaderMaterialwith custom shaders - Some
new THREE.Pointswith the icosahedron and that custom shader material
My shader material has a custom blend mode:
shaderMaterial.blending = THREE.CustomBlending;
shaderMaterial.blendSrc = THREE.OneFactor;
shaderMaterial.blendDst = THREE.OneFactor;
shaderMaterial.blendEquation = THREE.AddEquation;
and my fragment shader currently only does this:
gl_FragColor = vec4(0.0, 0.1, 0.0, 0.0);
Since I'm rendering into a fully black canvas, the expected color of drawn points should be, considering the blending mode:
SRC DST
r = 0 r = 0 r = 0
g = 0.1 * 1.0 + g = 0 * 1.0 = g = 0.1
b = 0 b = 0 b = 0
However, I get a totally different result:

The points are rendered much more brightly than the expected 0.1. Using
gl_FragColor = vec4(0.0, 0.2, 0.0, 0.0);
the points become fully saturated (g = 255).
What causes this? I have some ideas and hopefully can push me in the right direction.
- Perhaps three.js appends some code to my fragment shader, modifying the
gl_FragColor? - Maybe I'm not aware of some extra rendering / post processing step that three.js does?
- Maybe I've misunderstood the math regarding blending modes?
- Maybe there is some implementation error in three.js?
- Perhaps it's a browser / canvas / color space thing? (However, I cannot imagine any transformation that causes a green value of 0.2 to become fully saturated (255) in any color space transformation!)
Any help would be greatly appreciated. Thanks!
premultipliedAlphaon or off?premultipliedAlphadefault istrue! It matters. See WebGL and Alphagl.POINTSinstead ofgl.TRIANGLESthen every point is going to be drawn 5 times since every point is used by 5 triangles.premultipliedAlphaproperty ofMaterialwhich defaults to false and, I believe, shouldn't influence CustomShaders that don't implement them... I will look into this resource and report back, thanks!