Showing posts sorted by date for query planks. Sort by relevance Show all posts
Showing posts sorted by date for query planks. Sort by relevance Show all posts

Floor board add-on (a.k.a. planks) updated for Blender 4.1



It is always good to hear that people are using an add-on, and this time I got a request to update my floor board generator for Blender 4.1.

Blender changes all the time and this time 4.1 even broke the old version of the add-on. Fortunately it was pretty easy to fix, so I am happy to announce that a new version is available on GitHub. [click download in the upper left corner]

If you want to know more about what the add-on can do, check this older article on my blog.

This version also incorporates a few small tweaks:

  • the bevel modifier now uses percentage as the default. This gives more consistent behavior across different patterns,
  • the bevel modifier now also has the harden normals option checked, which gets rid of quite a few shading artifacts,
and a new pattern: Chevron



floorboard add-on: Blender 2.80 compatible version available

A new version of the floorboards add-on that is compatible woth Blender 2.80 is available on GitHub. (this is a single python file: select File->Save As... from your browser and save it somewhere as planks.py. Then in Blender, select File->User preferences->Add-ons->install from file... (don't forget to remove an earlier version if you have one).

It is a pretty minimal port, i.e. I only made the necessary changes to make it run on 2.80 but to be honest, the add-on shows its age. The coding isn't very elegant and there are still a number of known issues. Nevertheless, it's a start, so enjoy!

PS. there are quite a few articles on this blog that talk about this add-on, check here for a list.

Floor boards add-on: random thickness

Acting on a question from Ákos I added a random thickness option to the add-on.

The new version is of course available on GitHub. (this is a single python file: select File->Save As... from your browser and save it somewhere as planks.py. Then in Blender, select File->User preferences->Add-ons->install from file... (don't forget to remove an earlier version if you have one).

If you select a non-zero thinkness each plank gets a random extra thickness up to the chosen maximum.

The option is located together with the other randomization options (which can be applied in parallel.)

Floor boards add-on: minor feature added

Prompted by a question from Trevor I added a Restricted random mode to the uv randomization. It still randomizes the position of planks on the uv-map but keeps them inside the original bounds. It does this simply by not moving a uv map of a plank at all when the move would result in any portion of the plank ending up outside the bounds. The result is a compacter randomized uv-map which should make it somewhat easier to use with non-tiling textures, i.e. reduce the area of the textures that is not used.

The new version is of course available on GitHub.

The difference is illustrated in the image below where I have contrasted the random uv-map in orange with the restricted uv-map in green

Sample artwork with ProWood shaders

I started playing around with Karl Andreas Gross' ProWood Shader pack and after some twiddling around I must say I like it:

In this example scene (a scene from Chocofur) I used the beech preset material for the chair (the chair is also from Chocofur. Note that I dropped the bundled textured material and replaced it by the ProWood procedural material). I picked the colors to match and upped the brightness and the reflectivity a bit to get the varnished look of the steam-pressed plywood of the chair. The books were generated by the book wizard cover generator.

For the floor (generated with my floorboard add-on) I used the material preset that is included in the shader pack specifically for the add-on, in this case oak. I just changed the colors. I had to changed the profile in bevel settings of the floor to 0.69 to prevent strange shadows. That has nothing to do with the shaders but everything with the geometry of the planks my add-on is generating, so it might be a good idea to make this the default in future versions.

Floorboard add-on gets Versaille pattern

From time to time I keep on developing my floorboards add-on an I am happy to present a new option: the Versaille pattern.

(click to enlarge)

It was quite fiddly to get it right but now it looks fine. (Thank you Spirou4D for pointing out the issues with the center configuration).

This pattern offers the same options as the other pattern: you can add randomness to the planks, gaps between them, shift the origin, etc. etc. The generated uv-map (in Shuffle and Packed modes) aligns the uv coordinates in such a way that all are aligned along the longest axis of a plank. This means that if you have a single wood texture with the grain running in a certain direction, planks that are rotated still have a uv parallel to the grain, as it would probably be in reality. An example with a simple stripe material is shown below (note that each plank also has a different color in a vertex color layer that you can use to slightly randomize the material of each individual plank)

The pattern has border planks that are arranged in a symmetrical manner: 2 short horizontal ones,2 slightly longer vertical ones. Selecting the Switch option will change this to 4 identical planks arrange in a clockwise fashion.

An overview of the different articles that highlight all the options of the add-on can be found here.

Availability

The latest version is as always available on GitHub.

WIP: versaille pattern for floorboard add-on

I am currently working on an addition to my floor boards add-on for blender, the pattern often referred to as Versaille parquet.

I have implemented the simplest variant and am looking for a way to align the uv so the grain runs along with the length of the planks. With some manual tweaking it is already possible to get a decent result:

Small additions to the floor board generator add-on for Blender

The floor boards add-on most recently described in this article got a minor update: by request I added options to rotate and scale the generated uv-map. Although this might done in the uv image editor as well, any actions there would be overwritten when changing the floor boards mesh again with the add-on. Of course a uv map can be tweaked in the material just as well with a vector mapping node for example, so which method you prefer is a matter of taste. The defaults are such that it shouldn't break existing objects/materials.

Another option that is now visible is 'Keep materials'. This was on by default but not exposed in the options. You can now uncheck it if you like in which case any associated materials will be removed from the object. This is of questionable utility, but I'd rather not keep an option hidden.

The UV randomization drop down now offers a Packed option: instead of randomizing uvs it lets all the uv coordinates of planks start at (0,0) without altering the scale. This might come in handy when texturing planks with small and non tileable images. (It will look repetitive but that way it won't show seams)

I also fixed a rather embarrassing normal problem. Thank you maraCZ for pointing it out so clearly.

Known bugs

Under certain circumstances the generated mesh will contain doubled vertices. I think this is caused by Blenders boolean modifier. (To simplify the code we generate a pattern that is guaranteed to be big enough and then cut it to size with a boolean modifier). For now, if you see strange lighting artifacts, go to edit mode, select all and choose remove doubles. I will look into this later.

Availability

The code is a single file, available on GitHub.

Floor boards revisted

or why a bit of competition is a good thing

A while ago Cedric Brandin (clarkx at BlenderArtists) was working on an addon that could produce parquetry patterns and because he knew my floor boards addon he asked me some small code specific questions. I was happy enough to help him out of course and he went on to create a very useful addon.
But the idea of patterning a wooden floor sounded to me like a great addition to my addon, and I kept thinking about it. I even looked at his code and in the end decided to incorporate the idea of parquetry patterns. I didn't actually use any of the code because it proved to be difficult to merge the different styles of coding but I owe him a big thank you for the idea.


I did not yet implement all the different patterns but each pattern gets the same benefits as the regular flooring, including randomization options, modifiers and the option to use a floor plan.
At the same time I cleaned up the code, made the interface a bit more use friendly, made it possible to assign materials and keep them through changes and provided more efficiently packed uv maps.
In the near future I might add some additional parquetry patterns. The code itself is quite modular so this should be easy enough to do.

Code availability

The new version (20150320) is available from GitHub.

New features

patterns
currently just regular flooring, herringbone parquetry and square, alternating tiles
materials
assigned to the flooring are now retained even if you change the flooring later (thank you Lell for the suggestion)
size
The length and width of the flooring are now exact (any excess is trimmed of with the bisect_plane modifier)
uv-maps
randomized uv-maps are now packed more efficiently (in 'Shuffle' mode)

Known bugs and misfeatures

  • matching a floor to a floorplan is buggy: Blender's booleans don't seem good enough to deliver quality results, showing odd behaviour when the gaps between planks are small. Also if the floorplan is not 2D, the addon crashes.
  • The randomized uv-maps are still not packed in an optimal way
  • The default values for the bevel modifier are awful
Any comments are welcome of course and this BlenderArtists thread might be the best place for discussion.

Floor board generator, using a floor plan




I have started on the support for a floor plan, i.e. restricting the generated planks to some outline. This feature is very much a work in progress but it is already useable:
It works by adding and applying a boolean modifier to the generated floorboards.

The current [updated] workflow is like this:
  • select your floor plan, make sure it is flat, has a number of faces selected and the face normals pointing up:

  • position the 3D cursor just outside the bottom left corner of the floor plan
  • choose Add -> Mesh -> Add floor board mesh
  • adjust the number of planks and their length (in the modifier tab!)

    • select 'use floorplan' and select your floor plan mesh

      What is left to automate is probably to make sure the floor board is position at the lower left corner of the floor plan because that is easy to forget. You can change the position of the generated floor board but then you have to tweak some attribute (like the number of planks for example) to make it calculate a new floor board, which is ugly.

      For those who find a video easier to understand, here's a short screencast of the workflow:


      Code availability


      You can download version 0.0.15 form GitHub to try out this new functionality. If you already installed a previous version don't forget to remove the old version before installing the new one. (You can remove an old version by deleting the file planks.py from your Blender addons directory (on Windows typically in C:\Users\<your user name>\AppData\Roaming\Blender Foundation\Blender\2.71\scripts\addons )

      Known issues

      The sides of the planks are currently not properly uv mapped, something that may show when large gaps are used.

      Previous articles on the floor board addon

      The development and use of this addon is documented in several earlier articles:

      Part I initial version
      Part II random uv-coordinates
      Part III random vertex colors
      Part IV additional options
      Part V randomization
      Part VI small enhancements

      It is also extensively discussed in this BlenderArtists thread.

      Generate floor boards quick and easy, part VI

      This version (0.0.8) of the floor board generator adds options to add twists and hollow curvature to the individual planks. This is useful when creating floors in older houses and its more subtle simply rotation planks. All the options are now visually grouped as well to aid the user in locating related options.


      An example (with a flat material to emphasize the subtle curvature) is shown below (click to enlarge):

      The option values used to create the image are shown in the next image. Note that for illustrative purposes we made the gaps between the planks quite large:

      Parameterization

      The biggest change in this version was already visible in the image above: parameters no longer appear in the toolbar but in the FloorBoards section of the modifier options. This is not only a visual change but it actually means that even after savinf the .blend file all relevant parameters are retained along with the abject and can be tweaked at any time. (Thanks floric for the code adaptation and DragonLEE for the original idea)

      Generate floor boards quick and easy, part V

      This version (0.0.7) of the floor board generator adds options to add small random rotations to the individual planks. This is useful when creating floors in older houses. All the options are now visually grouped as well to aid the user in locating related options.

      An example (with exaggerated values for the rotations) is shown below (click to enlarge):

      The option values used to create the image are shown in the next image. Note that for illustrative purposes we made the gaps between the planks and the random rotation values quite large:

      Generate floor boards quick and easy, part IV

      In a previous post I added some extra functionality to the floor board generator and based on user feedback and code contributions there are now some more options:

      • the offset can now be random for each individual row of planks (thanks Alain for your contribution)
      • adding modifiers is now optional (but on by default)
      • adding random offsets to the uv-map for each plank is now optional (but on by default)

      Code availability

      This new version (0.0.6) is available for download from GitHuband is tracked in the Blender extensions tracker as well.

      Random Vertex Colors, a simple addon

      In a previous article I presented an addon to generate a floor board with individual planks. Each individual plank was adorned with a random vertex color that can be used to create materials with random color variations for each face.

      When working with the Ivy Generator recently I wanted this same feature and indeed my own space tree addon could benefit from this as well, because just like IvyGen it generates a single mesh object with a face. for each leaf. So I decided to separate this functionality from the floor board generator so it can be used in different situations.

      Once the addon is installed it can be used on any mesh object when in vertex paint mode as shown below:

      It will replace the vertex colors of the active vertex color layer with colors that are random but equal for each face. In Cycles vertex colors can be accessed with an attribute node, an example node setup can be found in the article on the floor board generator referred to at the start of this article.

      Code availability

      All functionality of this add-on plus a lot more is now available as a convenient all-in-one add-on on BlenderMarket. It comes with an extensive PDF manual and your purchase will encourage me to develop new Blender add-ons.

      The simple code shown in this article is available for download at GitHub and is uploaded to the upload section of Blender extensions tracker so if you find bugs you may post them there as well.

      [2016 Feb 7] The version currently in GitHub is much faster for large meshes because it uses Numpy. Check this article to see why.

      Generate floor boards quick and easy, part II

      In a previous article I presented a simple script to generate floor boards with real geometry. Since then I enhanced this with an option to generate uv coordinates as well, with a random offset for each individual plank. This option not only relieves the user of the need to create a uv map but the random offset will break the unwanted illusion that all planks are perfectly sawn from a single endless pices of wood.

      The image in the example on the left (click to enlarge) was generated with the wood shader presented earlier but similar effects can be obtained by applying a tiled image (which of course should not depict planks already), for example PlywoodNew0050 from CGTextures would work nicely I think.

      The updated script (version 0.0.3) is available from GitHub and is tracked in the Blender Bug Tracker as well. Version 0.0.3 also has its hard limits on plank length etc. removed. The are replaced by soft limits so if you want you can make planks shorter than 50cm or narrower than 10cm by explicitly typing in a value.

      Generate floor boards quick and simple

      I am updating this addon, check for an update this article.

      I am currently enrolled in Andrew Price's Architecture Academy and in one of his tutorials he mentioned how easy it would be to have a simple script that could create floor boards suitable for architectural renders like those available in some other modelling packages. He even thought about asking someone to develop it but for some reason or other it never came te be.

      Add Floor Boards

      Because I think it would make a useful addition to the ArchViz' modeller 's tool set I put together a simple script Add Floor Boards. Once installed it can be found in the Add->Mesh menu at the to of the 3D view. Slap on a decent wood shader and you have a floor with real geometry in a few seconds.

      The object that is generated by the script is a simple collection of rectangular faces adorned with a solidify and a bevel modifier so you can tweak some stuff even after the tool properties are no longer accessible.

      Installation

      • Download the script from GitHub
      • Click File->User Preferences->Addons and click the install script from file
      • Don't forget to enable the add-on, it can be found in the Add Mesh section

      Usage

      After clicking Add->Mesh->Add Floor Board a default floor board is generated. The tool options should be self explanatory and are shown below:

      Note that the measures are in blender units and the defaults reflect typical oak boards available at my local floor board dealer and are denoted in meters. (If you do archviz work it makes sense tp select some units in the scene options). Note that the variations in length and width are added to the base measurements so set them to zero if you want comlletely regular planks (a fixed width is quite common, a fixed length not so much as it leads to waste).

      An OSL wood knot shader

      Back in january I presented a wood shader that produces decent results but one of things that was missing was a way to add realistic knots to planks. In this article a present a shader that is meant as a first step in producing knots. It is not a finished shader yet, but it is fully functional as a texture warping tool and in a future article I might detail how to combine it with a wood shader and a shader to texture the inside of the knot properly. Because that will take some time so I thought it better to present it as a WIP as I am currently unable to spend more than a few minutes behind my desk (and there's no Blender for Android alas).

      Warping space

      The idea is quite simple and might be adaptable to more than just producing knots: we distribute points randomly and warp the position coordinates around these points. These warped coordinates are then used as the basis for a texture. In the example image we use the warped coordinates as the input to a bands texture:

      As you can see the bands of the texture seem to flow around the knots as if they were repelled by them and in fact that is pretty much how the algorithm works.

      Implementation


      int bend(vector p, vector k, float r, float a, float m, output vector B){
      vector D = k - p;
      float L = length(D);
      if( L < r ){
      float c = L/r;
      float d = m * pow( 1 - c , a);
      if( d < L ){
      B = d * normalize(D);
      return 1;
      }else{
      B = D;
      return 2;
      }
      }
      return 0;
      }

      shader knot(
      vector Pos = P,
      float Scale = 5,

      float R = 0.8,
      float Falloff = 1,
      float Strength = 0.9,
      float Knots=0.5,

      output vector Vec = P,
      output float Fac = 0
      ){
      vector p = Scale * Pos;
      vector sdp = 0;

      float TR = ceil(R);
      for(float dx=-TR; dx <= TR; dx++){
      for(float dy=-TR; dy <= TR; dy++){
      for(float dz=-TR; dz <= TR; dz++){
      vector ip = floor(p)+vector(dx,dy,dz);
      for(int ik=0; ik < (int)Knots; ik++){
      vector k = noise("cell",ip,ik);
      vector dp= 0;
      int ret = bend(p,ip+k,R,Falloff,Strength,dp);
      if(ret != 0){
      Fac=max(Fac,ret==2);
      sdp+=dp;
      }
      }
      if( noise("cell",ip,-1) < mod(Knots,1.0) ){
      vector k = noise("cell",ip,-2);
      vector dp= 0;
      int ret = bend(p,ip+k,R,Falloff,Strength,dp);
      if(ret != 0){
      Fac=max(Fac,ret==2);
      sdp+=dp;
      }
      }
      }
      }
      }
      if( Fac < 1 ){
      Vec = p + sdp;
      }else{
      Vec = sdp;
      }
      }
      The magic is in the bend() function. It calculates the difference vector from the point being shaded to the center of the repulsion. If the distance is short enough, a translation vector is returned that is a distance dependent fraction of the difference vector. It takes some thinking to see that in order to create the illusion of repulsion we actually have to replace the point being shaded towards the center of repulsion: remember that at the point we are shading we want to see the lines closer to the center.

      When we calculate the translation towards the center and we are close enough to it, we might overshoot the center point. In which case we return a value of 2, signalling we are inside the knot and return not the translated shading point but the vector pointing to the center (which might be useful to render some concentric pattern in the knot).

      The shader itself is nothing more than checking if we might be in range of one of the randomly distributed points and calling the bend() function to do the actual work. We do allow for a fractional number of knots per unit cell, in which case the fraction acts as the probability that a knot might occur.

      Room for improvement

      Obviously knots are not spherical marbles embedded randomly in some wood but as the remnants of branches they are more reminiscent of stubby cylinders which might be better modeled by determining the distance to a randomly oriented line segment instead, something I intend to implement in the near future.

      Another area that needs attention is to way the inside of the knot appears. In the example setup we produced some concentric circles but a real knot is a bit more complex than that.

      An OSL Wood Shader for Blender Cycles

      Good looking procedural wood is not that simple to implement but fortunately for us their is a whole host of renderman shading experience available online. Based on a shader by Larry Gritz we implement a fairly realistic wood shader in OSL.

      Both the dark wood of Suzanne and the torus and the lighter wood of the planks they are resting on was done with the shader we present in this blog article. The algorithms used to produce the ring and the grain are essentialy the same as those implemented in Larry Gritz' oak shader. However, Open Shading Language (OSL) is not quite the same as Renderman so there was in the end quite some adaptation needed.

      Beside syntactic differences between RSL and OSL, the main differences are that OSL provides us natively with snoise() functions but on the other hand, a function like area() doesn't seem to work well and neither are the derivative functions. However, because of the inherent antialiasing in Cycles we don't have to bother much about filter width (as we would have in other types of render engines) so we can do without I think. Functionally the biggest adaptation was that the original implementation provided a complete lighting model (a closure) for the wood shader while we adopt a more modular approach provinding color and displacement output that can be combined with existing closures for maximum flexibility. See the node setup at the end of the article for an example.

      The code is for the OSL shader is shown below. Implementation mistakes are mine but the credits go to Larry Gritz:


      // for the original renderman shader, check http://www.larrygritz.com/arman/materials.html

      // adapted from larry gritz advanced renderman patterns.h
      float smoothpulse (float e0, float e1, float e2, float e3, float x)
      {
      return smoothstep(e0,e1,x) - smoothstep(e2,e3,x);
      }

      /* A pulse train of smoothsteps: a signal that repeats with a given
      * period, and is 0 when 0 <= mod(x/period,1) < edge, and 1 when
      * mod(x/period,1) > edge.
      */
      float smoothpulsetrain (float e0, float e1, float e2, float e3, float period, float x)
      {
      return smoothpulse (e0, e1, e2, e3, mod(x,period));
      }

      // adapted from larry gritz advanced renderman noises.h
      /* fractional Brownian motion
      * Inputs:
      * p position
      * octaves max # of octaves to calculate
      * lacunarity frequency spacing between successive octaves
      * gain scaling factor between successive octaves
      */

      /* A vector-valued antialiased fBm. */
      vector vfBm (point p, float octaves, float lacunarity, float gain)
      {
      float amp = 1;
      point pp = p;
      vector sum = 0;
      float i;

      for (i = 0; i < octaves; i += 1) {
      vector d = snoise(pp);
      sum += amp * d;
      amp *= gain;
      pp *= lacunarity;
      }
      return sum;
      }

      // adapted from larry gritz oak.sl and oak.h
      // original comments between /* ... */
      // my comments start with //
      // note that I dropped the whole filterwidth stuff, partly
      // because I don't think it necessary in Blender Cycles, partly
      // because the derivatives and area() function doesn't seem to work (yet)
      // all specialized snoise defines are replaced by snoise() function calls
      float oaktexture (point Pshad,
      float dPshad,
      float ringfreq,
      float ringunevenness,
      float grainfreq,
      float ringnoise,
      float ringnoisefreq,
      float trunkwobble,
      float trunkwobblefreq,
      float angularwobble,
      float angularwobblefreq,
      float ringy,
      float grainy)
      {
      /* We shade based on Pshad, but we add several layers of warping: */
      /* Some general warping of the domain */
      vector offset = vfBm(Pshad*ringnoisefreq, 2, 4, 0.5);

      point Pring = Pshad + ringnoise*offset;
      /* The trunk isn't totally steady xy as you go up in z */
      vector d = snoise(Pshad[2]*trunkwobblefreq) ;
      Pring += trunkwobble * d * vector(1,1,0);

      /* Calculate the radius from the center. */
      float r = hypot(Pring[0], Pring[1]) * ringfreq;
      /* Add some noise around the trunk */
      r += angularwobble * smoothstep(0,5,r)
      * snoise (angularwobblefreq*(Pring)*vector(1,1,0.1));

      /* Now add some noise so all rings are not equal width */
      r += ringunevenness*snoise(r);

      float inring = smoothpulsetrain (.1, .55, .7, .95, 1, r);

      point Pgrain = Pshad*grainfreq*vector(1,1,.05);
      float dPgrain = dPshad; //dropped filterwidthp(Pgrain);
      float grain = 0;
      float i, amp=1;
      for (i = 0; i < 2; i += 1) {
      float grain1valid = 1-smoothstep(.2,.6,dPgrain);
      if (grain1valid > 0) {
      float g = grain1valid * snoise (Pgrain);
      g *= (0.3 + 0.7*inring);
      g = pow(clamp(0.8 - (g),0,1),2);
      g = grainy * smoothstep (0.5, 1, g);
      if (i == 0)
      inring *= (1-0.4*grain1valid);
      grain = max (grain, g);
      }
      Pgrain *= 2;
      dPgrain *= 2;
      amp *= 0.5;
      }

      return mix (inring*ringy, 1, grain);
      }

      // larry gritz' original shader was a closure but this shader
      // provides different outputs that you can plug into your own
      // closures/shaders
      surface oak(
      point Pos = P,
      float Sharpness = 0.01, // sharpness of the grain. hand tweaked because we lack derivatives.
      float ringfreq = 8,
      float ringunevenness = 0.5,
      float ringnoise = 0.02,
      float ringnoisefreq = 1,
      float grainfreq = 25,
      float trunkwobble = 0.15,
      float trunkwobblefreq = 0.025,
      float angularwobble = 1,
      float angularwobblefreq = 1.5,
      color Clightwood = color(.5, .2, .067),
      color Cdarkwood = color(0.15, 0.077, 0.028),
      float ringy = 1,
      float grainy = 1,
      output color Color = 0,
      output float Spec = 0.1,
      output float Roughness = 0.1,
      output float Disp = 0
      )
      {
      float wood = oaktexture (Pos, Sharpness, ringfreq, ringunevenness, grainfreq,
      ringnoise, ringnoisefreq, trunkwobble, trunkwobblefreq,
      angularwobble, angularwobblefreq, ringy, grainy);

      Color = mix (Clightwood, Cdarkwood, wood);
      Disp = -wood; // lightwood = 0, darkwood is deeper/lower = -1
      Spec = 0.1*(1-0.5*wood); // darkwood is less specular
      Roughness = 0.1+0.1*wood; // and rougher
      }

      Example node setup

      The node setup for the Suzanne and the torus looks like this: