Reputation: 487
When using the WebGLRenderer directly the background is automatically cleared with a white color. However, when using the EffectComposer the background is cleared with black color instead.
Here is an example: http://jsfiddle.net/wereHamster/Lt2DX/. The scene shows a red cube on white background. If you comment out line 41 and uncomment line 42 (enabling the EffectComposer), the canvas will show a red cube on black background.
Here is the code:
# A simple scene with a red cube in the center.
scene = new THREE.Scene
camera = new THREE.PerspectiveCamera 75, 200/200, 0.01, 1000
camera.position.z = 5
scene.add camera
geometry = new THREE.CubeGeometry 1, 1, 1
material = new THREE.MeshBasicMaterial { color: 0xFF0000 }
scene.add (mesh = new THREE.Mesh geometry, material)
# The barebone WebGL renderer.
renderer = new THREE.WebGLRenderer
renderer.setSize 200, 200
$('body').append renderer.domElement
# Composer with two passes, RenderPass and ShaderPass.
composer = new THREE.EffectComposer renderer
renderPass = new THREE.RenderPass scene, camera
composer.addPass renderPass
shaderPass = new THREE.ShaderPass THREE.CopyShader
shaderPass.renderToScreen = true
composer.addPass shaderPass
# The main animation loop.
animate = ->
requestAnimationFrame animate
mesh.rotation.x += 0.01
mesh.rotation.y += 0.01
# If we use the composer to render the scene then the
# background is black instead of white.
renderer.render scene, camera
#composer.render 0.1
animate()
Upvotes: 0
Views: 1041
Reputation: 104793
THREE.RenderPass
has additional arguments
renderPass = new THREE.RenderPass scene, camera, null, new THREE.Color().setHex( 0xffffff ), 0
Also, the renderer
by default has a clear, not white, background. What you are seeing is body color showing through.
fiddle: http://jsfiddle.net/Lt2DX/36/
Upvotes: 4