Thursday, February 2, 2012

How to blend shapes along an axis. Also, a chair!

Today, I modelled a chair!

Nadya just loves this chair. After spotting it in a second-hand store,
she worried that if we did not hurry, somebody else might buy it first.

Fortunately, she is the only one who thinks this chair is awesome.


Ok, so it's only a chair, but just because you see chairs every day doesn't mean it's easy to model one. The most challenging part, for me, was the seat. The front of the seat curves downwards in order to wrap the legs, while the remainder of the seat curves inwards in order to wrap Nadya's ass. Important stuff! But easier said than done.

Thanks to the SoftTransform operator, adding a single curve to a planar surface is straightforward. Adding the second curve, however, is harder because the curves can interact with each other. To bypass the problem, I decided to model two single-curve seats, assuming that I could somehow blend one variant into the other.

Well, turns out blending is complicated enough that I can write an entire blog post on the subject. Enjoy.


Which seat would you rather sit on?

Answer: Sit on your own damn seat. This one is for Nadya's ass only!

I love Houdini, but I was a bit disappointed to discover that its BlendShape operator isn't flexible enough to perform the blending I needed. I will explain why in a moment, but before I get to that, let me explain what it is that I needed.

Blending, you see, involves interpolating the position of each point so that it lies between the position it would have in the first variant, and the position it would have in the second variant. This interpolation depends on a parameter, the blending parameter, which can vary between zero and one. Animating the parameter from zero to one gives the impression that the first shape is morphing into the second shape, and Houdini's BlendShape operator clearly has this use case in mind.

Above: Sphericubes!


Being able to create intermediate shapes is nice, but that's not what I had in mind. An intermediate between my two curved seats would be a seat which curves both downwards and inwards, simultaneously. That's not what I want! The seat I want to model has a downwards curve at the front, and an inwards curve at the back.

To use a sphericube-style example, I don't want a cube with bulging faces, I want the left side of a cube, the right side of a sphere, and something intermediate in the middle, whatever that may be.

Above: A cubisphere, whose "something intermediate in the
middle" turned out to look a lot less awkward than I expected.

Sadly, the BlendShape operator can create sphericubes, but not cubispheres.

It's a shame, really.


Well, punchline! I found a way to create them anyway. Yes! The screenshots are real!


Houdini has a very flexible operator called, simply, "Point". It loops over all the points of your shape, manipulating them according to a formula you write. Or rather, three formulas, one per axis.

Suppose you wanted to translate your shape to the right by one unit. The formula relating the original point positions to the translated positions is as follows.

(x, y, z) ↦ (x + 1, y, z)

Using the Point operator, you would write this instead.

$TX + 1
$TY
$TZ

And your points would be translated. Of course, you wouldn't use the Point operator for a simple translation; you would use a Transform operator, because its interface is simpler and its implementation is probably faster. You would only use the Point operator when, say, the existing operators let you down. I'm looking at you, BlendShape.

Above: Math. Also, a blending operator which blends along the Z axis!


Maybe I am being too harsh with BlendShape. Its limitation is not surprising. In fact, most operators, including the Transform operator, share this limitation: parameter values cannot vary from point to point. For example, when I translate a shape, I cannot tell Transform that the top of the shape should move to the right, while the bottom of the shape should move to the left. Outrage! Cripplingly limiting! Annoying, perhaps, but entirely unsurprising if your favorite 3D software is something more conventional, like 3DS Max.

As a Houdini user, however, I am rightfully surprised!


You see, the parameters in Houdini are not mere numbers. They are formulas, computing the right number from attributes of other nodes. It's very easy, for example, to scale a hat so that its new width coincides with the width of a head you have already created. The idea is that if you change your mind about the width of the head, you won't have to also adjust the hat.

At Houdini's, we sell hats which fit heads of all sizes.

Parameter formulas are also convenient for creating animations, by writing equations involving the current frame number. The point is that in Houdini, varying parameters according to stuff is common and expected. One subtlety to keep in mind, however, is that the node can't actually see the formula; instead, the formula is used to compute a number, and the node can only see that number.


It's a bit as if you were ordering Christmas lights online, and you had to pick a color. You can (and must!) consult your girlfriend, the weather, compare with your other decorations... You can vary your answer according to any number of factors, but your answer still can't vary along the length of the light rope. You must distill all the factors into a single color, say, red, and select "red" on the online form.

It might be possible, in theory, to alternate red and green lights along the rope, but the light rope manufacturer won't ship you one, because all it knows about your order is that you clicked on "red". Similarly, it might be possible to use a 0.1 blend factor on the left of the cubisphere and 0.9 on the right, but the BlendShape operator won't ship you one, because all it knows about your order is that you clicked on "0.5".

The above is purely theoretical.


If you liked my Christmas lights example better than my sphericube example, be sure to check Nadya's post. She is texturing a light rope!

She worked on that labor of love right here, on the properly-blended curves of this very chair.

Wednesday, December 28, 2011

Christmas Lights

The decorative lights the neighbors put on their bushes and houses for Christmas and the last work of Sam (the initials) inspired me to do the following exercise. I decided to write our initials with a LED rope.

Unfortunately I could not use the letters from Sam. I needed single stroke letters, so they could be used as a path for a cylinder which represents a rope.
I was not able to find a single stroke font, so I had to make one myself. Obviously, 3ds Max was a bad choice for font manipulation due to its poor set of vector graphics tools. Instead, I used Inkscape, a perfect app for vector  manipulations.

First, I needed to find a prototype font that would have a fancy shape that would go well with the festive mood of Christmas. Monotype Corsiva seemed to be the best match.



I traced the letters from inside. Then I simplified the resulting path and made the curves more round remembering that the LED rope is rigid and does not bend very well:

(the curly tail of the S letter was eventually given up)


I am sure you've noticed that the paths intersect. The intersection spots required more work. In real life ropes do not go through each other; instead they lay on top of each other. More bezier curve editing after the import - and the paths were not flat anymore:


 


The next step was to make a LED material.

It should be a self-illuminating material, since the rope emits light.
I used Architectural Material. For bump map I used the bump map from Transparent Plastic material.


For diffuse and intensity maps I used a gradient ramp, since it is the base of any light. The light part represented a light bulb, and the dark part was a plastic wrap cord. Since the rope is round, the inside bulbs are visible from any point of view. Thus, I used a linear white-red gradient and mirrored it along its light end. Also I turned the gradient 90 degrees on the VW axis and added some noise to imitate the slightly uneven structure of the plastic wrap.


I rendered my sample LED cylinder, and it looked like a Santa Clause cane, not like a LED rope! The gradient step was way too small.


How to make it bigger? 

I applied the Unwrap UVW modifier and adjusted the UVW map to make the gradient look proper. It was a mistake, since I planned to copy my cylinder around for each letter. Once I started messing up with UVW map, it got converted from being flexible to being fixed. This means that the UVW map got attached to the object vertices. Since every letter cylinder has a different length, its UVW map got streched or shrunk. This made my material be unevenly distributed on each letter (the N letter map distortions were exaggerated a bit to make them more clear):


This approach would require me to adjust a UVW map of the every letter, and the results would not be consistent. Not good.
While looking for a workaround I went again through the Gradient Ramp options. And I discovered the Size field!


It was exactly the value I needed to manipulate in order to adjust the real gradient size.
Here is what I got as a result! A LED rope shaped in the form of our initials!



Happy New Year!

Saturday, December 17, 2011

How hard can it be? Extruded, beveled text in Houdini.

Nadya asked me to create a simple 3D model to help her practice texturing. Specifically, she asked me for the letters "N & S", big and white, like the Hollywood letters on their mountain.

At first, I was a bit disappointed. Extruded letters? That's it? Seems like a waste of my talent. Might as well ask a Photoshop user if she knows how to create a lens flare effect! In fact, extruding text is such a common task that the Extrude operator's icon is an extruded "T".
  1. Lay down a Font operator, changing the text for "S & N".
  2. Lay down an Extrude operator, reducing the depth if necessary.
  3. There is no step three!
3D modelling is rarely that easy.


That was easy, but Nadya was not happy with the result. The edges are way too sharp! Real-world 90 degree angles don't look like that.

This is the sharpest-looking corner in the room.
Can you spot the bevel?


If real-world objects had true 90 degree angles, their corners would be dangerously sharp. So while the faces of the table above are at 90 degrees from one another, they do not actually meet at 90 degrees. In fact, the faces themselves do not meet. There is a very thin 45 degrees rectangle beween them, and a tiny triangle at the corner, joining the thin rectangles formed by the three edges. This is a very common setup, called a "bevel".

The bevel should be much easier to spot this time.


By increasing the size of the bevel and adding more intermediate angles than just 45°, corners can be made to look very smooth. Let's add some bevel to our extruded text.

Something doesn't feel right about this bevel.


Yikes, spikes! As you can see, laying down a Bevel operator is not enough. The operator handled the S just fine, but something about the ampersand geometry is messing things up. What is it?

Who put these inner edges on my ampersand?


One of the problems is that the ampersand has holes. Representing an area with holes requires more than one curve: one for the area's perimeter, and one for each of the holes. In a node-based modeller like Houdini, however, this representation has the disadvantage that each operation needs to take the possibility of holes into account. For this reason (or maybe for historical reasons), Houdini uses a simpler representation which assumes that faces never have holes, and can thus always be represented using a single curve.

Faces which do have holes need to be cut in a special way, so that they don't really have holes, yet look like they do.

A convoluted perimeter, yes, but no holes.


This representation is usually adequate. Most operators preserve the shape of the face, so even after many transformations, the fake hole usually continues to look real. There is one operator, however, which does not preserve the shape of the face. This operator is none other than our spike-producing friend, the Bevel operator!

What you want (left) is not always what you get (right).

This is an "inset", the first step towards a bevel.
Houdini doesn't have an Inset operator, but you can easily
make one by playing with the parameters of the Extrude operator.


Now that we understand the cause of the problem, how do we fix it?

I still hope there is a better way, but the solution I found was to make two copies of the ampersand. The inner edges can be moved elsewhere along the face without compromising the look of the hole, so I can place the inner edges at different places on each copy. This way, the bad parts of the beveled ampersand will look fine on the other copy.

I was planning to use a Knife operator to slice away the bad parts of each copy. While playing with the Knife operator, I discovered that slicing a fake hole has the nice side-effect of replacing the fake hole's inner edge with the knifed-in edge. Convenient!

The Knife operator adds, but also replaces inner edges.


Now that we have an easy way to move inner edges around, we are ready to complete the ampersand bevel.

A mother ampersand splits into two baby half-ampersands,
who in turn grow and become 3D half-ampersands. They then
find a mate of the opposite half, with whom they live in symbiosis,
forming another mother ampersand. Thus completing the circle of life.


The result looks good this time. To make it look even better, we can increased the number of points each letter uses to approximate its font curves. Unfortunately, this leads to more problems!

The acute angle at the bottom-right of the ampersand has an artifact which only shows up with the increased point density. Fortunately, this corner is made of straight edges, so we don't actually need the increased point density. Using the multi-purposed Facet operator, we can clean up the polygon so that straight edges don't use so many points, thereby getting rid of the artifact.

Extra divisions are useful to make curved segments smoother.
Extra divisions in the straight segments, on the other hand,
are worse than useless: they can actually produce artifacts!


One last Facet operator to ensure the front faces are completely flat, and voilà! We're ready for a nice, extruded, beveled, boring piece of rendered 3D text.

I guess I should mention somewhere that
"S & N" stands for "Samuel and Nadya".
Yup, that's us!


I wonder what Nadya is going to create using this? To find out, stay tuned!

Sunday, December 11, 2011

Lighting Problem II

See the part I here.

I followed the advice of my friend designer, and replaced Autodesk Hardwood material with Arch & Design Material. The wooden and bump bitmaps were taken from the Autodesk Hardwood.
The radius of the ball was not changed, and it is 19 cm.

This time the rendering results have improved quite significantly.
Here is the result with a bit of glossiness (0.05):





For comparison here is the rendering with 0 glossiness:

Top right corner is not rendered


There is still some parasite lighting on the sides of the ball, but much less than in the previous scene with Hardwood material.


However, perspective rendering with 0 glossiness shows a lack of volume on the picture. The ball looks flat, and it seems to be a 2D image attached to the scene. A specular light is missing:






Tuesday, December 6, 2011

Houdini and 3DS Max

Before I talk about our project, I would like to discuss our tools. That is rather typical of me; as you might already know from my blog, I love tools, especially UNIX-style command line tools which can be combined into exponentially-many behaviours. With this in mind, if you know Houdini, then you won't be surprised to hear that Houdini is my favorite 3D modeller by far.

And if you don't know Houdini, then you are probably wondering what the hell I am talking about.

3D software packages are usually very large, monolithic applications, the very anti-thesis of the "do one thing and do it well" philosophy of UNIX tools. Houdini is different, and in order to highlight that difference, let me compare my Houdini workflow to my 3DS Max workflow.

Houdini and 3DS Max.
Even though their logos are strikingly similar,
the two 3D packages could not be more different.

Maybe I'm just spoiled by Houdini, but I don't feel like 3DS Max deserves its popularity. I created a sofa using box modelling, and although we are very satisfied with the result, my early attempt resulted in a dead end. It's a very frustrating workflow: you work for a while, discover that you forgot to do something important at the beginning, start over again, discover something else... I have no doubt that more experimented modellers can model entire objects without having to start over even once, but until then, the learning process is painful. It doesn't have to be this way.

There is a reason why they call this "box" modelling.
Just kidding! Box modelling creates curved objects, it's just that the
real-world IKEA Klippan I was trying to reproduce is very blocky.


Fortunately, 3DS Max has other modelling methods which are much more forgiving. Each 3D object starts with a mesh, but this mesh can then be transformed, squashed, spherified, intersected... You can apply an entire stack of modifiers on top of your mesh, and if you make a mistake, it's easy to go back and change earlier modifiers.

By combining a few modifiers, it's possible to create very interesting effects. For example, a couple of smooth transforms and a path deform modifier are all you need to create pillows for the popular IKEA Poäng chair.

The real-world pillows look a bit more comfortable, though.
Maybe it's because the fabric wrinkles are missing?
Hmm, such comfortable wrinkles.

Once I figured out the right combination of modifiers which produces the effect I was looking for, I could simply apply the same modifiers to my other pillows in order to obtain the same effect.

Did I say "simply apply the same modifiers"? What I meant to say was: "painstakingly apply the same list of modifiers you just applied to the last ten pillows, remembering to set each modifier's many parameters to the correct value, again and again". It doesn't have to be this way.

In Houdini, the sequence of modifiers could be isolated and given a new name, "pillowify". This is analogous to creating a shell script, thereby giving a name to a useful sequence of commands. Isn't this awesome? Now you see what the hell I was talking about!

Rock on!!!

(note: This is not a picture of Houdini. This is bash. Houdini looks much better.)

3DS Max is not as bad as I'm picturing it here. I managed to create this great looking furniture, and even to impress Nadya with my mad 3D skillz! Plus, since she will continue using MAX for the foreseeable future, I'm sure she will show you areas in which 3DS Max shines. As for me, I have discovered Houdini, and I don't want to go back. In my future posts, I plan to demonstrate the UNIX-style tools I'll be creating inside Houdini, and the effects which can be obtained by combining them.

Stay tuned!

Monday, December 5, 2011

Ambient Occlusion


While fighting with the lighting problem, I have stumbled upon an interesting property of an Autodesk Material: Ambient Occlusion. What is this and what you may need it for you can read on Wikipedia: Ambient Occlusion.
Here is the results it gave on my big wooden ball:


Ambient Occlusion
No Ambient Occlusion

You do not see much difference, uh? ;)
Watch this animated gif:
See how the shadow changes near the ball's bottom.


Well, the Ambient Occlusion does not give much effect in my scene.
Maybe in some other conditions it will be more noticeable!

Material used for the ball: Autodesk Hardwood, beechwood_gunstock.png, default setting apart from Relief Pattern where Amount was changed to 3.7.

Lighting Problem

Recently I found a great tutorial about a virtual studio which can be used for designing or testing purposes:
Illumination Tutorial for Industrial/ Product/ Furniture Design

I carefully followed the tutorials. However, when I was done, the result scene did not look quite right.

Here is my rendered scene:


Maybe it seems to be totally Ok for you. However, it does not for me!

The big ball has this awful parasite light on the left and on the right. The small one has it too, but less visible.



How to get rid of this reflection? I doubt the real studio set-up produces such results.

The virtual studio set-up:



May it be that the round wall material is too reflective? But I completely turned off the reflectivity.
Here is the info about the scene.
Materials:
  • Tea pot: Ceramic/Porcelain Ice White Autodesk Ceramic, High Gloss
  • Big ball: Autodesk Hardwood with beechwood_gunstock.png image, Unfinished
  • Small ball:  Autodesk Hardwood with Woods - Plastics.Finish Carpentry.Wood.Boards.png, Unfinished
  • Board: Autodesk Hardwood with red_oak_classic_natural.png, Unfinished
  • Scene round wall: Paint White, no glossiness, no reflectivity
Lights:
  • Skylight: Multiplier 0.2, Map 100.0
  • TPhotometricLight: Ray Traced Shadows, Emit Light from Rectangle 200x200 cm, Dimming 20% gives 300 lx)
  • Two boxes with self illuminating material: Luminance 500
Rendering settings:
click to see the bigger screen shot

What am I doing wrong?

P.S.
The top view point shows the parasite reflection even better:

Here is the glossy finishing for comparison:

With glossiness the reflection looks totally Ok.