Can't figure this gradient material thing out.

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.

Anyone know how to tackle this?

1351081--66515--$Untitled-1.jpg

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.

Something like this?
GradientBarsRange (shader) : Unity3D : UnityCoder.com (webplayer, QA and WS keys to move lines)

.

Yea, is that something done through code? So when the top bar and bottom bar are moved and it updates the gradient?

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…)

very cool thats what I’m looking for! but how do I do that? LOL

I saw you had a blog with it in there, is there any way for me to get the source?

pm your email address i’ll send the test package.

PM Sent, thanks!

If anyone else wants it, its now here:

*but dont buy it just for making gradients, there are better assets for that.
*New: 2024, upgraded this asset into unity 2021.3.x
Vertical Gradient Range Shader | VFX Shaders | Unity Asset Store