BSL Texture Brush issue

To talk about brush creation and controllers
mysticflavour
 
Posts: 5
Joined: 21 Sep 2016, 22:36

BSL Texture Brush issue

Postby mysticflavour » 23 Feb 2017, 21:32

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

User avatar
u2bleank
 
Posts: 906
Joined: 11 Jun 2012, 10:41

Re: BSL Texture Brush issue

Postby u2bleank » 24 Feb 2017, 15:53

Thanks for this report.
As a wrokaround you can use this code :
Code: Select all
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 );

   return float4(1,1,1,1-color.r) * i.color ;
}

mysticflavour
 
Posts: 5
Joined: 21 Sep 2016, 22:36

Re: BSL Texture Brush issue

Postby mysticflavour » 25 Feb 2017, 19:43

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 :)

User avatar
u2bleank
 
Posts: 906
Joined: 11 Jun 2012, 10:41

Re: BSL Texture Brush issue

Postby u2bleank » 26 Feb 2017, 09:17

no the bottomLayer return the pixel of the currently drawn Layer only ( not the merged version )


Return to Brush Making