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

Lights rendered on object before object is rotated? #829

Open kenyee opened 5 years ago

kenyee commented 5 years ago

If you modify the lighting sample here: https://github.com/googlesamples/sceneform-samples by rotating the box via either setLookDirection or setLocalRotation:

          // Create a thin box beneath the models.
          createShapeNode(anchorNode, boxRenderable, new Vector3(0.0f, 0.0f, 0.0f))
                  //.setLookDirection(new Vector3(0f, 1f, 0f));
            .setLocalRotation(Quaternion.lookRotation(new Vector3(0f, 1f, 0f), Vector3.up()));

The lighting which should be above the box seems to be rendered onto it before it's rotated (notice that the light is on the side and nothing appears on the top of the box but it should be because the box is rotated):

image

kenyee commented 5 years ago

Found a fix I think...decompiled ShapeFactory.makeCube and changed these lines: val front = Vector3.back() // front/back normals are flipped val back = Vector3.forward() // in the Sceneform code to swap front/back. Rotation works fine if you do this so it looks like the normals on the front/back surfaces weren't set properly?