Adding Shadow to my 2d image using script

Options
TOBI SULAIMAN OLOYEDE
edited January 2023 in General #1

I will be really grateful for help on this....I am a newbie in lensstudio.
I was following the tutorial of "2d art to AR" https://youtu.be/VRLMy6HmNUo

It get to the stage of adding Shadow and rendering on both side through script but its not working

Below is the code

// -----JS CODE-----
// @input int shadowMode = 1 {"widget":"combobox", "values":[{"label":"None", "value":0}, {"label":"Caster", "value":1}, {"label":"Receiver", "value":2}]}
// @input bool twoSided = true

var imageComponent = script.getSceneObject().getComponent("Component.Image");
imageComponent.meshShadowMode = script.shadowMode;
imageComponent.mainPass.twoSided = script.twoSided;

Answers

  • Bakari Mustafa
    Bakari Mustafa Posts: 178 🔥🔥🔥
    Options

    If the code is not working, it could be due to a few different reasons. Some possible causes and solutions include:

    • The object does not have an image component: Make sure the object you are trying to modify has an "Image" component attached to it in the scene.
    • The component variable is not correctly referenced: Verify that the "imageComponent" variable is correctly referencing the object's image component. You can check this by printing the variable to the console using "print(imageComponent);"
    • The meshShadowMode and twoSided properties are not being set correctly: The code you provided sets the meshShadowMode and twoSided properties correctly. It could be the case the properties are already set somewhere else. Verify that they are not being set in another script or in the object's properties.