Jump to content
How to Install Plugins ×

Cell Texture plugin (12th Nov 2012 - updated to v1.2)


davidf

Recommended Posts

Effects > Render > Cell Texture

Edit: Updated to version 1.2 (no code changes, just made sure it uses the internationalized Render menu instead of the string "Render").

Edit: Updated to version 1.1 (added "Combined" distance type and changed "Multiply" method to "Root sum of squares", which looks a bit nicer - also handled coloring better for this method. See left image in the second row below for an example).

This plugin was inspired by the page:

http://www.blackpawn...ar/default.html

The algorithm can create quite a lot of different texture types:

cell_texture.jpg

The parameters are:

Foreground - the color inside the cells.

Background - the color around the edge of the cells.

Swap background and foreground - exactly what it says!

Avoid border - do not place cells near the edge of the image. If this is not set, the image is tileable (i.e. it wraps around the edges).

Cell size - the side length of the invisible squares the cells are based on (there is one "point", i.e. cell centre, at a random location inside each square - with a slight bias towards the middle).

Intensity - adjust the distance where the foreground turns into the background.

Random color - amount of random color to add to individual cells.

Method - formula to use to determine the color (see the link mentioned above).

Distance - distance metric to use. "Euclidean distance" is distance in a straight line, "Manhattan distance" is the sum of the X and Y differences, "Chebychev distance" is the maximum of the X and Y differences and "Combined" is a combination of all of these.

I'd love to see any interesting uses people find for this ...

(My first plugin created using Visual C#. Yay!)

Download: CellTexturev1.2.zip

By the way, when adjacent cells are different colors, there is no antialiasing at the moment -- I need to investigate the best way to do that.

Known bug: for large cell sizes with "Subtract nearest two neighbors" and "avoid border" both set, there are sometimes some problems near the right or bottom edge of the image.

Edited by davidf
Link to comment
Share on other sites

th_Blueeyes.png

Cool plug-in with heaps of potential, it helped me finish this piece.Cheers for the share.

Great! Took me some time to work out where in the image you used it ...

Link to comment
Share on other sites

May I propose an option to allow a fix position of the nucleus in the cells (i.e. centered). This would allow to create regular textures too.

And a question. Would you provide a code snippet how you are mapping the colors to the gray values generated by the algorithm?

midoras signature.gif

Link to comment
Share on other sites

I couldn't stop to do more experiments using this algorithm to create textures ;-)

I changed the distance function a bit to move the nuclei out of the center of the cells and got the attached images.

Pseudo code:

distance.x = nuclei[ i].x - pixel.x; if (distance.x > 0) distance.x = distance.x * 3;
distance.y = nuclei[ i].y - pixel.y; if (distance.y < 0) distance.y = distance.y * 3;

So this may also be an idea for an additional option: Weight distances in certain directions.

post-79572-0-59572500-1352020294_thumb.j

post-79572-0-64313800-1352020309_thumb.j

post-79572-0-63369800-1352036945_thumb.j

post-79572-0-25963900-1352036967_thumb.j

Edited by midora

midoras signature.gif

Link to comment
Share on other sites

And a question. Would you provide a code snippet how you are mapping the colors to the gray values generated by the algorithm?

The levels are just proportional to the distance from each point. The main algorithm for "nearest neighbor" is:

  • For each square in the grid (side length = "cell size" parameter), pick a random point (the cell centre).
  • For each pixel (x, y), find the distance D to the nearest cell centre and divide by the cell size to give a value W; if W > 1, set W to 1.
  • Linearly interpolate between the foreground and background colour using W: foreground * (1 - W) + background * W.

The "intensity" parameter is also added to W (and the result is restricted to the range 0 to 1).

I changed the distance function a bit to move the nuclei out of the center of the cells and got the attached images.

Pseudo code:

distance.x = nuclei[ i].x - pixel.x; if (distance.x > 0) distance.x = distance.x * 3;
distance.y = nuclei[ i].y - pixel.y; if (distance.y < 0) distance.y = distance.y * 3;

So this may also be an idea for an additional option: Weight distances in certain directions.

I tried it out, and here is the result:

Download: CellTextureWithDisplacement.zip

The new parameters are "X displacement" and "Y displacement". If these values are not zero, the X or Y component of the distance is multiplied by 1 + abs(displacement): if the parameter is less than zero, only negative X/Y values are multiplied, otherwise only positive values are multiplied. If the paramaters are X displacement = 2 and Y displacement = -2, the result is exactly the same as your code above.

I'm not very fond of this variation though (I think it leaves too many empty areas), so I won't make it the official download.

Link to comment
Share on other sites

I'm not very fond of this variation though (I think it leaves too many empty areas), so I won't make it the official download.

I agree, the gaps are getting too large. But there must be a difference in the distance function of our implementations if you are looking too the attached examples. Anyway I didn't expect that you give it a try immediately ;-) Thanks.

I'm more interested in a variant which does not use random positions for the nuclei.

midoras signature.gif

Link to comment
Share on other sites

I'm more interested in a variant which does not use random positions for the nuclei.

The positions are based on a square grid, so using uniform positions doesn't look very interesting -- just a screen full of squares ...

You could try other types of grids (triangular, etc.) but the way I wrote the plugin depends on using a square grid, so it isn't simple to try that out.

Link to comment
Share on other sites

I'm expecting you are using squares to speed up the calculation of the pixels minimal distance value.

In general I like both regular and more irregular textures. It depends what you like to achive in your image.

Attached are examples of textures generated using the algorithm with centered nuclei.

post-79572-0-34137900-1352100395_thumb.j

post-79572-0-05766100-1352100423_thumb.j

midoras signature.gif

Link to comment
Share on other sites

It looks like that the plugin does not return SubmenuNames.Render in the StaticSubMenuName function instead it seems to use "Render".

Thanks, I didn't know about that -- the .zip file in the original post has been updated to version 1.2 now (this is the only change, so no need for English speakers to re-download).

How do you learn about these kinds of things? The template code I was using didn't have this information. I'd love it if there was a "complete guide to writing PDN plugins" ...

Edited by davidf
Link to comment
Share on other sites

How do you learn about these kinds of things? The template code I was using didn't have this information. I'd love it if there was a "complete guide to writing PDN plugins" ...

Looking to more templates. Using F12. I agree that the situation is not quite comfortable for developers.

The first thing I'm doing when I start to develop on a new environment is to create a new document about the environment. Everytime I'm figuring something out, there will be a remark in this document. So I'm entering links, code snippets and more. All depends on the quality of the original documentation.

I.e. two weeks ago, I decided to check if IndirectUI is usefull. Everytime I needed a new control type I added a new section about this type. This collects all the kind of information you do not have an idea about when you are starting. Like that the color you are providing to the colorwheel must be opaque (or you are getting an exception).

At some time we may just start new topics in the Plugin Developer Central and add all the things we are figuring out.

I detected the 'Render' issue when I tested a plugin after switching Paint.NET to German. Suddenly there was an additional submenu 'Render' containing your (but not only your) plugin. Most Render plugins poped up under the german entry.

midoras signature.gif

Link to comment
Share on other sites

This got updated...tomorrow D: <downloads plugin from the future>

No, Paint.NET is not spyware...but, installing it is an IQ test. ~BoltBait

Blend modes are like the filling in your sandwich. It's the filling that can change your experience of the sandwich. ~Ego Eram Reputo

Link to comment
Share on other sites

  • 5 years later...

<3 Dear @lifeday! That's just so awesome! :star: Keep it up! Thank you for the sharing. :coffee: :cake:

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...