RawShaderMaterial does not use opacity

Description of the problem

RawShaderMaterial opacity is not used, even when the transparency flag is set. I have seen this issue in r84 & versions as far back as r78. I have mainly been using Chrome Version 56.0.2924.87 (64-bit), but saw this in Firefox for r84 as well. I expect my objects to use 50%% opacity if the opacity in the RawShaderMaterial is set.

I have a test html page that shows the issue. Note that the opacity & transparency are passed into the RawShaderMaterial yet the points render as solid blue:


<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/84/three.js"></script>
body { background-color: grey; }
#render canvas {border: 1px solid black; }

<div id="render"></div>

<script type="text/javascript">
    function drawDots(scene) {
        var vertices = new Float32Array( [-32, 0, 0, 32, 0, 0] );
        var geometry = new THREE.BufferGeometry();
        geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
        var shaders = {
            vertex: document.getElementById('rasterVertexShader').textContent,
            fragment: document.getElementById('rasterFragmentShader').textContent,
        var material = new THREE.RawShaderMaterial({
            uniforms:       {},
            vertexShader:   shaders.vertex,
            fragmentShader: shaders.fragment,
            transparent:    true,
            depthTest:      false,
            opacity:         0.5,
        material.side = THREE.DoubleSide;
        var mesh = new THREE.Points(geometry, material);
        mesh.frustumCulled = false;
        //TODO: Use groups

    function initRenderer() {
        var renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
        var div = document.getElementById('render');
        var camera = new THREE.PerspectiveCamera(90, 1, 1, 1000);
        camera.position.z = 256;
        var scene = new THREE.Scene();
        //var dpr = window.devicePixelRatio ? window.devicePixelRatio : 1;
        renderer.setSize(256, 256)
        camera.aspect = 1.0;
        return {
            renderer: renderer,
            scene: scene,
            camera: camera,

    document.addEventListener("DOMContentLoaded", function() {
        var renderer, scene, camera;
        var r = initRenderer();
        r.renderer.render(r.scene, r.camera);


<script type="x-shader/x-vertex" id="rasterVertexShader">

attribute vec3 position;

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;

void main() {
  vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
  gl_Position = projectionMatrix * mvPosition;;
  gl_PointSize = 64.0;

<script type="x-shader/x-fragment" id="rasterFragmentShader">
void main() {
  gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
Three.js version
  • r84

First noticed in r78, no data before that point.

  • Chrome
  • Firefox

Probably more

  • macOS

I believe I have seen this on Linux (Fedora) as well, but that was a while ago and not my computer.

Hardware Requirements (graphics card, VR Device, …)

I don’t believe it’s significant, but I am running on MacBook Pro (Retina, 15-inch, Late 2013) while using discrete only graphics NVIDIA GeForce GT 750M.

Author: Fantashit

1 thought on “RawShaderMaterial does not use opacity

Comments are closed.