Gradient Shader - I'm struggling!

Node-based Shader Editor
ken0y
Posts: 6
Joined: Tue Oct 31, 2017 8:30 am

Gradient Shader - I'm struggling!

Post by ken0y »

Hey everyone,

I love to play around in amplify shader and I've been trying to learn how to make my own gradient shader.

I've made some progress but I'm stuck on a particular concept:

Image

Image

I've managed to map the gradient in one direction using the world normal direction but I cannot figure out how to evenly map the gradient to the scale of the mesh.

I'm currently using the vertex position.

Any help would be much appreciated,

Kind Regards,

K
ken0y
Posts: 6
Joined: Tue Oct 31, 2017 8:30 am

Re: Gradient Shader - I'm struggling!

Post by ken0y »

OK, sorry folks. I didn't realise that there were node examples supplied.

I found the PositionCutOff example and it helped a lot.

Image

Image

Start point and distribution were the controls I was struggling to define (I suck at maths :( )

Also, the saturate node helped clamp the values.

Kind Regards,

K
ken0y
Posts: 6
Joined: Tue Oct 31, 2017 8:30 am

Re: Gradient Shader - I'm struggling!

Post by ken0y »

the only problem I am currently left with is that when a gradient is mapped to the world Y normal direction it blends with other world normal directions depending on the angle of the geometry.

Maybe there would be some way to restrain the normal angle in Y?

Kind Regards,

K
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Gradient Shader - I'm struggling!

Post by Amplify_RnD_Rick »

Hey ken0y,


Thank you so much for using Amplify Shader Editor!

I've read your posts and it seems that you want a gradient to be dependent on the fragment Y position, but then your are multiplying the saturated Lerp result with the World Normal x component and I'm not quite sure why.

I do apologize for this but Is it possible for you to give further information on how the gradient is suppose to behave so I can better help you out?
ken0y
Posts: 6
Joined: Tue Oct 31, 2017 8:30 am

Re: Gradient Shader - I'm struggling!

Post by ken0y »

Hi Rick,

Thank you for responding :)

Apologies, I am a shader noob and learning as I go.

I will try my best to describe what I am trying to do:

1. Create 3 gradients, each using 2 colours. Blend gradient using world Y
2. Apply each of these gradients to geometry depending on world normal direction (XYZ)

The problem is that any face normals not perpendicular to XYZ use a blend of the gradients.

Image


Thank you for the help,

Kind Regards,

K
ken0y
Posts: 6
Joined: Tue Oct 31, 2017 8:30 am

Re: Gradient Shader - I'm struggling!

Post by ken0y »

Perhaps I could use a triplanar method to map the gradients?

I'm trying to avoid having to create the UVS myself.

Cheers
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Gradient Shader - I'm struggling!

Post by Amplify_RnD_Rick »

No problem at all, I hope I can help you out.
And thank you for the cool drawing :D
It's quite the interesting challenge. Let me give me some thought and I'll let you know as soon as I figure out something that might help.
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Gradient Shader - I'm struggling!

Post by Amplify_RnD_Rick »

Like you previously said, your solution may come from using a triplanar technique and our Triplanar node would probably do the trick.

After creating the this node you would go to its node properties and set the Mapping option to Spherical. Your gradients would be saved into textures and then set as the Top, Middle and Bottom textures of the Triplanar node.
After that you'll need to play around with the falloff value as it controls the interpolated blend between the projected planes.

Having a big falloff value ( p.e. 100 ) may be what you need, since from your drawing you don't want any blend over angled faces.

Please take a look at the Triplanar Sample node documentation for further details.
http://wiki.amplify.pt/index.php?title= ... nar_Sample
ken0y
Posts: 6
Joined: Tue Oct 31, 2017 8:30 am

Re: Gradient Shader - I'm struggling!

Post by ken0y »

Hi Rick,

thank you for taking the time to reply :)

Just a quick question regarding your solution; How do I go about converting a Lerp to a Texture sample?

Kind Regards,

K
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Gradient Shader - I'm struggling!

Post by Amplify_RnD_Rick »

Hey ken0y,

I do apologize but I'm not quite sure about your last question.

Are you trying to connect a Lerp into the Top, Middle and Bottom Tex ports of the Triplanar Sampler node? These ports can only have Texture Object nodes connected to them and unfortunately you cannot have anything but that connected to them.

Is it possible for you to give a bit of additional information on what you are trying to do?
Post Reply