- Home /
Is there a way to communicate between the gameobject and the shader?
Is there a way to set some sort of flag on your gameobject so that custom HLSL shader code and read it and change its properties accordingly?
for example,
a gameobject could tell the material/shader to change its color multiplier to red.
or more specifically to my needs, I just need it to pass an index number to a property in my custom shader code.
Answer by Meltdown · Feb 07, 2012 at 06:47 PM
Use Material.SetColor and access your shader property through that.
well I used color as an example to try to explain what I needed. But the flag I need to pass is actually a custom flag. I created I texture atlas that allows you to tile the subtextures in the atlas. (Custom HLSL code) but I would like to pass in an index on a per object basis that tells the shader which texture to use in the texture atlas. Which would be a number between 0 and 16.....Although I may be able to pull that information from the color propery if there was no other way.
Hmmm you might have better luck asking this question at http://forum.unity3d.com/forums/16-ShaderLab
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
How to create light like in minecraft? 1 Answer
Using Color.Lerp with Lightweight Render Pipeline 1 Answer
Set unity_GUIZTestMode in UI Shaders? 0 Answers
CustomRenderTexture Starter? 0 Answers