Reading Shader Color
I have a really basic shader. Color value into the Shader color.rgb.
When I try to read the values of the material with script.getColour.mainPass.baseColor i get a value that looks like 0x6000015bd2f0 where I really need it as a Vector3 or Vector4.
Would anyone know what I'm doing wrong? or a way to convert the outputs?
Thanks.
K.
Hi, @...!
Looks like your material doesn't have a baseColor property.
Did you create a Node Graph material? Can you check the scripting name of your Color Parameter?
If this is the issue you can either change scripting name to baseColor or access it via:
Hope this works!
Best
Olha
Thanks Olha.
It looks like the base colour isn’t set when the script runs on initialized. I placed the script on a tap event and it’s returning a ver4 value. But the value seems to be the same no matter what colour I set it.
Is it not possible to access the updated color from the shader?
Hi, @...
Could you please take a look at this project? Everything seems to work for me. Here is my set-up and code
Best
Olha
Please activate my snapchat profile so people can see my lenses and subscribe my page.
Thanks Olha for the reply. I see you are using a "Color Parameter" node, I want to read the color from the Shader when its been assigned by something else like a "Color Value" node.
Sorry I don't quite understand what are you trying to achieve. Maybe you could provide some context? Value nodes are designed to return predefined value, you can't assign or access them from the script.
If you want to access a result color of a shader you can render it and then access a pixel color of a Render Target texture using getPixels() method of a ProceduraltextureProvider. Is it something that you might use? example
Let me know
Best
Olha
Actually that's all the bits I need to get it going.
Many thanks Olha :D
K.