Sprite Random

A place to share your brush
User avatar
u2bleank
 
Posts: 1179
Joined: 11 Jun 2012, 10:41

Sprite Random

Postby u2bleank » 21 Sep 2020, 13:26

Hi,

Sprite Random Brush.
Output in random a collection of sprite from a unique texture source.
Each sprite should be placed in a regular grid.
You can specify the size of the grid direcly in the Brush Parameter.

Attachments
sprites random.bkbrush
(12.5 KiB) Downloaded 239 times

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

Re: Sprite Random

Postby u2bleank » 20 Oct 2020, 08:10

this time with a color parameter ;)
Image
Attachments
sprites random.bkbrush
this time with color parameter
(13.28 KiB) Downloaded 210 times

User avatar
neurolinked
 
Posts: 38
Joined: 11 Feb 2014, 11:50

Re: Sprite Random

Postby neurolinked » 29 Mar 2021, 22:39

Hi, i'm playing with the BSL language, in particular with the shaders 'spriteblitter' attacched to this Sprite brush.
I have tried to force minimum and manimum for the input parameter and to fix a problem with the fixed parameter highlighted in the code.

Here's the code

cfg{
name = "spriteblitter_2";
samplerDefault;
{
filter = point ;
adressU = clamp ;
adressV = clamp ;
}
}

globals {
texture tex ;
{
uiName="Sprites";
}

float NbSpriteX = 4 ;
{
uiMin = 1 ;
uiMax = 64;
uiNumPixScale = 1;
uiName = "horizontal";
uiFormat = integer;
}

float NbSpriteY = 4;
{
uiMin = 1 ;
uiMax = 64;
uiNumPixScale = 1;
uiFormat = integer;
uiName = "vertical";
}
}

float hash( float3 n )
{
return frac( sin(dot(n, float3(12.9898, 78.233, 36.791)))* 43758.5453 ) ;
}

float4 main( idatas i )
{

float2 p = i.primBox.toUpperLeftNorm( i.pos );

float2 sizeI = float2(1./NbSpriteX, 1./NbSpriteY );

float maxRepeat = NbSpriteX * NbSpriteY ;

int rndp = maxRepeat * hash( float3(i.time, i.nbUserStroke, i.time) );
int linedimension = floor(NbSpriteX);

p = (p + float2( mod(rndp,linedimension), rndp/linedimension))*sizeI;

float4 col = tex.isEmpty ? float4(p.x,p.y,0,1) : tex.sample( p );
return col ;
}

There are thing that i can't understand why they wont work..

* Why the languange don't respect the uiMin and uiMax that i gave to the parameter for horizontal an vertical grid of the sprite.
* Why if i use the mousewheel to change size of the horizontal or vertical grid it won't step by 1 unit
* Every stroke start a new "line" with the same starting sprite unless i click on the UI of BlackInk and restart drawing

Is it possible to integrate a parameter logger features or function to see what value I'm receiving from certain operation ??


Love your software a lot!


Return to Brush Exchange

cron