Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Lighting to Sceneform Node no effect

I'm following the google developers guide on adding Light to a Node in SceneView:

https://developers.google.com/sceneform/develop/build-scene

Light spotLightYellow =
    Light.builder(this, Light.Type.FOCUSED_SPOTLIGHT)
        .setColor(new Color(android.graphics.Color.YELLOW))
        .setShadowCastingEnabled(true)
        .build();

However it doesn't seem to do anything to my rendered model.

Is there anything else I'm missing?

 ModelRenderable.builder()
                .setSource(
                        this,
                        Uri.parse(card)
                )
                .build()
                .thenAccept(
                        modelRenderable -> {

                            node.setParent(scene);
                            node.setLocalPosition(vector3);
                            node.setLocalScale(new Vector3(1.4f, 1.4f, 1.4f));
                            node.setName("Test");

                            Light light =
                                   Light.builder(Light.Type.FOCUSED_SPOTLIGHT)
                                   .setColor(new Color(android.graphics.Color.YELLOW))
                                   .setShadowCastingEnabled(true)
                                   .build();

                            node.setLight(light);

                            node.setRenderable(modelRenderable);


                        })
                .exceptionally(
                        throwable -> {
                            Toast toast =
                                    Toast.makeText(this, "Unable to load Fox renderable" + throwable, Toast.LENGTH_LONG);
                            toast.setGravity(Gravity.CENTER, 0, 0);
                            toast.show();
                            return null;
                        });
like image 925
DIRTY DAVE Avatar asked Jun 21 '20 17:06

DIRTY DAVE


1 Answers

Make sure that DIRECTIONAL light's intensity is considerably lower than FOCUSED_SPOTLIGHT's intensity. A position and direction of a spotlight do matter, however a directional light is controlled by direction only (as its name suggests). If FOCUSED_SPOTLIGHT still doesn't work, try regular SPOTLIGHT.

like image 107
Andy Jazz Avatar answered Oct 29 '22 09:10

Andy Jazz