google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

the shadows of the objects gets clipped according to the plane #542

Closed ishaang10 closed 5 years ago

ishaang10 commented 5 years ago

i want my model to have shadows even outside of the detected plane

khonakr commented 5 years ago

Just a suggestion, you could make a large transparent plane (e.g 10m) using the pose + center of the current plane found. If this material is set to show shadows, you ll see shadows on much larger area and they would not get clipped off.

ishaang10 commented 5 years ago

thanks for the reply.. I am thinking the same but now my problem is that how to disable the current shadows from my model. also how to make a seperate plane and cast the shadows?

khonakr commented 5 years ago

arSceneView.getPlaneRenderer().setShadowReceiver(false); will disabled the shadows on the default planeRenderer.

You can create your own plane by making a mesh based on the detected plane specifics: Look at com.google.ar.sceneform.rendering.PlaneVisualizer and com.google.ar.sceneform.rendering.PlaneRenderer

You can create your own PlaneNode and PlaneVisualizer classes inspired from these.

ishaang10 commented 5 years ago

thanks . currently i set the node.setshadowcaster(false) .

i added a light in my scene. so do you haveany idea how can i change the local position of that light as i canot se any setlocalpos method for the light.i want it to be above my node

michaelvogt commented 5 years ago

To deactivate the default shadow is a really good idea. The problems with the default shadow are even worse than before with version 1.7.

Another default not useable.

khonakr commented 5 years ago

@ishaang10 Yes you can position a light. It's a node itself. Here is an example placing light at Position 1, 1, 1

`

    Node light = new Node();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        light.setLight(Light.builder(Light.Type.POINT)
                .setColor(new Color(-863292))
                .setIntensity(200)
                .build());
    }
    light.setLookDirection(new Vector3(0.7F, -1.0F, -0.8F));
    light.setParent(sceneView.getScene());
    light.setWorldPosition(new Vector3(1,1,1));

`

Let me know :)

ishaang10 commented 5 years ago

is there a way my node cast shadow by only this light and not the default one on the plane? thanks

khonakr commented 5 years ago

(I think) The shadows will always be based on all the lights in the scene.

You can though disable the default sunlight and add your own lights wherever you want: sceneView.getScene().getSunlight().setEnabled(false);

ishaang10 commented 5 years ago

Do you know the default location of the sun or the default light.. i mean if i were to set all the properties same just change the location of the sun (x axis) then it would be awesome

khonakr commented 5 years ago

Since sun is a node, I think you can getWorldPosition() on it.

"All other functionality in Node is supported. You can access the position and rotation of the sun, assign a collision shape to the sun, or add children to the sun. Disabling the sun turns off the default directional light."

https://developers.google.com/ar/reference/java/sceneform/reference/com/google/ar/sceneform/Sun

You should get familiar with the documentation. It's really useful.

ishaang10 commented 5 years ago

thanks a lot sir :)

MrCsabaToth commented 4 years ago

Newer URL to the Sun: https://developers.google.com/sceneform/reference/com/google/ar/sceneform/Sun