提交 9bc383e1 编写于 作者: A alteredq

Fixed discrepancy between ANGLE and OpenGL when rendering to texture.

Had to set viewport to make it work in OpenGL.

Also made it easier to see texture orientation in the example.

Now it's visible that there is indeed flipping. At least now it's consistent ;).
上级 cee72056
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -53,7 +53,13 @@
void main(void)
{
gl_FragColor = vec4( time, vUv.x, vUv.y, 1.0 );
//gl_FragColor = vec4( time, vUv.x, vUv.y, 1.0 );
float r = vUv.x;
if( vUv.y < 0.5 ) r = 0.0;
float g = vUv.y;
if( vUv.x < 0.5 ) g = 0.0;
gl_FragColor = vec4( r, g, 0.25, 1.0 );
}
</script>
......@@ -94,6 +100,13 @@
light.position.normalize();
scene.addLight( light );
light = new THREE.DirectionalLight( 0xffaaaa, 0.5 );
light.position.x = -1;
light.position.y = 0;
light.position.z = -1;
light.position.normalize();
scene.addLight( light );
rtTexture = new THREE.RenderTarget( 256, 256 );
material = new THREE.MeshShaderMaterial( {
......
......@@ -22,6 +22,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var _canvas = document.createElement( 'canvas' ), _gl,
_oldProgram = null,
_oldFramebuffer = null,
_modelViewMatrix = new THREE.Matrix4(), _normalMatrix,
_viewMatrixArray = new Float32Array(16),
......@@ -1484,8 +1485,30 @@ THREE.WebGLRenderer = function ( parameters ) {
}
var framebuffer = renderTexture ? renderTexture.__webGLFramebuffer : null;
_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
var framebuffer, width, height;
if ( renderTexture ) {
framebuffer = renderTexture.__webGLFramebuffer;
width = renderTexture.width;
height = renderTexture.height;
} else {
framebuffer = null;
width = _canvas.width;
height = _canvas.height;
}
if( framebuffer != _oldFramebuffer ) {
_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
_gl.viewport( 0, 0, width, height );
_oldFramebuffer = framebuffer;
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册