#Trying to recreate 4 corner vertex gradient into shader graph

1 messages · Page 1 of 1 (latest)

carmine valve
#

Hey so I'm creating a UI thing for a game and I saw TMP has a vertex gradient thing for a 4 corner gradient for its text, so i wanted to give the box background i gave it the same sort of gradient so I made this:
Problem is it doesn't really feel like I'm 50/50 lerping the colours? at first I wasn't using a multiply node and it was super obvious the colours weren't linearly lerping 50/50 so i added one and it's better but am i missing a way to lerp colours "properly"?

vagrant violet
#

There's many ways to represent color, and to blend it too
The mathematical interpolation rarely matches our perception of colors

carmine valve
#

each colour would have control of its corner and it'd fade into the other colours as it goes outwards
ideally the same as how TMP does it but the screenshot i sent is kinda close but i can tell the colours arent blending 50/50 by looking at the black and white representation

#

here's a cleaner view of it not looking right, where one corner is dark red, one white, and other two black, it feels like the bottom right corner doesnt start out with enough white on it, same with bottom left the red isnt as strong as i'd expect

vagrant violet
carmine valve
#

but ill switch it out for pure red and rescreenshot

#

this also feels like it should be working without me needing to feed a multiply node a specific number like i saw in another video

#

without the multiply node it looks even more off lol

vagrant violet
#

Also, is your project using gamma or linear color space?

carmine valve
#

unsure, where could i check?

vagrant violet
carmine valve
#

yea its linear

#

if possible i'd prefer a solution that would keep it like that, i cant edit some of the project settings cuz of some restrictions i have

vagrant violet
#

Screen space overlay canvases would not be

carmine valve
#

it's in prefab mode and says screen space overlay canvas so i assume not

#

the shader is also HDRP/Unlit cuz i couldnt think of any other shader i would use if that is a problem

vagrant violet
carmine valve
#

would just setting it up in my "Game" view in the specific scene where it'd normally show up be fine?

vagrant violet
#

You should always preview UI through the Game window if that's what you mean

#

As it's camera dependent and scene view is a different camera

carmine valve
#

yeah it seems to still be the same way (ignoring the fact i gotta do something later to make it transparent for the text behind it lol)

vagrant violet
#

Correction, screen space - overlay, not camera

carmine valve
#

oh right lemme check

#

yeah using screen space camera

vagrant violet
#

Camera includes post processing, overlay excludes it

carmine valve
#

huh, turning it into overlay instead of camera does this, that doesnt feel right lol

vagrant violet
#

That's actually expected

carmine valve
#

oh okay

vagrant violet
#

Shaders used on overlay canvas objects should have the Canvas graph type

#

Sprite Unlit might work partially if Canvas is unavailable

#

(but I'd expect them to break / not support canvas features properly)

carmine valve
#

icic

#

so im a tiny bit lost here on if im doing anything wrong haha

vagrant violet
#

Not exactly

carmine valve
#

okie

vagrant violet
#

Which Unity version do you have?

carmine valve
#

2022.3.9f1

vagrant violet
#

So if I recall correctly that one does not support Canvas graphs
You can see how far you get with Sprite Unlit instead
Or use a camera space canvas and deal with the fact that the camera's post processing and tonemapping are also applied to your shader

carmine valve
#

hmm so its the post processing and tone mapping causing my stuff to look like that?

vagrant violet
#

I think so

#

In my end the shader on the canvas looks exactly as it does in SG previews
Unless I enable color correction effects for the camera while using camera space canvas

#

Multiplication by 0.5 is not necessary and will make the gradient less correct

#

But you can use multiplication, power or any other operations that seem to work to offset the effect of the post processing

carmine valve
#

okay yeah i think that makes sense, its a little unfortuante but looks like ill just have to mess with offsetting the effect and just giving very precise colour values for what i need, thanks for the help!

#

now i just gotta figure out how to give it transparency lol