Skip to content

Commit

Permalink
Merge pull request #582 from guycalledfrank/fixdirectshadowflicker
Browse files Browse the repository at this point in the history
Fix directional shadow flickering
  • Loading branch information
guycalledfrank committed Apr 28, 2016
2 parents 4a140be + 7f4d702 commit 70e4ade
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/scene/forward-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pc.extend(pc, function () {
new pc.Mat4().setScale(0.5, 0.5, 0.5)
);

var directionalShadowEpsilon = 0.01;

var shadowCamView = new pc.Mat4();
var shadowCamViewProj = new pc.Mat4();
var c2sc = new pc.Mat4();
Expand Down Expand Up @@ -1173,7 +1175,7 @@ pc.extend(pc, function () {

// 3. Fix projection
shadowCam._node.setPosition(light._node.getPosition());
shadowCam._node.translateLocal(centerx, centery, maxz);
shadowCam._node.translateLocal(centerx, centery, maxz + directionalShadowEpsilon);
shadowCam.setFarClip( maxz - minz );

this.setCamera(shadowCam, true);
Expand Down

0 comments on commit 70e4ade

Please sign in to comment.