How to set Transparency gradually in a TextureRect?

Oh good to see

I wanted to mention another route in using the UV’s of the texture rect to do the same thing, something like:

float remap(float value, float in_min, float in_max)
{
	return (value - in_min) / (in_max - in_min);
}

void fragment() 
{
	float fade_value = 1. - (distance(UV, vec2(.5,.5)) * 2.);
	fade_value = remap(fade_value, .05,.3);
	COLOR.a = mix(0.,1., fade_value);
}

Unless the UV’s are odd for the rect, this would be agnostic towards the placement and size of the rects.

The remap there is to take in a min/max for the fading edge to control it, which can be a parameter, for instance below is a large fade distance, then a shorter one that starts out past the middle. Adding a power function to this would further add some shape to the gradient.

1 Like