Skip to content

Commit

Permalink
Last-minute shadow fix
Browse files Browse the repository at this point in the history
  • Loading branch information
torchipeppo committed Sep 22, 2021
1 parent 9d043fb commit 9728cd6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/user-interfaces/story-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createUI(scene) {
const text_story = new BABYLON.GUI.TextBlock("text_story");
text_story.text = theStoryText;
text_story.top = "-40px";
text_story.fontSize = 30;
text_story.fontSize = 27;
rect_bg.addControl(text_story);

// add button to retry
Expand Down
48 changes: 25 additions & 23 deletions src/utils/lib-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,34 @@ function createDirectionalLight(scene, shadowcasters=[], sceneType=SCENETYPE.DUN
// ...and a dimmer diffuse color, so we can darken the dungeon a bit further w/o dimming specular reflections too much
light.diffuse = new BABYLON.Color3(0.8, 0.8, 0.8);

let resolution;
switch (theOptions.shadows) {
case 2:
resolution = 4096;
break;
case 1:
default:
resolution = 1024;
if (theOptions.shadows != 0) {
let resolution;
switch (theOptions.shadows) {
case 2:
resolution = 4096;
break;
case 1:
default:
resolution = 1024;
}
const shadowgen = new BABYLON.ShadowGenerator(resolution, light);
shadowcasters.forEach(element => {
shadowgen.addShadowCaster(element, true);
});
if (sceneType == SCENETYPE.ENDING) {
shadowgen.useBlurCloseExponentialShadowMap = true;
}
const shadowgen = new BABYLON.ShadowGenerator(resolution, light);
shadowcasters.forEach(element => {
shadowgen.addShadowCaster(element, true);
});
if (sceneType == SCENETYPE.ENDING) {
shadowgen.useBlurCloseExponentialShadowMap = true;
}
else if (theOptions.shadows == 2 && sceneType == SCENETYPE.BATTLE) {
shadowgen.useBlurCloseExponentialShadowMap = true;
}
else if (theOptions.shadows == 2 && sceneType == SCENETYPE.DUNGEON) {
shadowgen.usePercentageCloserFiltering = true;
else if (theOptions.shadows == 2 && sceneType == SCENETYPE.BATTLE) {
shadowgen.useBlurCloseExponentialShadowMap = true;
}
else if (theOptions.shadows == 2 && sceneType == SCENETYPE.DUNGEON) {
shadowgen.usePercentageCloserFiltering = true;
}

light.shadowMinZ = -9;
light.shadowMaxZ = 6;
}

light.shadowMinZ = -9;
light.shadowMaxZ = 6;

// return the light for future use
return light;
}
Expand Down

0 comments on commit 9728cd6

Please sign in to comment.