-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support transparent shadow --------- Co-authored-by: ChenMo <gl3336563@163.com>
- Loading branch information
1 parent
dd7f7f3
commit 2fd95b2
Showing
17 changed files
with
230 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* @title Shadow Transparent | ||
* @category Shadow | ||
*/ | ||
|
||
import { | ||
Camera, | ||
DirectLight, | ||
GLTFResource, | ||
Logger, | ||
MeshRenderer, | ||
PBRMaterial, | ||
PrimitiveMesh, | ||
ShadowResolution, | ||
ShadowType, | ||
Vector3, | ||
WebGLEngine, | ||
WebGLMode | ||
} from "@galacean/engine"; | ||
import { initScreenshot, updateForE2E } from "./.mockForE2E"; | ||
Logger.enable(); | ||
|
||
WebGLEngine.create({ | ||
canvas: "canvas", | ||
graphicDeviceOptions: { | ||
webGLMode: WebGLMode.WebGL2 | ||
} | ||
}).then((engine) => { | ||
engine.canvas.resizeByClientSize(); | ||
const scene = engine.sceneManager.activeScene; | ||
const rootEntity = scene.createRootEntity(); | ||
scene.shadowResolution = ShadowResolution.Medium; | ||
scene.shadowDistance = 10; | ||
const cameraEntity = rootEntity.createChild("camera_node"); | ||
cameraEntity.transform.setPosition(0, 2, 3); | ||
cameraEntity.transform.lookAt(new Vector3(0)); | ||
const camera = cameraEntity.addComponent(Camera); | ||
const lightEntity = rootEntity.createChild("light_node"); | ||
const light = lightEntity.addComponent(DirectLight); | ||
lightEntity.transform.setPosition(-6, 10, 0); | ||
lightEntity.transform.lookAt(new Vector3(0, 0, -10)); | ||
light.shadowType = ShadowType.Hard; | ||
|
||
const planeEntity = rootEntity.createChild("plane_node"); | ||
const renderer = planeEntity.addComponent(MeshRenderer); | ||
renderer.mesh = PrimitiveMesh.createPlane(engine, 10, 10); | ||
const planeMaterial = new PBRMaterial(engine); | ||
renderer.setMaterial(planeMaterial); | ||
|
||
engine.resourceManager | ||
.load<GLTFResource>("https://mdn.alipayobjects.com/oasis_be/afts/file/A*kgYIRo36270AAAAAAAAAAAAADkp5AQ/bottle.glb") | ||
.then((asset) => { | ||
const defaultSceneRoot = asset.instantiateSceneRoot(); | ||
rootEntity.addChild(defaultSceneRoot); | ||
defaultSceneRoot.transform.scale.set(0.05, 0.05, 0.05); | ||
scene.enableTransparentShadow = true; | ||
|
||
updateForE2E(engine, 500); | ||
initScreenshot(engine, camera); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.