You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React中使用OutlinePass遇场景变暗及Mac渲染artifacts问题求助

React中使用Three.js OutlinePass等后期处理的问题求助

我在React应用中使用Three.js的OutlinePass时遇到以下问题:

  • 将OutlinePass添加至EffectComposer后,整个场景出现变暗现象
  • 在Mac设备的Chromium浏览器中渲染时,画面出现artifacts(瑕疵)
  • 换用UnrealBloomPass等其他后期处理工具时,同样存在上述两个问题

渲染效果对比

Windows系统添加OutlinePass前后

添加前渲染效果
添加后渲染效果

Mac(Chrome浏览器)添加OutlinePass前后

添加前渲染效果
添加后渲染效果

Windows系统下OutlinePass正常工作效果

Windows下正常渲染效果

核心渲染代码

const initMap = () => {
        if (renderer==null) {

            container = document.getElementById( 'canvas' );
            document.body.appendChild( container );

            scene = new THREE.Scene();

            addPerspectiveCamera();

            //Composer and renderer
            renderer = new THREE.WebGLRenderer({ canvas: canvasRef.current, antialias: true, precision: "highp"});
            renderer.setSize( window.innerWidth, window.innerHeight );
            renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
            renderer.outputEncoding = THREE.sRGBEncoding
            renderer.toneMappingExposure = 1
            renderer.shadowMap.enabled = true
            renderer.shadowMap.type = THREE.PCFSoftShadowMap

            const size = renderer.getSize( new THREE.Vector2() );
            const _pixelRatio = renderer.getPixelRatio();
            const _width = size.width;
            const _height = size.height;

            var renderTarget = new THREE.WebGLRenderTarget( _width * _pixelRatio, _height * _pixelRatio, {
              minFilter: THREE.LinearFilter,
              magFilter: THREE.LinearFilter,
              format: THREE.RGBAFormat,
              encoding: THREE.sRGBEncoding
                 } );

            compose = new EffectComposer(renderer, renderTarget);
            renderPass = new RenderPass(scene, perspectiveCamera, pointLight, light);

            //Outline pass 
            outlinePass = new OutlinePass(new THREE.Vector2(window.innerWidth,window.innerHeight),scene,perspectiveCamera, pointLight, light);
            outlinePass.renderToScreen = true;
            outlinePass.selectedObjects = selectedObjects;

            //Add passes to composer
            compose.addPass(renderPass);
            compose.addPass(outlinePass);     //TODO - fix this in MAC (!!!!)

            container.appendChild( renderer.domElement );

            const interaction = new Interaction(renderer, scene, perspectiveCamera, pointLight, light);

            if (props.localMap) {
              addLocalMap();
            } 
            if (!props.localMap) {
              addWorldMap();
            }

        }

        //addOrbitControls();
        animate();
    }

恳请各位提供解决方案。

内容的提问来源于stack exchange,提问作者Elemermelada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 01:20:31