Get transparency in WebGLRenderTarget is always 1

index.js - nodebox - CodeSandbox


I have a transparent cylinder in my original scene, and it’s rendered into a WebGLRenderTarget, I finally sample it, and the atransparency I get is always 1.0, why? How can I get the right a-transparency?

1 Like

https://codesandbox.io/p/devbox/thirsty-kepler-pj7sg7?workspaceId=ws_4mXDziRfBeoC3AxqXCn3rR

With it too not red. Maybe absend call for rendering this.renderPlaneScene:

            if(c.a<1.0){
            c = vec4(1.0,0.0,0.0,1.0);
            }else{
              c = vec4(1.0,0.0,0.0,1.0);
            }

正在上传:image.png…


It’s red, I forgot to turn it on

this.webGLRenderer = new THREE.WebGLRenderer({ canvas: this.canvas });
to
this.webGLRenderer = new THREE.WebGLRenderer({ canvas: this.canvas,alpha:true });

2 Likes

Thanks, I tried it before, alpha:true, I set the background of the scene to black in my local code, so it has been getting incorrect, now it is okay to remove the background

1 Like