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

Model shadow on ARSceneView #357

Open
pablojoseoroz opened this issue Nov 17, 2023 · 4 comments
Open

Model shadow on ARSceneView #357

pablojoseoroz opened this issue Nov 17, 2023 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@pablojoseoroz
Copy link

Any example to show a model shadow? I try with LightNode, adding PlaneNode below ModelNode, setting isShadowCaster and isShadowReceiver, changing scenes lightEstimation, adding custom LightNode to scene... But never appears model shadow :-(

fun addModelNodeLocalOnHit(context: Context, hitResult: HitResult, model: String) {
        sceneView.modelLoader.loadModelAsync("models/$model") {
            it?.let {
                val parent = createAnchorNode(hitResult)
                ModelNode(
                    modelInstance = it.instance,
                    parent = parent,
                    centerOrigin = Position(y = -1f),
                    scaleToUnits = 0.004f
                ).apply {
                    //isEditable = true
                    isShadowCaster = true
                    isShadowReceiver = false
                }.also {
                    PlaneNode(
                        getEngine(),
                        size = Size(0.5f, 0.1f, .5f),
                        center = Position(y = -.5f),
                        materialInstance = MaterialLoader(getEngine(), context)
                            .createColorMaterial(Color(1f, 1f, 1f, 1f), 0f, 0f, 0f),
                        parent = it
                    ).apply {
                        isShadowCaster = false
                        isShadowReceiver = true
                    }
                }
                addChilNodeToScene(parent)
}

Thanks!

@ryust
Copy link

ryust commented Feb 6, 2024

I've never gotten shadows to work either.

@natasam
Copy link

natasam commented Feb 24, 2024

Did you find a solution for adding the shadow?

Copy link

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label May 25, 2024
@ThomasGorisse ThomasGorisse added bug Something isn't working help wanted Extra attention is needed and removed Stale labels May 29, 2024
@Dreiko
Copy link

Dreiko commented May 30, 2024

@pablojoseoroz try to use the following material for the PlaneNode and ensure ModelNode is between directional light and plane.

4.2.29 Lighting: shadowMultiplier

material {
    name : GroundShadow,
    blending : transparent,
    shadingModel : unlit,
    shadowMultiplier : true
}

fragment {
    void material(inout MaterialInputs material) {
        prepareMaterial(material);
        material.baseColor = vec4(0.0, 0.0, 0.0, 0.5); // 0.5 is strength of the shadow. Change it or modify to use parameter.
    }
}

also check if shadows are enabled in the view

engine.createView().apply {
   setShadowingEnabled(true)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants