- Home /
per-vertex data(input) in custom shaders?
I'm currently try to wrap my head around shaders.
What I actually want to do? Implement a Fog of War system like in Age of Empires for example on my unity terrain.
That means I have 3 different transparency states per vertex/tile (0,50,100% or unexplored, explored but not in viewrange, explored and in viewrange)
I'm aware of that I can do something like shader.SetInt("foo", 2);
but I don't know how to do this per vertex.
So my question is: How can I pass data to an Shader per-vertex ?
Answer by robertbu · Aug 24, 2014 at 12:59 AM
Seems to be that you would want to pass this info in the Mesh.colors array. Probably be best to use the 'a' of each color in the array.
@robertbu hm, I can't do this with an terrain, right? Well, I didn't mention that I use a terrain, I'll update my question. Well but I could use a second mesh for this one I guess.
Update: Yep this seems to work - so feel free to upgrade your comment to an answer :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613161354im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to force the compilation of a shader in Unity? 5 Answers
How to determine shader center? 0 Answers
Why does this IOS / OGLES shader not match PC version? 0 Answers
Use multiple materials? 1 Answer