[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 154: preg_replace_callback(): The /e modifier is no longer supported, use preg_replace_callback instead
Bleank • View topic - BSL Texture Brush issue
Page 1 of 1

BSL Texture Brush issue

PostPosted: 23 Feb 2017, 21:32
by mysticflavour
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:
Image

Texture used for brush:
Image

Re: BSL Texture Brush issue

PostPosted: 24 Feb 2017, 15:53
by u2bleank

Re: BSL Texture Brush issue

PostPosted: 25 Feb 2017, 19:43
by mysticflavour
Thanks for the reply :)

Btw, is there a way to get the pixel information from just the current layer? As I understand it, the bottomLayer function gets the value of all layers, i.e. the canvas. Hope my question makes sense.

Keep up the great work :)

Re: BSL Texture Brush issue

PostPosted: 26 Feb 2017, 09:17
by u2bleank
no the bottomLayer return the pixel of the currently drawn Layer only ( not the merged version )