@lawnjelly Hello and thanks for your answer. I dont fully understand.
In SFML i have a circle object that is my brush. Its color and alpha is all zero.
Then i have a shader ON this brush object.
The shader has a color glFragColor.rgb and the alpha is glFragColor.a = GradientAlpha
Then on every mouse change i stamp down this circle object with the shader onto a RenderTexture with a previously set BlendMode.
So where in this process do i have to introduce a "first" and "second" pass?
As far as i know i can only draw the whole thing at once to the RenderTexture (i might be wrong).
This is my shader code. (expand creates the gradient / alpha is an additional transparency(opacity))
const char VertexShader[] =
"void main()"
"{"
"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
"gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;"
"gl_FrontColor = gl_Color;"
"}";
const char RadialGradient[] =
"uniform vec3 color;"
"uniform float alpha;"
"uniform vec2 center;"
"uniform float radius;"
"uniform float expand;"
"uniform float LayerHeight;"
"void main(void)"
"{"
"vec2 SfmlCenter = vec2(center.x, LayerHeight - center.y);"
"vec2 p = (gl_FragCoord.xy - SfmlCenter) / radius;"
"float d = length(p);"
"float GradientAlpha = smoothstep(0.0, 1.0 - expand, 1.0 - d);"
"gl_FragColor.rgb = color;"
"gl_FragColor.a = GradientAlpha - alpha;"
"}";