sceneview-android
sceneview-android copied to clipboard
Model shadow on ARSceneView
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!
I've never gotten shadows to work either.
Did you find a solution for adding the shadow?
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.
@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)
}