4
$\begingroup$

This is my very first day of learning Open Shading Language. I have watched few videos in Youtube and learned a little.

Right now, for learning purpose only, I want to know what OSL codes can draw one black circle against the white ground of plane, but I can't find any tutorial to teach me that.

Next, I want to know how to do a circle grid like this below.

enter image description here And this too.

enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

These scripts will create two nodes. The first one is for the grid and the second one for the circle. By changing the size of the grid, you will have more or less circles. By changing the radius, you will have bigger or smaller circles.

enter image description here

shader Tiles2D(
    point Vector = P,
    float Size = 1,
    float Offset = 0,
    output vector Tiles = vector(0,0,0)
)
{
   Tiles = Vector * Size;
   Tiles[2] = 0;
   Tiles[0] += step(1,mod(Tiles[1],2)) * Offset;
   Tiles -= floor(Tiles);

}
shader Circle(
            point Vector = P,
            float Radius = 0.5,
            output float Fac = 0)
{
    vector st = Vector;
    vector dist = st - vector(0.5,0.5,0);
    Fac = smoothstep(Radius*0.99, Radius * 1.01,dot(dist,dist)*4);
}

Results

$\endgroup$
4
  • 4
    $\begingroup$ Hi. Would be useful if you could include the actual code in the question body to save people typing out the code from the images. Thanks. $\endgroup$ Commented Feb 17, 2020 at 16:48
  • $\begingroup$ @RPSebb, thank you very much. You are a star. $\endgroup$ Commented Feb 17, 2020 at 17:52
  • 1
    $\begingroup$ Consider to accept the answer @RitaGeraghtystandsbyMonica $\endgroup$
    – brockmann
    Commented Feb 18, 2020 at 18:11
  • $\begingroup$ @brockmann done, and thank you for reminding me. $\endgroup$ Commented Feb 19, 2020 at 13:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .