THREE.js blur the frame buffer

前端 未结 2 1922
执笔经年
执笔经年 2021-02-03 15:20

I need to blur the frame buffer and I don\'t know how to get the frame buffer using THREE.js.

I want to blur the whole frame buffer rather than blur each texture

2条回答
  •  鱼传尺愫
    2021-02-03 16:03

    Any blur should use shaders to be efficient, but in this case not as materials.

    If you want to blur the entire frame buffer and render that to the screen use the effect composer. It's located in three.js/examples/js./postprocessing/EffectComposer.js

    Set up the scene camera and renderer as normal but in addition add an instance of the effect composer. With the scene as a render pass.

    composer = new THREE.EffectComposer( renderer );
    composer.addPass( new THREE.RenderPass( scene, camera ) );
    

    Then blur the whole buffer with two passes using the included blur shaders located in three.js/examples/shaders/

    hblur = new THREE.ShaderPass( THREE.HorizontalBlurShader );
    composer.addPass( hblur );
    
    vblur = new THREE.ShaderPass( THREE.VerticalBlurShader );
    // set this shader pass to render to screen so we can see the effects
    vblur.renderToScreen = true;
    composer.addPass( vblur );
    

    finally in your method called in each frame render using the composer instead of the renderer

    composer.render();
    

    Here is a link to a working example of full screen blur http://bit.ly/WfFKe7

提交回复
热议问题