Hi there,
I am making glow effect, but the blur shaders don’t work.
My code is this:
const hblur = new ShaderPass(HorizontalBlurShader);
const vblur = new ShaderPass(VerticalBlurShader);
var bluriness = 3;
hblur.uniforms["h"].value = bluriness / SCREEN_WIDTH;
vblur.uniforms["v"].value = bluriness / SCREEN_HEIGHT;
var renderModelGlow = new RenderPass(glowscene, camera);
const glowcomposer = new EffectComposer(renderer, renderTargetGlow);
glowcomposer.addPass(renderModelGlow);
glowcomposer.addPass(hblur);
glowcomposer.addPass(vblur);
const finalshader = {
uniforms: {
tDiffuse: { type: "t", value: 0, texture: null },
tGlow: { type: "t", value: glowcomposer.renderTarget2, texture: null }
},
vertexShader: [
"varying vec2 vUv;",
"void main() {",
"vUv = vec2( uv.x, uv.y );",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"}"
].join("\n"),
fragmentShader: [
"uniform sampler2D tDiffuse;",
"uniform sampler2D tGlow;",
"varying vec2 vUv;",
"void main() {",
"vec4 texel = texture2D( tDiffuse, vUv );",
"vec4 glow = texture2D( tGlow, vUv );",
"gl_FragColor = texel + vec4(0.5, 0.75, 1.0, 1.0) * glow * 2.0;",
"}"
].join("\n")
};
var renderModel = new RenderPass(scene, camera);
var finalPass = new ShaderPass(finalshader);
finalPass.needsSwap = true;
finalPass.renderToScreen = true;
const renderTarget = new THREE.WebGLRenderTarget(SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters);
const finalcomposer = new EffectComposer(renderer, renderTarget);
finalcomposer.addPass(renderModel);
finalcomposer.addPass(finalPass);
glowcomposer.render();
finalcomposer.render();
Can you help me?