threeJS使用OutlinePass场景会变暗(颜色不对)

问题描述

在使用OutlinePass发现场景变得很暗

  this.composer = new EffectComposer(this.renderer);

      const renderPass = new RenderPass(this.scene, this.camera);
      this.composer.addPass(renderPass);
      
      // const gammaCorrectionShader = new ShaderPass(GammaCorrectionShader);
      // this.composer.addPass(gammaCorrectionShader);

      this.outlinePass = new OutlinePass(
        new Vector2(width, height),
        this.scene,
        this.camera
      );

原因分析:

网上找了很多文档大部分都说是颜色转换问题sRGBLinear


解决方案:

使用GammaCorrectionShader校正,就是单词意思。

注意:位置要放在renderPass之后

this.composer = new EffectComposer(this.renderer);

      const renderPass = new RenderPass(this.scene, this.camera);
      this.composer.addPass(renderPass);
      
      // 放在renderPass之后
      const gammaCorrectionShader = new ShaderPass(GammaCorrectionShader);
      this.composer.addPass(gammaCorrectionShader);

      this.outlinePass = new OutlinePass(
        new Vector2(width, height),
        this.scene,
        this.camera
      );

参考大佬思路
-------------------------这里大佬文档------------------------

你可能感兴趣的:(Vue3,threeJS,webgl,vue.js,前端)