The forum on this site is closed for new comments and posts. Continue the conversation in our Snap AR Discord server.

Can I tweak material graph parameter of a specific scene object?

  • hi Diana G

    you can use a Material in multi scenes and if you made a change in that material it will infect all the scenes linked to
    to reference the scene object texture's alpha first you need to access the variable of the alpha
    by moving the mouse up the alpha and a window will popup like image below

    roughness is the variable for that slider im selecting you will have defferent variable name
    now you can edit the alpha 
    in this exemple code ( baseColor ) is the variable

    // @input Component.Image image
    // @input float alpha = 0.5 {"widget":"slider", "min":0.0, "max":1.0, "step":0.01}
    var currColor = script.image.mainPass.baseColor;
    script.image.mainPass.baseColor = new vec4( currColor.r, currColor.g, currColor.b, script.alpha );

    i hope that help
    if you need any help let us know .

    cheers

    Comment actions Permalink
  • Hi, @...!

    1. Are materials instances on a scene object? It seems like from other posts that they are not but I find this confusing as you can specify the texture per scene object.

    No they are not .For all custom materials if you modify their settings you will modify all references of a Material. Default Image material is an exception, that's why you can change texture. 

    To avoid this you can create a copy of material when Lens is initialized and modify the copy. 

    Sample script might be next : 

    //@input Component.MaterialMeshVisual meshVisual
    //@input Asset.Texture tex

    var material = script.meshVisual.mainMaterial.clone();
    script.meshVisual.mainMaterial = material;

    material.mainPass.baseTex = script.tex

    // do something with material

    2. Is there a way I could reference the scene object texture's alpha property through script? I've gotten as far as [Component.Image name].[texture script name] but I'm not sure what would come after that.

    Kanz answered this question for you

    For a default material alpha is material.mainPass.baseColor.a 

    var color = material.mainPass.baseColor;
    color.a = 0.5
    material.mainPass.baseColor = color

    Also when you are using Graph Materials you are able to set s scripting name of parameter by yourself

    (Please make sure that blend mode on a material is set to Normal to see alpha working)

    3. I noticed that the "Default" material has two material-parameters in the image inspector window: "Texture" and "Alpha". Is there a way to achieve this alpha parameter in the image inspector window with a custom material (for clarification, I don't mean in the material inspector window, I mean the image inspector)?

    Image Component that uses custom material will show this parameters in the UI if their scripting names match with scripting names of a Default material (baseTex and baseColor). Texture Parameter will show anyway but Alpha parameter can appear in the Image inspector if your material has a BaseColor parameter with a "baseColor" scripting name. The alpha of this color is the alpha

    Example: 

    Hope this helps!

    Comment actions Permalink
  • Kanz and Olha, thank you so much! You guys crushed it with your explanations. I had played with naming custom variables but I didn't realized there was some implied behaviors when naming your parameters things like "baseColor" or "baseTex". That's so cool! Also, cloning the material was a game changer.

    Thanks guys!

     

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!