Hi guys,
I've been playing around with Brush Shader Language and made a basic texture brush. However I've run into an issue, might be a bug. The brush works well, but when the last primitive is drawn it does not use the user selected color, instead it uses the color of the texture. You can see the code below and I've added an image where you can see the issue. The user selected color is orange and the texture itself is black and white ( used as alpha channel).
Once I've solved the issue I can upload the finished .bsl file
cfg{ name="Texture Brush";}
globals
{
texture mat;
{
uiName = "Texture";
}
}
float4 main( idatas i )
{
// Transform position to box space 0 - 1.
float2 transPos = i.primBox.toUpperLeftNorm(i.pos);
// Get color from texture.
float4 color = mat.sample( transPos );
// Calculate alpha.
float alpha = smoothLerp(color.r, color.g, color.b );
// Set alpha
color.a = 1.0 - alpha;
// Use color selected by user
color.rgb = i.color.rgb;
return color ;
}
Brush stroke:
Texture used for brush: