mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1f0ba7c19a | ||
![]() |
b4d08a99ad |
@@ -26,6 +26,7 @@ namespace gdjs {
|
||||
|
||||
private _shadowMapDirty = true;
|
||||
private _shadowMapSize: float = 1024;
|
||||
private _minimumShadowBias: float = 0;
|
||||
|
||||
private _shadowCameraDirty = true;
|
||||
private _distanceFromCamera: float = 1500;
|
||||
@@ -66,17 +67,6 @@ namespace gdjs {
|
||||
}
|
||||
this._shadowMapDirty = false;
|
||||
|
||||
// Avoid shadow acne due to depth buffer precision. We choose a value
|
||||
// small enough to avoid "peter panning" but not too small to avoid
|
||||
// shadow acne on low/medium quality shadow maps.
|
||||
// If needed, this could become a parameter of the effect.
|
||||
this._light.shadow.bias =
|
||||
this._shadowMapSize < 1024
|
||||
? -0.002
|
||||
: this._shadowMapSize < 2048
|
||||
? -0.001
|
||||
: -0.0008;
|
||||
|
||||
this._light.shadow.mapSize.set(
|
||||
this._shadowMapSize,
|
||||
this._shadowMapSize
|
||||
@@ -135,9 +125,21 @@ namespace gdjs {
|
||||
return true;
|
||||
}
|
||||
updatePreRender(target: gdjs.EffectsTarget): any {
|
||||
// Apply any update to the camera or shadow map size.
|
||||
this._updateShadowCamera();
|
||||
this._updateShadowMapSize();
|
||||
|
||||
// Avoid shadow acne due to depth buffer precision.
|
||||
const biasMultiplier =
|
||||
this._shadowMapSize < 1024
|
||||
? 2
|
||||
: this._shadowMapSize < 2048
|
||||
? 1.25
|
||||
: 1;
|
||||
this._light.shadow.bias = -this._minimumShadowBias * biasMultiplier;
|
||||
|
||||
// Apply update to the light position and its target.
|
||||
// By doing this, the shadows are "following" the GDevelop camera.
|
||||
if (!target.getRuntimeLayer) {
|
||||
return;
|
||||
}
|
||||
@@ -197,6 +199,8 @@ namespace gdjs {
|
||||
this._distanceFromCamera = value;
|
||||
} else if (parameterName === 'frustumSize') {
|
||||
this._frustumSize = value;
|
||||
} else if (parameterName === 'minimumShadowBias') {
|
||||
this._minimumShadowBias = value;
|
||||
}
|
||||
}
|
||||
getDoubleParameter(parameterName: string): number {
|
||||
@@ -210,6 +214,8 @@ namespace gdjs {
|
||||
return this._distanceFromCamera;
|
||||
} else if (parameterName === 'frustumSize') {
|
||||
return this._frustumSize;
|
||||
} else if (parameterName === 'minimumShadowBias') {
|
||||
return this._minimumShadowBias;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1949,6 +1949,18 @@ module.exports = {
|
||||
.setLabel(_('Shadow quality'))
|
||||
.setType('choice')
|
||||
.setGroup(_('Shadows'));
|
||||
properties
|
||||
.getOrCreate('minimumShadowBias')
|
||||
.setValue('0')
|
||||
.setLabel(_('Shadow bias'))
|
||||
.setDescription(
|
||||
_(
|
||||
'Use this to avoid "shadow acne" due to depth buffer precision. Choose a value small enough like 0.001 to avoid creating distance between shadows and objects but not too small to avoid shadow glitches on low/medium quality. This value is used for high quality, and multiplied by 1.25 for medium quality and 2 for low quality.'
|
||||
)
|
||||
)
|
||||
.setType('number')
|
||||
.setGroup(_('Shadows'))
|
||||
.setAdvanced(true);
|
||||
properties
|
||||
.getOrCreate('frustumSize')
|
||||
.setValue('4000')
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "gdevelop",
|
||||
"productName": "GDevelop 5",
|
||||
"description": "GDevelop 5 IDE - the open-source, cross-platform game engine designed for everyone",
|
||||
"version": "5.5.234",
|
||||
"version": "5.5.235",
|
||||
"author": "GDevelop Team <hello@gdevelop.io>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://gdevelop.io",
|
||||
|
Reference in New Issue
Block a user