A multitude of variables are provided to the shaders and can be used by them:

The effects variables


// datas from the vertex shader

in vec4 v_color; // color of the vertex

in vec2 v_texCoords0; // texture 0 coordinates: coordinates in the current layer

in vec2 v_texCoords1; // texture 1 coordinates: not used

in vec2 v_texCoords2; // texture 2 coordinates: not used


// textures

uniform sampler2D f_currentLayerTexture; // id of the current layer texture

uniform sampler2D f_underLayerTexture; // id of the layer under the current layer texture

uniform sampler2D f_paperTexture; // id of the paper texture

uniform sampler2D f_selectionLayerTexture; // id of the selection mask texture


// General parameters

uniform vec2 f_texturePos; // texture top left position in canvas coordinates

uniform float f_textureSize; // texture size

uniform vec2 f_paintedRectPos; // painted rectangle top left position in canvas coordinates

uniform float f_paintedRectWidth; // painted rectangle width

uniform float f_paintedRectHeight; // painted rectangle height

uniform bool f_clipToPaintedRect = true; // true -> clip to paintedRect

uniform bool f_clipToSelection = false; // true -> clip to selection

uniform float f_opacity = 1; // current layer opacity

uniform float f_globalTime = 0; // time elapsed in seconds since application start


out vec4 f_color; // shader output color


Brush engines variables


// datas from the vertex shader

in vec4 v_color; // brush color

in vec2 v_texCoords0; // texture coordinates 0: texture coordinates of the stamp

in vec2 v_texCoords1; // texture coordinates 1: current layer texture coordinates

in vec2 v_texCoords2; // texture coordinates 2: not used


// datas computed for each stamp buffer

uniform float f_radius = 10; // stamp radius

uniform float f_hardness = 1.0; // brush hardness

uniform float f_density = 1.0; // pixels density

uniform float f_flow = 1.0; // brush color flow

uniform float f_opacity = 1.0; // brush stroke opacity

uniform int f_compositionMode = 0; // composition mode

uniform bool f_inheritAlphaUnder = false; // indicates if the brush should blend using the alpha of the layer under the current layer

uniform int f_alphaEquation = 0; // mask equation

uniform bool f_inheritAlphaCurrent = false; // indicates if the brush should blend using the alpha of the current layer

uniform bool f_hasTexture = false; // indicates if the brush has a texture

uniform bool f_preserveTextureColor = false; // indicates if the color of the texture is used instead of the brush color

uniform float f_colorAbsorbtionRate = 0.0; // brush color absorption rate

uniform float f_colorFlowingRate = 1.0; // brush color flowing rate

uniform int f_antialiasing = 0; // antialiasing 0[antialiasing] 1[no antialiasing]

uniform bool f_clipToSelection = true; // indicates if the stamp should be clipped to selection mask

uniform int f_shape = 0; // brush shape 0[ellipse], 1[rectangle]

uniform float f_factor = 1.0; // factor used in composition formula [0, 1]

uniform vec4 f_borderColor = vec4(1, 1, 1, 1); // color of the border of the stamp

uniform bool f_useBorderColor = false; // indicates if border color should be used

uniform int f_stampCount = 1; // stamp count since the beginning of a stroke

uniform float f_random = 1.0; // random number given for each stamp buffer

uniform vec2 f_texturePos; // texture top left position in canvas coordinates

uniform float f_textureSize; // texture size

uniform vec2 f_paintedRectPos; // painted rectangle top left position in canvas coordinates

uniform float f_paintedRectWidth; // painted rectangle width

uniform float f_paintedRectHeight; // painted rectangle height

uniform sampler2D f_currentLayerTexture; // texture id of the current layer

uniform sampler2D f_underLayerTexture; // texture id of the layer under the current layer

uniform sampler2D f_brushTexture; // texture id of the brush texture (if a texture is assigned to the brush)

uniform sampler2D f_colorTexture; // texture id of the color buffer

uniform sampler2D f_selectionLayerTexture; // texture id of the selection mask

out vec4 f_color;