Rounded-corner Square-brush

To talk about brush creation and controllers
jaycephus
 
Posts: 23
Joined: 03 Jan 2014, 06:47

Rounded-corner Square-brush

Postby jaycephus » 24 Dec 2019, 21:01

I'd like to have a brush that is square with rounded corners to make flat, even strokes, but the square orients to the direction of stroke. (so with all the usual pen-pressure modifiers turned off, it just makes an even, uniform stroke)

The base shape would look something like the attached picture.
Shape_Ink_05.jpg
brush shape
Shape_Ink_05.jpg (10.16 KiB) Viewed 2348 times


The desired straight-line stroke would just be an elongated version of the attached brush shape pic, a long rectangle with rounded corners.

(As a suggestion, a primitive like this with specified corner radius would be good, I think. I'd love to have the softer corners for all the various scatter brushes that currently exist.)

If it is possible to make this, currently, just give me some tips (like a good existing-brush to edit).

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

Re: Rounded-corner Square-brush

Postby u2bleank » 06 Jan 2020, 16:31

yes it's possible with the right BSL code.
I don't have time right now to code it for you but you can have a look on this page to help you.

PS : if you can't make it I'll make a little video or I'll code this form.

tal-kai
 
Posts: 3
Joined: 14 Feb 2020, 06:44

Re: Rounded-corner Square-brush

Postby tal-kai » 14 Feb 2020, 06:46

Very interested on this part. Seen bunch of photoshop artists using customized brusheswhen they do their art.

mrange
 
Posts: 7
Joined: 06 Mar 2020, 22:22
Location: Oslo

Re: Rounded-corner Square-brush

Postby mrange » 06 Mar 2020, 22:28

Hi.

I know a too little to create a great brush for you but I know some things about distance functions that produces rounded corners.

Code: Select all

// From: http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
float sdRoundedBox(float2 p, float2 b, float4 r)
{
    r.xy = (p.x>0.0)?r.xy : r.zw;
    r.x  = (p.y>0.0)?r.x  : r.y;
    float2 q = abs(p)-b+r.x;
    return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x;
}

// Produces the final distance field
float df(float2 p)
{
  float d = sdRoundedBox(p, float2(1000.0, 1000.0), float4(200.0, 200.0, 200.0, 200.0));

//  d = abs(d) - 20.0;

  return d;
}

float4 main(idatas i)
{
  float fuzzy = 1.0;
  float d = df(i.pos - i.strokePos);

  float s = smoothstep(-fuzzy, fuzzy,d);
  float4 b = float4(0.0, 0.0, 0.0, 0.0);
  float4 col = lerp(i.color, b, s);
  return col;
}


This produces a rounded box of hard coded size and dimensions. I am looking for documentation on the idatas input that could help me make it more intelligent but so far I haven't found that doc.

Just for your information: sdRoundedBox produces a so called distance field for a rounded box. The property of a distance field is if it returns 0 then we are on the "surface" of the shape. 1 means we are 1 pixel from the shape, -1 we are in pixel inside the shape. This is a very powerful abstraction to create complex and interesting shapes.
--
mrange

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

Re: Rounded-corner Square-brush

Postby u2bleank » 22 Mar 2020, 12:07

mrange : nice answer :yeah:
moreover the BSL doc is here ( you will find reference on idatas, etc.. )


Return to Brush Making

cron