Skip to content

Instantly share code, notes, and snippets.

@kishalmi
Created April 29, 2013 11:08
Show Gist options
  • Save kishalmi/5480983 to your computer and use it in GitHub Desktop.
Save kishalmi/5480983 to your computer and use it in GitHub Desktop.
support for shadowMapCullFace 'None' and 'Both'
--- build/three.js 2013-04-29 12:12:34.237944000 +0200
+++ /home/lmg/js/three.js 2013-04-29 13:00:24.276532000 +0200
@@ -35281,18 +35281,14 @@
_gl.clearColor( 1, 1, 1, 1 );
_gl.disable( _gl.BLEND );
- _gl.enable( _gl.CULL_FACE );
- _gl.frontFace( _gl.CCW );
-
- if ( _renderer.shadowMapCullFace === THREE.CullFaceFront ) {
- _gl.cullFace( _gl.FRONT );
-
- } else {
-
- _gl.cullFace( _gl.BACK );
-
- }
+ // save current values of both cull and front face - for restoring later
+ // since these are not saved in the renderer yet, locals with default values are used.
+ // ideally they'd get saved inside setFaceCulling()
+ // and setDefaultGLState() would also call it instead of directly setting _gl values
+ var _oldFrontFace = THREE.FrontFaceDirectionCCW;
+ var _oldCullFace = THREE.CullFaceBack;
+ _renderer.setFaceCulling(_renderer.shadowMapCullFace, THREE.FrontFaceDirectionCCW);
_renderer.setDepthTest( true );
@@ -35559,12 +35555,7 @@
_gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearAlpha );
_gl.enable( _gl.BLEND );
- if ( _renderer.shadowMapCullFace === THREE.CullFaceFront ) {
-
- _gl.cullFace( _gl.BACK );
-
- }
-
+ _renderer.setFaceCulling(_oldCullFace, _oldFrontFace);
};
function createVirtualLight( light, cascade ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment