Страници

Saturday, February 10, 2018

All in One Blender Matcaps Material

Everyone knows that in Blender 2.79 you can use only single Matcap shader per view. That is sometimes limiting and not so pretty. Especially if you have model with multiple parts.

And because matcap is based on an old Normal mapping technique I decided to make a material that can use specific matcap depending on the object's random number or by assigning specific index.
For this I made a screenshot of the matcaps preview panel and edited it slightly in Gimp. Then using the power of material nodes and some math it turned out like this.



From here you can amaze your unsuspecting friends by making multi-matcap candy ball.



Do you think this texture tiling deserves a tutorial?

Let me know!

Monday, February 5, 2018

Basic usage of Vertex Weight Proximity Modifier

Vertex Weight Proximity Modifier is a powerful modifier that can control vertex weights in given vertex group and vertex groups are widely used in other modifiers to control the amount of the modifications.

In this short tutorial I will show you how to set up a Vertex Weight Proximity Modifier in order to explore its properties. The tutorial is accompanied with short demo video that summarize some of the most important controls of the modifier.

You will need basic knowledge of mesh editing and modifiers to complete this tutorial.

Let's begin!

1. Create a Plane. Subdivide it in Edit Mode couple of times.

2. Select all vertices and add new Vertex Group. Leave it with the default name Group.

3. Create new object that will be the Target for the modifier. In this case I choose Cylinder without caps and very small height. Align it to the Plane.

4. Rename the Cylinder as Target.

5. Now add Vertex Weight Proximity Modifier to the Plane and set the Cylinder object as Target.

6. In the modifier's field Vertex Group select Group.

7. As Distance criteria choose Object. In this case the weights of the Group vertex group will be influenced by the distance to the center of the Target.

8. For Lowest value set 1, for Highest - 0. Those values are very important and explained at the end of this tutorial.

9. In order to see how Vertex Weight Proximity Modifier affects the selected vertex group let's add another modifier which will be controlled by the same vertex group.

10. Add Solidify modifier to the Plane add some Thickness (0.5) and select Group in vertex group field.

11. Move the Plane to the left and rename it to Plane_L. Then duplicate it and move the duplicate to the right. Leave the Target object in the middle. Rename the duplicate to Plane_R.

12. Select Plane_R and in its modifier stack change Distance option of the Vertex Weight Proximity Modifier to Geometry and then select Vertex as geometry element. In this case the weights of the vertex group will be influenced by the distance to the vertices of the Target.

If you set everything correctly you should end up with something similar to the image below. Don't be afraid to be creative and deviate from this look.



The final result: Two subdivided planes with modifiers and Cylinder object as influencer (Target)

Now, try moving the Target towards the center of the Plane_L. You will observe the Solidify modifier changing from no effect to full effect when both centers of the Plane_L and Target coincide.

Now move the Target towards the Plane_R you will notice that the Solidify modifier is in full effect where the vertices of the plane are closest to the vertices of the Target. You can now switch to other Geometry element of influence Edge or Face. All vertices closest to the edge or face will have their weight set to higher vertex wight and thus more influenced by the Solidify modifier.

The Vertex Weight Proximity Modifier has more controls as Falloff Type, Vertex Group Mask and Texture Mask, which give additional control over the modification of the vertex group.

You can see a demo of most of the options in this video:



So, now you can control the weights of the vertices depending on the distances to different parts of given object. Changing vertex weights gives control over the final result from other modifiers in the stack. In this way you can create various effects.

As final note the parameters Lowest and Highest have the following meaning:
Lowest (value) - maximal distance at which the vertices of the vertex group receive weight of 0.
Highest (value) - minimal distance at which the vertices of the vertex group receive weight of 1.

This is a bit confusing. So here are the settings used above explained:
Highest value of 0 means that vertices that are at distance of 0 to the target element will receive the highest vertex weight of 1 and Lowest value of 1, means that vertices that are at distance of 1 and above will receive lowest vertex weight of 0. So you can type any values in those fields and see how the vertex weight values of the Group change.

Subscribe, like, comment!
Enjoy your day!




Monday, January 29, 2018

Polygonize an image in Blender




Reducing an image to set of triangles is an interesting way to make abstract art but requires hours of careful placing of points and tedious colorizing of polygons. Of course there are programs that try to automate this process, but you as a true Blender user want to make everything in your favorite program. So, in this tutorial I will show you how to make polygonized images by couple of ways in Blender - applying some skills and knowledge from Modeling, Modifiers and UV mapping.

In this tutorial we will create the images shown above.

Let's begin!




Preparing the image plane


Start with a simple Plane object. The orientation of the object is not important. My preferences are to place it in XZ plane.
You can resize the Plane to the proportions of the image. For example if you intend to render 1920x1080, you can resize the dimensions to X - 1.920 and Z - 1.080.



Plane object aligned in XZ plane and rescaled to desired dimensions.

If you like squares leave the dimensions unchanged. Apply the scale and rotation before going further, just in case.

We will examine two types of polygonisation: abstract and concrete.


Abstract polygon background


In the abstract variant we will generate triangles that will take the color from given image without taking into account the underlying shapes.

Enable Wire and Draw All Edges in Display panel of Object Properties tab to better observe the changes.

1. Add Subdivision Surface modifier and set it to Simple.
2. Set Subdivisions - View to 6
3. Add Decimate modifier and set the Ratio to 0.1, also check Triangulate option.



Remeshing of the plane made simple.

You can play with the above settings to your liking.
4. Apply the modifiers in the order of creation.
5. With object selected tap Tab to enter edit mode. Select All vertices.
6. Press Spacebar and type Edge Split and execute the operation. All triangles are now split from each other and deselected.
7. In Front view Select All and press U -> Project from View (Bounds) to create UV map layer.
8. Switch from 3D View to UV/Image Editor change UV selection mode to Face and Rotation/Scaling pivot to Individual Origins as marked on the image below.



Editind UVs. From this...



.. to this after scaling the UV faces.

9. Press S to scale the polygons and type 0. Now the UV faces will pick single color from the texture.
10. Switch to 3D View again. Set the Viewport Shading to Rendered. Create a simple Shadeless material for the plane and add new texture to the material. I will use a Clouds texture with custom Ramp colors and settings for the Depth and Size. Make sure that Mapping coordinates are set to UV. The settings are shown below.



Create abstract backgrounds from procedural images...



... or photos.

With that the polygonization of the image texture is complete. You can experiment with any kind of textures including photos to see how they will look. Render cool abstract art!

Concrete image polygonization


In the concrete variant it is taken care of outlining the forms that we want to remain recognizable by the viewer.

Lets take for example this photo:



If we apply this image to the plane object that we created it will look like this:



For fresh viewer it will be hard to recognize what is on the image and here you have the opportunity to focus on specific parts of the image in order to make it look better.

You can always increase the polygon density in some parts, but if you want to keep the image low-poly you have to put your basic modeling skills at work. This approach requires more time and artistic look. Be patient!

Using the image as reference create new object, delete all vertices and start placing and connecting new vertices at strategic places - mostly where the edges of shapes are and where the texture is varying.

Try to keep the polygon count low, because this is the beauty of this art - showing more with less.

After creating the polygons (preferably triangles). UV unwrap the mesh as described above. This time you can load the reference image in the UV/Image editor to see exactly where the uv faces are located.

 

Here is my take on placing vertices at strategic places on the image, variations are unlimited.

After finishing with the modeling repeat the steps from No. 5 as instructed above to achieve the low-poly look.



Polygonization of an image with attention to the details. Compare with the polygonized image using the first method.

A great thing of this method is that you can always change the colors of the polygons by simply moving around the scaled down UVs in the UV/Image editor. Make sure Proportional Editing is enabled and the size of the falloff is set to very small value so the vertices of the faces stay toghether.



Improved image by moving around the uv polygons and placing them on different pixels.

With that the tutorial is complete.

The technique described here could be a base for creating various low-poly effects and animations and it's not limited to 2D mesh ot triangle polygons.

Like the examples below.


If you like this content follow me on Twitter for updates and new cool stuff!
Happy polygonizing!

Saturday, December 23, 2017

Parametric Modeling with Modifiers




Modifiers in Blender are powerful tools that help achieve fast various goals. From shaping and modifying mesh objects, transferring data between objects, animation based on specific properties. Even physics simulations like particles, cloth and fluids are part of the modifiers family.
One interesting aspect of modifiers is that you can stack them on top of each other affecting the result from the previous modifiers.
This gives opportunity to create parametric models which is a way of nondestructive modeling.
Simply start with primitive object element and build up towards more complex structure using only modifiers and helper objects like Empties and Textures.
In this tutorial I will show you an example of parametric modeling with modifiers.

We will build a sphere from single plane and will add custom properties that will drive some parameters of the sphere.

If you feel impatient to read through the tutorial you can download the final blend file at the end of the page. But I strongly advise you to go through the steps if you want to learn how the sphere was constructed.

Let' s Begin!


Empty your scene from any objects or start on an empty layer

Creating the Plane


Press Shift+A and select Mesh -> Plane.
This will add a Plane object that by default is oriented with face pointing in Z direction (Fig. 1)



Figure 1. The good ol' Plane

In order to continue with building the parametric sphere rotate the Plane along X axis by 90 degrees and Apply the Rotation. With the Plane selected press - R then type - X, type - 90 and press Enter, to apply the rotation press Ctrl+A and select Rotation)
The Plane's local axis should look like in Fig. 2



Figure 2. The plane rotated 90 degrees around X axis. Don't forget to apply the rotation!

Adding the Modifiers


All modifiers can be added from the Add Modifier menu in Modifiers Tab in Properties Editor (Fig. 3)



Figure 3. The Great Add Modifiers menu.

Adding Displace Modifier


Displace Modifier basically shifts the vertices of the object by given rules.

In our case we need to move the whole plane half width (which is 1) to the left on the X axis.
Select the Plane object and add a Displace Modifier with the following settings (Fig. 4):

Direction: X
Midlevel: 0



Figure 4. Our first modifier shifts the Plane to the left of its origin.


Adding second Displace Modifier


Press the Copy button to duplicate the modifier.
In the new Displace Modifier change Direction to Z (Fig. 5)
The Plane should move 1 unit along Z axis



Figure 5. This time let's move the Plane 1 unit along Z axis.


Adding Array Modifier


Array Modifier duplicates the object or the result from the modifier's stack by given number and direction condition.
With the Plane object selected add Array Modifier and enter 12 (for now) in the Count field
Also enable Merge (not shown in the figure)
(Fig. 6)



Figure 6. We continue bay making a stripe of planes using Array Modifier.

Tip: To view the edges of the object enable Wire and Draw All Edges in Display panel of the Object Tab


Adding Simple Deform Modifier


Simple Deform Modifier performs space warping operations on the object vertices. In our case we need the strip to bend and to form a half circle. Add Simple Deform Modifier, press Bend button and enter 180 in Angle field (Fig. 7).



Figure 7. Bending the stripe with Simple Deform Modifier into half circle.

Tip: Bending works by placing the center of deformation at specified origin (center of the object or another one). Then it uses the axis orientation to perform the bend. It takes the vertices and swirl them around Z axis of the object by given angle. In our case the strip is bent to form a half circle.

Creating first custom property


The procedure of adding a custom property to the object is described in my tutorial

Create an array of planes that fits inside of Camera View using Drivers


Create a custom property that will represent the half of the faces in a sphere ring, respectively the half of the columns and name it half_cols (Fig. 8). Enter the settings as shown in the figure.



Press N in the 3D View to open the Properties shelf and open Properties panel.

Adding Driver for the columns


In the Array Modifier panel press Ctrl+D over the Count field and select Single from Target.
With the Picker click over the half_cols property. Increase the number of half_col to 12.
You can open additional Graph Editor to edit the Drivers (Fig. 9)



Figure 9. Create a driver for the Count property of the Array Modifier and link it with the half_rows custom property of the Plane. In this way we won't dig into the modifier stack to change this value.

Adding third Displace Modifier


We need to shift the bent stripe along Y axis so the center of the plane coincides with the center of the half circle.
The Bend Modifier takes the initial length of the stripe from the Array Modifier and bends it into half circle. The length of the stripe is:

length = 2*n ,where

2 is the width of the Plane
n is the number of Array copies

So the radius of the half circle should be:

radius = length/pi or

radius = (2*n)/pi ,where

pi is constant

Add new Displace modifier, set Direction to Y, Midlevel to 0. Add driver - Single from Target to Strength property and pick half_cols property.
Select the Strength channel in Drivers window of Graph Editor and enter the expression:

-(2*var)/pi

 as shown in Fig. 10



Figure 10. Using driver to move the half circle so its center coincides with the Plane's origin

The half circle is centered correctly. You can test if everything works by changing the half_col value.

Adding second Array Modifier


Add second Array Modifier but this time set the Relative Offset to be 1 along Z axis.
Enable Merge option (Fig. 11).



Figure 11. Second Array Modifier duplicates the half circle along Z axis.


Creating second custom property


The second custom property of the Plane object will control the count of the second Array Modifier (Array.001) and will represent the number of rows in the sphere. Enter the following settings for that property (Fig. 12)



Figure 12. The second custom property of the Plane - rows, will control the number of sphere rows.


Adding Driver for the rows


Open Array.001 modifier panel and add driver  - Single from Target and pick rows custom property.
Set the rows custom property to 12 (Fig. 13)



Figure 13. The second driver will link the number of  rows to the Count of the Array.001 modifier.

Tip: Sometimes the Drivers don't update immediately - changing the frame on the timeline will refresh the Drivers.


Adding second Simple Deform Modifier


In order to bend the half cylinder the Plane axis won't work. We need to bend the cylinder from the bottom and far left side of the half cylinder. For this we need an Empty object to control the bending axis and origin.
Add Empty object.
Add second Simple Deform modifier to the Plane.
Set the Empty as Axis, Origin and set the Deform Angle to 180 (Fig. 14)



Figure 14. Second Simple Deform will bend the half cylinder into half torus shape.

The bent half cylinder looks strange. We need to rotate the Empty in the correct orientation.
Select the Empty and type in the Properties shelf, in Transform panel, in Rotation fields the following values (Fig. 15):
X: 90
Y: 90
Z:180



Figure 15. With the help of the Empty object the bending looks better.


Adding Driver for the displacement Strength


For the X location of the Empty we will add driver that will place it to the far left side of the half cylinder.
Right click over X location field of the Empty and add driver - Manually Create Later (Single).
Click the X Location channel in the Drivers Graph Editor and change var to Single Property variable. Select Plane as Object and in Path type: ["rows"]. In the Expression field type:

(2*var)/pi

which is the radius of the outer circle of the donut.

Change the rows custom property to see the Empty shifting along X axis and the half cylinder bending into half sphere (Fig. 16)




Figure 16, From half donut to half sphere - that's the power of drivers!

Tip: While changing the custom properties the half sphere will not close properly because of drivers not refreshing properly. Changing a frame on the timeline (with arrows keys) fixes this problem and refreshes the model shape.


Adding Mirror Modifier


The Mirror Modifier duplicates and flips the object over defined axis. Select the Plane object and add Mirror Modifier - disable X and enable Z axis. You should get the full sphere (Fig 17)

.

Figure 17. Using Mirror Modifier we complete a full sphere.

If you play now with the custom properties you will notice that the sphere changes its rows and columns but also its size. Let's fix that.

Adding Cast Modifier


The Cast Modifier takes the vertices of the object and from given center and radius moves the vertices to shape Sphere, Cylinder or Cube
We already have spherical object but in this case we will use the Cast Modifier to restrict the radius of that shape to desired value.
Add Cast Modifier to the Plane object.
Disable From Radius, set Factor to 1 and for Size type 2 (Fig. 18).



Figure 18. Using Cast Modifier we restrict the radius of the sphere to constant while changing the custom properties - rows and half_cols.

That's it!


We made a parametric sphere and we can control the number of polygons however we want.

Tip: To convert and collapse all modifiers and turn the parametric sphere into real mesh press Alt+C - Mesh from Curve/Meta/Surf/Text. This will erase all modifiers but will keep the sphere with the last settings.

Tip: You can add additional custom properties to the Plane for different modifiers parameters like bend angles, relative offsets and animate those custom properties to make crazy animations. Like this:






Download the final blend file!



Wednesday, November 29, 2017

Create an array of planes that fits inside of Camera View using Drivers


This tutorial is based on a question from Blender Stack Exchange user 3pointedit

The main goal is to create a variable count of Plane objects in array (row) that fit in Camera view with additional option for offset space between the objects and the Camera view bounds as well as different coloration of the tiles. Here is a preview of what we are going to create:



This tutorial includes using Custom Properties, Drivers and Compositing and not very complicated mathematical expressions. It is oriented more to the advanced Blender user but I will gladly answer any relevant question left in the comments below.

Warning: Read it slowly to avoid headache :)


If you feel lost - after each main stage you can download a blend file with the current progress.


Let' s Begin!


Start with an empty scene (delete everything). Create a default Plane and rotate it 90 degrees around X axis. Apply Rotation & Scale (Fig. 1).



Figure 1. Create empty scene and add default Plane object aligned to Front view.

Add an Array Modifier with default values.


How Array Modifier's Relative Offset Works and some Math


Let's examine the X value of the Relative Offset parameter (Fig. 2).



Figure 2. Add Array modifier to the Plane.

Value of 1 means no offset from the previous copy.
Value of 2 means the next copy is offset by the width of the original object.
Which means that the offset distance is relative to the object's width and is equal to:

width * (x_off - 1)          (1)

where width is the X dimension of the object,
x_off is the relative offset

width + width * (x_off - 1)          (2)

represents the common width of the object plus the offset distance.

To find the actual width of the object after Array modifier (including the last offset distance) we have to multiply the above equation by the number of copies:

n * (width + width * (x_off - 1))          (3)

where n is number of copies (Count property in Array modifier)

For our task we need to scale back the width of the array object to the initial width size (including the empty space from the last offset distance).

Finding the X scale factor that will bring back the array object to the initial width


We have to find the scale factor that will do the trick. It is simply dividing the original width by the width of the array object:

x_ scale = width / (n * (width + width * (x_off - 1)))          (4)

where x_scale is the scale factor for the X axis

Let's clean up the above equation:

x_ scale = width/(n * width * (1 + (x_off - 1)))          (5)
x_ scale = width/(n * width * (1 + x_off - 1))          (6)
x_ scale = width/(n * width * x_off)          (7)

x_ scale = 1/(n * x_off)          (8)

So, finding the scale factor does not require the width of the object itself

Finding the X location of the center of the array object


Initially the Plane's center (not origin) is located at 0 on the X axis
with each copy the center of the object will move to the right. The relative center of the array object is the width of the Plane multiplied by the number of copies and divided by two

n*width/2          (9)

with the offsets added:

n * (width + width * (x_off - 1))/2          (10)

So we have to move the whole array object back to the left:

width/2 - n * (width + width * (x_off - 1))/2          (10)

Don't forget that we have an offset empty space at the end of the array object so we have to move to the right the half offset distance in order the visible parts to be centered:

width/2 - n * (width + width * (x_off - 1))/2 + width * (x_off - 1)/2          (11)

And because we apply a scale factor to the width of the array object we have to apply the same scale factor (x_scale) to the transformation for the array object:

x_location = (width/2 - n * (width + width * (x_off - 1))/2 + width * (x_off - 1)/2) * x_scale     (12)

where x_location is the new position of the Plane's origin

If we simplify this equation we get

x_location = (1-n)*width*x_off*x_scale/2          (13)

we can further simplify by replacing x_scale with the equation (8)

x_location = (1-n)*width*x_off*(1/(n * x_off)/2           (14)

Finally we get:

x_location = ((1-n)*width)/(2*n)           (15)

effectively solving x_location with two variables

Solving the task

Prerequisites


We need three custom properties that will control our Array object:

count - that will control the number of copies
x_offset - that will control the horizontal offset between the copies
z_offset - that will control the vertical offset between the copies

We also need a reference object that will hold an information for the initial dimensions of the Plane and specifically its width. To do that create a linked duplicate of the Plane (Alt+D) move it above and rename it to Reference. Also delete the Array modifier for the Reference object (Fig. 3)



Figure 3. Create linked duplicate of the Plane and name it Reference. Move it up out of the way.


Let's create the custom properties for the Plane.

In Object tab of the Properties editor - go to Custom properties and Add and Edit three properties with the following settings (Fig. 4):

1. count
Property Name: count
Property Value: 1 (note that the value is integer not float)
Min: 1.000
Max: 100.000

2. x_offset
Property Name: x_offset
Property Value: 1.0
Min: 1.000
Max: 2.000

3. z_offset
Property Name: z_offset
Property Value: 0.0
Min: 0.000
Max: 1.000




Figure 4. Add 3 custom properties for the Plane with the given settings.

In Properties Shelf locate and expand  Properties panel for easy access (Fig. 5).



Figure 5. Make sure the Properties shelf is open and the custom properties visible.

You can download the progress so far here:

Prerequisites.blend

Drivers


We will use two methods for adding drivers (Fig. 6):

1. Right click  ( or Ctrl+D) over property - Add Driver - Single from Target - Click with the Picker over Target property
2. Right click  ( or Ctrl+D) over property - Add Driver - Manually Create Later (Single)



Figure 6. This is the usual menu for adding drivers to property.

So let's create the first driver!

Right click over Count property of the Array modifier of the Plane and select Add Driver - Single from Target. Move the Picker over the count custom property of the Plane and click.

Add Graph Editor view to access the drivers channels (Fig. 7)



Figure 7. Create Graph Editor view and open Drivers context view.

Click on the Count channel and go into Drivers tab.
Change the variable name of var to n.
Enter in Expr: field - n
Increase the count value to observe adding new copies to the array (Fig. 8)



Figure 8. Our first driver controls the number of Plane copies.

Similarly, let's add driver for the X value of the Relative Offset of the Array modifier.
Again use Single from Target but this time the Target property is x_offset custom property of the Plane.
Change the variable name var to x_off and type in Expr: x_off. Modify the x_offset value to observe different spacing between the copies (Fig. 9)

.

Figure 9. The second driver controls the Relative Offset X value.

Go to Object tab, Transform panel and add driver for the X Scale this time use Manually Create Later (Single).
Click on the X scale channel in Graph Editor to view the driver variables.
Rename the variable var to n and change its type to Single Property.
Select Plane object in Prop field and type: ["count"] in Path field
Add another Single Property variable.
Name it x_off.
Select Plane as object and type: ["x_offset"] in Path field.

In Expr field we'll enter the right side of the equation 8:

1/(n * x_off)

Play with the count and x_offset properties and observe how the array keeps the initial width but slightly moves to the right (Fig. 10).



Figure 10. The third driver scales the copies to fit the initial width of the Plane.

To fix that shift let's add driver to X Location of the Plane.

Right click over X value of Location parameter and add Single from Target driver. The target property is count.
Change variable name var to n.
Add second Single Property variable and name it width.
This time as object select Reference and in Path type: dimensions[0].
In Expr: field enter the right side of the equation 15:

((1-n)*width)/(2*n)

If everything is correctly done changing count and x_offset properties will not affect the position and width of the array object while changing the number of copies and the offset between them  (Fig. 11).



Figure 11. The fourth driver moves the Plane object so the whole array stays in place when the user changes the custom properties.

Finally, lets add driver for the vertical offset.
Add single driver from target to the Z Scale value of the Plane object. As target pick z_offset
Rename var to z_off.
Type the expression:

1 - z_off

Changing z_offset custom property will scale the array object vertically (Fig. 12).



Figure 12. The fifth driver controls the vertical scale of the Plane.

Because the drivers update from the custom properties we can change the dimensions of the Plane to our liking.
If we want to fit a Plane to Camera view we need to make the aspect ratio of the Plane dimensions and Camera frame equal.
Lets Add Orthographic Camera to the scene and move it along -Y axis (Fig. 13).



Figure 13. Create Orthographic Camera and place it in front of the Plane.

You'll notice the Resolution is 1920x1080 with aspect ratio of the image 16:9.
You can use any resolution as long as you know how to derive the image aspect ratio from it.
In this case our Plane object must have width to height ratio - 16 : 9.
As we already have Reference object as linked duplicate any vertex editing of the Reference will reflect to the Plane object.

In front view select Reference object, enter Edit mode and scale all vertices along X axis by 1.6, then scale again along Z axis by 0.9. Exit edit mode and the Plane object will update with new dimensions that will correspond to 16 : 9 ratio.

Select Plane object and set all custom properties to default values (just drag the values with the mouse to the left) .Right click Reset to Default Value would not work for the count property and will reset the value to 0 instead of 1, that will cause division by zero error in the drivers. It's a bug - not a feature!

After properties reset go in Camera view and with Plane selected press Space bar and type in search field Camera Fit Frame to Selected (Fig. 14)



Figure 14. Camera Fit Frame to Selected command will do the magic that will fit the Plane into the frame.

This will change the Camera's Orthographic Scale and the Plane will fit completely inside the frame.
Test again the custom properties. The result should be similar to Fig. 15



Figure 15. The final look of the Plane with custom Array modifier which will always fit inside the frame.

With that the drivers set up for the Plane is complete.

You can download the progress so far in the blend file below:

Drivers.blend

Adding unique colors to the tiles.


As final touch we will add unique color to each tile. This could be useful for selective masking of specific tile by its color.
A quick and easy approach is to take advantage of the color posterization effect.
We will create shadeless material and apply single blend texture to the plane object.
Then we will create a Shader node and with the help of a few Math nodes and custom Color Ramp we will add unique color to each tile.

First with Plane selected create new material and name it Mat_Tiles. Make the material Shadeless.
In Texture tab Create new Texture of Type: Blend
In Colors enable Ramp and change the Alpha of the Black color to 1.
In Mapping set Coordinates to Window (Fig. 16).



Figure 16. The initial settings of the Mat_Tiles material.

Download:

Material.blend

In Node Editor switch to Shader type, select Mat_Tiles material and enable Use Nodes. Select Mat_Tiles in Material node (Fig. 17)



Figure 17. The initial look of the Material nodes of Mat_Tiles.


Add the following nodes as shown in Fig. 18



Figure 18. Using some Math nodes and custom Color Ramp we can posterize the gradient of the Blend texture.

Finally we'll add a driver to the Value node to reflect the current number of the tiles defined by the count custom property.
Open Properties Shelf to reveal the custom properties of the Plane add single driver from target and pick the count property.

That's it!

Now whenever you change the number of tiles it will automatically change the number of colors too (Fig. 19).



Figure 19. The last driver will control the number of color posterization steps.

Download the final blend:

Final.blend

Note: Due to the nature of the Window coordinate space - Rendered viewport shading will work correctly only if the camera frame touches the edges of the window (as shown above). The best way to see the result of is to render.