Page 1 of 1

Help with shaders

Posted: Mon Apr 22, 2019 10:13 pm
by ITISTHEBKID
I currently have this code:

Code: Select all

[[
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
		vec4 pixel = Texel(texture, screen_coords);
		vec2 coords = vec2(texture_coords.x,screen_coords.y+1);
		vec4 Upixel = Texel(texture,coords);
		if (Upixel.a < pixel.a){
			float average = (Upixel.a+pixel.a)/2;
			Upixel.a = average;
			pixel.a = average;
		} 
}
]]
The problem is when I draw a circle, the shader does not rise at all(I'm creating a smoke shader), and cannot seem to get the alpha of pixels from outside the circle

Re: Help with shaders

Posted: Mon Apr 22, 2019 10:46 pm
by pgimeno
The texture_coords of a circle or rectangle or line are always vec2(0,0), because the texture is just one white pixel (or at least it behaves as if it is). I can't look into your shader in enough detail now but maybe that info helps.

Re: Help with shaders

Posted: Mon Apr 22, 2019 11:42 pm
by 4vZEROv
Draw your circle on a canvas and then use the shader on the canvas