I have somewhat of a bar graph model that I need to adjust a gradient on depending on where a top line and bottom line is. I’ve been trying to figure this out but can’t seem to find an answer.
I’m not even able to get a gradient on the 3d model at all even after trying a ton of things I’ve found on the internet, and then even after I figure that out, I’m not sure how I can adjust the gradient to work depending on the position of the top and bottom lines. I attached an image that may explain it, anything below the bottom line needs to be one color, then a gradient to the top line, and then another color above the top line.
In what? Shader? cg? vert/frag? surf? bitmaps? vertex colors?
if you just want to “get a gradient on the 3d model” then make an image with a gradient, then apply that to a material on the model. You can even get the top and bottom boundaries with smart uv mapping and a clamped bitmap.
I’m new to Unity and have no idea how to do smart UV’s or clamped bitmaps. I was searching for gradient materials and found code that did it, but couldn’t get it to work at all.
Using shader, script sends the top line and bottom line world positions to shader (material.setFloat()).
Then shader checks for worldPos.y, if its bigger than top line, use color1… if its less than bottom line, use color2,
and if its between, draw gradient from top line to bottom line…
(limitation: those vertical bars currently have to start from y=0 world position…)