BSL Texture Brush issue
![Post Post](./styles/prosilver_se/imageset/icon_post_target.gif)
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![smile :)](./images/smilies/icon_smile_2.png)
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](http://orig08.deviantart.net/e5fd/f/2017/054/9/f/9fb6e7c15fef304085ccaa19803a021e-db045yb.png)
Texture used for brush:
![Image](http://orig04.deviantart.net/0035/f/2017/054/f/f/ffe1e80e1474216c28ac405d54805fd6-db0472x.png)
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
![smile :)](./images/smilies/icon_smile_2.png)
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](http://orig08.deviantart.net/e5fd/f/2017/054/9/f/9fb6e7c15fef304085ccaa19803a021e-db045yb.png)
Texture used for brush:
![Image](http://orig04.deviantart.net/0035/f/2017/054/f/f/ffe1e80e1474216c28ac405d54805fd6-db0472x.png)