Skip to content

Commit

Permalink
Merge pull request #4006 from AnalyticalGraphicsInc/shadows-derived-fix
Browse files Browse the repository at this point in the history
Shadow fixes for derived commands and OIT
  • Loading branch information
pjcozzi committed Jun 7, 2016
2 parents fdfbdef + fd902f2 commit 6959c80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Source/Renderer/DrawCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ define([
result._owner = command._owner;
result._debugShowBoundingVolume = command._debugShowBoundingVolume;
result._debugOverlappingFrustums = command._debugOverlappingFrustums;
result._castShadows = command._castShadows;
result._receiveShadows = command._receiveShadows;

result.dirty = true;
result.lastDirtyTime = 0;
Expand Down
8 changes: 7 additions & 1 deletion Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,10 @@ define([

if (scene.debugShowCommands || scene.debugShowFrustums) {
executeDebugCommand(command, scene, passState);
} else if (scene.frameState.shadowHints.shadowsEnabled && command.receiveShadows) {
} else if (scene.frameState.shadowHints.shadowsEnabled && command.receiveShadows && defined(command.derivedCommands.shadows)) {
// If the command receives shadows, execute the derived shadows command.
// Some commands, such as OIT derived commands, do not have derived shadow commands themselves
// and instead shadowing is built-in. In this case execute the command regularly below.
command.derivedCommands.shadows.receiveCommand.execute(context, passState);
} else {
command.execute(context, passState);
Expand Down Expand Up @@ -1895,6 +1898,9 @@ define([
var numberOfCommands = pass.commandList.length;
for (var k = 0; k < numberOfCommands; ++k) {
var command = pass.commandList[k];
// Set the correct pass before rendering into the shadow map because some shaders
// conditionally render based on whether the pass is translucent or opaque.
uniformState.updatePass(command.pass);
executeCommand(command.derivedCommands.shadows.castCommands[i], scene, context, pass.passState);
}
}
Expand Down
4 changes: 4 additions & 0 deletions Source/Scene/ShadowMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,8 @@ define([
}

result = DrawCommand.shallowClone(command, result);
result.castShadows = true;
result.receiveShadows = false;

if (!defined(castShader) || oldShaderId !== command.shaderProgram.id || shadowsDirty) {
if (defined(castShader)) {
Expand Down Expand Up @@ -1575,6 +1577,8 @@ define([
}

result.receiveCommand = DrawCommand.shallowClone(command, result.receiveCommand);
result.castShadows = false;
result.receiveShadows = true;

// If castShadows changed, recompile the receive shadows shader. The normal shading technique simulates
// self-shadowing so it should be turned off if castShadows is false.
Expand Down

0 comments on commit 6959c80

Please sign in to comment.