Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadows Fix #3574

Merged
merged 2 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ define([
this._inverseTransposeModelDirty = true;
this._modelViewDirty = true;
this._inverseModelViewDirty = true;
this._viewProjectionDirty = true;
this._inverseViewProjectionDirty = true;
this._modelViewRelativeToEyeDirty = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, looks like a bug I must have injected years ago. Sorry and good catch!

this._inverseModelViewDirty = true;
this._modelViewProjectionDirty = true;
Expand Down Expand Up @@ -783,6 +781,7 @@ define([
uniformState._inverseModelViewDirty = true;
uniformState._inverseModelView3DDirty = true;
uniformState._viewProjectionDirty = true;
uniformState._inverseViewProjectionDirty = true;
uniformState._modelViewProjectionDirty = true;
uniformState._modelViewProjectionRelativeToEyeDirty = true;
uniformState._modelViewInfiniteProjectionDirty = true;
Expand All @@ -803,6 +802,7 @@ define([
uniformState._inverseProjectionDirty = true;
uniformState._inverseProjectionOITDirty = true;
uniformState._viewProjectionDirty = true;
uniformState._inverseViewProjectionDirty = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes in UniformState didn't affect the issue at hand, but they may be good changes to make.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, the old code was wrong.

uniformState._modelViewProjectionDirty = true;
uniformState._modelViewProjectionRelativeToEyeDirty = true;
}
Expand Down
13 changes: 11 additions & 2 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,11 @@ define([
}

us.updateFrustum(frustum);

if (scene.sunShadowMap.enabled) {
scene.sunShadowMap.updateShadowMapMatrix(us);
}

clearDepth.execute(context, passState);

var commands = frustumCommands.commands[Pass.GLOBE];
Expand Down Expand Up @@ -1604,6 +1609,10 @@ define([
// Do not overlap frustums in the translucent pass to avoid blending artifacts
frustum.near = frustumCommands.near;
us.updateFrustum(frustum);

if (scene.sunShadowMap.enabled) {
scene.sunShadowMap.updateShadowMapMatrix(us);
}
}

commands = frustumCommands.commands[Pass.TRANSLUCENT];
Expand Down Expand Up @@ -1952,12 +1961,12 @@ define([
scene.fog.update(frameState);

var shadowMap = scene.sunShadowMap;
us.update(frameState, shadowMap);

if (shadowMap.enabled) {
shadowMap.update(frameState);
}

us.update(frameState, shadowMap);

scene._computeCommandList.length = 0;
scene._overlayCommandList.length = 0;

Expand Down
9 changes: 3 additions & 6 deletions Source/Scene/ShadowMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,12 @@ define([
var scaleBiasMatrix = new Matrix4(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);

ShadowMap.prototype.update = function(frameState) {
var context = frameState.context;
var uniformState = context.uniformState;

applyDebugSettings(this, frameState);
updateFramebuffer(this, frameState.context);
};

updateFramebuffer(this, context);

ShadowMap.prototype.updateShadowMapMatrix = function(uniformState) {
// Calculate shadow map matrix. It converts gl_Position to shadow map texture space.
// TODO : only compute matrix when dirty
var viewMatrix = this.camera.viewMatrix;
var projectionMatrix = this._frustum.projectionMatrix;
var shadowMapMatrix = Matrix4.multiplyTransformation(projectionMatrix, viewMatrix, this._shadowMapMatrix);
Expand Down