提交 3c618a86 编写于 作者: A alteredq

Fixed too aggressive projection matrix uniform caching.

This was causing troubles for camera changing mid-frame (like for shadow maps).
上级 f83c6a41
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
......@@ -108,6 +108,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_currentFramebuffer = null,
_currentMaterialId = -1,
_currentGeometryGroupHash = null,
_currentCamera = null,
_geometryGroupCounter = 0,
// GL state cache
......@@ -3291,6 +3292,7 @@ THREE.WebGLRenderer = function ( parameters ) {
for ( var i = 0, il = plugins.length; i < il; i ++ ) {
_currentProgram = null;
_currentCamera = null;
_oldBlending = -1;
_oldDepthTest = -1;
_oldDepthWrite = -1;
......@@ -3300,6 +3302,7 @@ THREE.WebGLRenderer = function ( parameters ) {
plugins[ i ].render( scene, camera, _currentWidth, _currentHeight );
_currentProgram = null;
_currentCamera = null;
_oldBlending = -1;
_oldDepthTest = -1;
_oldDepthWrite = -1;
......@@ -4169,10 +4172,16 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if ( refreshMaterial ) {
if ( refreshMaterial || camera !== _currentCamera ) {
_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, camera._projectionMatrixArray );
if ( camera !== _currentCamera ) _currentCamera = camera;
}
if ( refreshMaterial ) {
// refresh uniforms common to several materials
if ( fog && material.fog ) {
......@@ -4245,7 +4254,7 @@ THREE.WebGLRenderer = function ( parameters ) {
material instanceof THREE.MeshPhongMaterial ||
material.envMap ) {
if( p_uniforms.cameraPosition !== null ) {
if ( p_uniforms.cameraPosition !== null ) {
_gl.uniform3f( p_uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
......@@ -4258,7 +4267,7 @@ THREE.WebGLRenderer = function ( parameters ) {
material instanceof THREE.ShaderMaterial ||
material.skinning ) {
if( p_uniforms.viewMatrix !== null ) {
if ( p_uniforms.viewMatrix !== null ) {
_gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, camera._viewMatrixArray );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册