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

[BUG]: castShadow/receiveShadow 无效 #299

Closed
OriIIusion opened this issue Sep 14, 2023 · 0 comments · Fixed by #343
Closed

[BUG]: castShadow/receiveShadow 无效 #299

OriIIusion opened this issue Sep 14, 2023 · 0 comments · Fixed by #343
Labels
bug Something isn't working

Comments

@OriIIusion
Copy link
Contributor

Bug描述

官方阴影说明codepen示例中,灯光的castShadow打开,方块的castShadow关闭,地面的receiveShadow也关闭,阴影仍然存在。

Bug复现流程

通过以下步骤产生bug:

  1. 打开官方文档平行光阴影的codepen页面
  2. 将灯光的castShadow 设置为false,阴影消失,这是对的。
  3. 将灯光的castShadow 设置为true,方块的castShadow设置为false,地面的receiveShadow也设置为false,阴影仍然存在。

期待的结果

场景中会有一部分物体希望显示阴影 另一部分不想展示阴影。不想展示阴影的那些物体怎么设置?

测试引擎版本:

0.6.9

代码示例

import { Engine3D, Scene3D, Object3D, Camera3D, Vector3, AtmosphericComponent, View3D, LitMaterial, BoxGeometry, MeshRenderer, UnLitMaterial, SphereGeometry, DirectLight, PointLight, SpotLight, HoverCameraController, PlaneGeometry, Color } from '@orillusion/core'

// shadow setting
Engine3D.setting.shadow.autoUpdate = true
Engine3D.setting.shadow.shadowBound = 100
Engine3D.setting.shadow.type = 'HARD'

await Engine3D.init({
    canvasConfig: { devicePixelRatio: 1 }
})
let scene3D: Scene3D = new Scene3D()
let cameraObj: Object3D = new Object3D()
let camera = cameraObj.addComponent(Camera3D)
camera.perspective(60, Engine3D.aspect, 1, 5000.0)
let controller = cameraObj.addComponent(HoverCameraController)
controller.setCamera(-45, -45, 100, new Vector3(0, 0, 0))
scene3D.addChild(cameraObj)

//DirectLight
{
    let obj = new Object3D()
    obj.rotationX = 45
    obj.rotationY = 0
    obj.rotationZ = 0
    let light = obj.addComponent(DirectLight)
    scene3D.addChild(obj)
    // enable light shadow
    light.castShadow = true
    light.intensity = 30
    scene3D.addChild(obj)
}

// create a box as shadow source
{
    let castShadowObj = new Object3D()
    castShadowObj.y = 5
    castShadowObj.rotationY = 45
    let mr = castShadowObj.addComponent(MeshRenderer)
    mr.geometry = new BoxGeometry(10, 10, 10)
    mr.material = new LitMaterial()
    mr.material.baseColor = new Color(1, 0, 0)
    mr.castShadow = false
    scene3D.addChild(castShadowObj)
}

// create a plane to receive shadow
{
    let receiveShadowObj = new Object3D()
    let mr = receiveShadowObj.addComponent(MeshRenderer)
    mr.geometry = new BoxGeometry(2000, 1, 2000)
    mr.material = new LitMaterial()
    mr.receiveShadow = false
    scene3D.addChild(receiveShadowObj)
}
// create a view with target scene and camera
let view = new View3D()
view.scene = scene3D
view.camera = camera
// start render
Engine3D.startRenderView(view)

@OriIIusion OriIIusion added the bug Something isn't working label Sep 14, 2023
@lslzl3000 lslzl3000 changed the title [BUG]: LitMaterial阴影关不掉 [BUG]: castShadow/receiveShadow 无效 Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants