首先,我是glsl和Three.js的初學者:)。僅對某些3D對象應用後期處理效果
這裏是我的頂點和shader1的片段着色器(很簡單):
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
}
void main() {
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
在我的init()函數有:
var geometry = new THREE.CubeGeometry(2, 2, 2);
var material = new THREE.MeshLambertMaterial({color: 0xffaaff});
cube = new THREE.Mesh(geometry, material);
scene.add(cube);
var effect1 = new THREE.ShaderPass(THREE.ShaderExtras[ "shader1" ]);
effect1.renderToScreen=true;
composer = new THREE.EffectComposer(renderer);
composer.addPass(renderScene);
composer.addPass(effect1);
在我的功能渲染():
Renderer.clear() ;
composer.render();
但最後我所有的屏幕都不是紅色的,而是我的立方體。怎麼了 ?
謝謝。
我忘了打招呼:) – user1482030 2012-07-06 10:22:27