send data outside fragment area.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By catafest

The debug tell me is an error about the uv :
Invalid arguments to operator "- " : int and float
from here:

vec3 colW = mix(vec3(0.0), vec3(0.3), 1 - uv.y);

I think is a problem with sending data from fragment area to another function.
The code I used is derived from https://www.youtube.com/watch?v=vPYu2PTSBHQ.
This is my full source code:

shader_type canvas_item;
render_mode blend_mix;

vec3 flag_test(vec2 uv){
		vec3 colG = mix(vec3(0.0), vec3(1.0), step(0.67, uv.x));
		vec3 colB = mix(vec3(0.0), vec3(0.76), step(0.67, uv.y));
		vec3 colW = mix(vec3(0.0), vec3(0.3), 1 - uv.y);
	return colW+colG+colB;
}

void fragment() {
vec3 col;
float a = 1.0;
vec3 colX;
vec3 colY;

vec2 position = vec2(UV.x-0.1, UV.y-0.1)*1.25;
if (abs(1-position.y) < 1.0)
	{
		if(abs(position.y) < 1.0){
			colY = flag_test(position);	
			}
	}
if (abs(1- position.x) < 1.0 )
	{ 	
		if(abs(position.x) < 1.0){
			colY = flag_ro(position);	
			}
	}
col = colY+colX;	
if (col ==vec3(0.0)){ a = 0.0;}
COLOR = vec4(col,a);
}

Doesn’t that error mean that you can’t do a 1-uv.y because one is an int and the other is a float? Have you tried 1.0-uv.y?

p7f | 2019-01-15 19:49