#simple gradient shader
1 messages · Page 1 of 1 (latest)
here are the previews:
it seems even unity knows what's happening
object space must not really go from -1 to 1
1 question, why are you adding 1 and multiplying by 0.5?
if we imagined it did go from -1 to 1:
adding 1: now it's 0 to 2
dividing by 2: now its 0 to 1
perfect for lerp
what is saturate doing?
makes sure values dont go below 0 and beyond 1
that definitely looks like 0-1
but the 0 starts at the center
making the overall shape -1 to 1
it seems 0 is at centre but its at the bottom
maybe you can remove the saturate node and check?
sure
saturate appears unnecessary likely because sample grad already clamps to 0-1
yeah you're right
I may have to continue ignoring this behavior
you can add an offset to the shader by subtracting x value from the object space Y axis. put it right after the split
but that offset would have to be different per object
the key may be relying on UVs instead of vertex position
but Im not good with UVs yet
Oh you just have to swap out the object space node with the uv node
Object space is not clamped to any value
If you have a 5x5x5 cube, the tallest point in object space is 2.5, lowest point -2.5
Sampling a gradient works in 0-1 range, but you can multiply or remap it to a different range
in: 0, 1 out: -2.5, 2.5 in case of a 5 unit cube
If you want the gradient to adapt to an object's dimensions, you need to get them from the bounds outside of the shader and pass them in as properties
This is what Blender does with its "generated" texture coordinates which you may be confusing object space with
Ahh okay, so normalisation has to be done explicitly