Вход Регистрация
Файл: Space race/libs/postprocessing/BloomPass.js
Строк: 171
<?php
/**
 * @author alteredq / http://alteredqualia.com/
 */

THREE.BloomPass = function ( strengthkernelSizesigmaresolution ) {

    
strength = ( strength !== undefined ) ? strength 1;
    
kernelSize = ( kernelSize !== undefined ) ? kernelSize 25;
    
sigma = ( sigma !== undefined ) ? sigma 4.0;
    
resolution = ( resolution !== undefined ) ? resolution 256;

    
// render targets

    
var pars = { minFilterTHREE.LinearFiltermagFilterTHREE.LinearFilterformatTHREE.RGBFormat };

    
this.renderTargetX = new THREE.WebGLRenderTargetresolutionresolutionpars );
    
this.renderTargetY = new THREE.WebGLRenderTargetresolutionresolutionpars );

    
// screen material

    
var screenShader THREE.ShaderExtras"screen" ];

    
this.screenUniforms THREE.UniformsUtils.clone( screenShader.uniforms );

    
this.screenUniforms"opacity" ].value strength;

    
this.materialScreen = new THREE.ShaderMaterial( {

        
uniformsthis.screenUniforms,
        
vertexShaderscreenShader.vertexShader,
        
fragmentShaderscreenShader.fragmentShader,
        
blendingTHREE.AdditiveBlending,
        
transparenttrue

    
} );

    
// convolution material

    
var convolutionShader THREE.ShaderExtras"convolution" ];

    
this.convolutionUniforms THREE.UniformsUtils.clone( convolutionShader.uniforms );

    
this.convolutionUniforms"uImageIncrement" ].value THREE.BloomPass.blurx;
    
this.convolutionUniforms"cKernel" ].value THREE.ShaderExtras.buildKernelsigma );

    
this.materialConvolution = new THREE.ShaderMaterial( {

        
uniformsthis.convolutionUniforms,
        
vertexShader:   "#define KERNEL_SIZE " kernelSize ".0n" convolutionShader.vertexShader,
        
fragmentShader"#define KERNEL_SIZE " kernelSize "n"   convolutionShader.fragmentShader

    
} );

    
this.enabled true;
    
this.needsSwap false;
    
this.clear false;

};

THREE.BloomPass.prototype = {

    
render: function ( rendererwriteBufferreadBufferdeltamaskActive ) {

        if ( 
maskActive renderer.context.disablerenderer.context.STENCIL_TEST );

        
// Render quad with blured scene into texture (convolution pass 1)

        
THREE.EffectComposer.quad.material this.materialConvolution;

        
this.convolutionUniforms"tDiffuse" ].texture readBuffer;
        
this.convolutionUniforms"uImageIncrement" ].value THREE.BloomPass.blurX;

        
renderer.renderTHREE.EffectComposer.sceneTHREE.EffectComposer.camerathis.renderTargetXtrue );


        
// Render quad with blured scene into texture (convolution pass 2)

        
this.convolutionUniforms"tDiffuse" ].texture this.renderTargetX;
        
this.convolutionUniforms"uImageIncrement" ].value THREE.BloomPass.blurY;

        
renderer.renderTHREE.EffectComposer.sceneTHREE.EffectComposer.camerathis.renderTargetYtrue );

        
// Render original scene with superimposed blur to texture

        
THREE.EffectComposer.quad.material this.materialScreen;

        
this.screenUniforms"tDiffuse" ].texture this.renderTargetY;

        if ( 
maskActive renderer.context.enablerenderer.context.STENCIL_TEST );

        
renderer.renderTHREE.EffectComposer.sceneTHREE.EffectComposer.camerareadBufferthis.clear );

    }

};

THREE.BloomPass.blurX = new THREE.Vector20.0019531250.0 );
THREE.BloomPass.blurY = new THREE.Vector20.00.001953125 );
?>
Онлайн: 2
Реклама