Home Unity

Procedural gradient falloff shading for a simple path

polycounter lvl 11
Offline / Send Message
Spudnik polycounter lvl 11
I'm trying to build a system with which I can have any sort of geometry (mostly planes) the edges of which fade off into full transparency. Right now I'm simply using a black to white vertical ramp and mapping the corresponding faces to it white using a different shader on the 'path'. 

This has a few obvious issues: 
a) lots of hand authoring of edge meshes and their UVs, time intensive
b) not very flexible 
c) can't deal with multi-directional falloffs (see below) 


So, how would I go about setting something like this up in Unity? The the ideal scenario would be to have a system by which I can only author the path itself and generate the falloff edges based on a selection. Is something like that possible in Unity alone or would I have to use a hybrid approach where I generate the meshes in something like Maya and just do the shading here (I could automate that for the most part, but I'm still stuck on the shading part) ?  


Replies

  • Eric Chadwick
    You might be able to detect edge vertices, and apply vertex colors to them. So the gradient is vc not texture.
  • Spudnik
    Offline / Send Message
    Spudnik polycounter lvl 11
    Ah, great idea, I'll give it a try! Though I'll have to figure out a way to distinguish border edges that I want soft vs ones I want kept straight...

  • Spudnik
    Offline / Send Message
    Spudnik polycounter lvl 11
    OK, gave it a try, it's a good idea, works great in most cases and super easy to author. But the point where two gradients start intersecting becomes a problem because I cant get a smooth transition between the two gradients. Changing the geo/tessellation helps, but seems to shift the issue, not get rid of it completely. 


  • Eric Chadwick
    You might also try using the UV itself as a gradient. Similar resolution issues, but in authoring you have finer control over the rotation & scale.

    Shader Forge has examples on their site about how to use the UVs as a gradient.
  • Apple_hardcore
    I'd recommend possibly setting your gradient to an unlit shader as well. It will help with the sharp edges. Or if the plan is for the gradient to be replaced with a different texture later get your smoothing groups sorted.  You can also relax that corner vert before before tessilation, should give you a more radial gradient if that's what you are looking for.
Sign In or Register to comment.