November 21, 2012

2D image deformation in Blender

Hello everybody,

Today I will introduce a fairly tortuous way to locally deform 2D images using... Blender. Here's what we're going to do:
 Notice the deformation of the web center



OK, But why not in GIMP ?

I recently wanted to apply a lattice correction on a simple 2D image in GIMP (to correct perspective and bad proportions on a drawing)... but GIMP is seriously missing a good and real-time lattice (or FFD=Free Form Deformation) transformation like the one in photoshop (Warp Tool) for example.

Of course there is the cage grid tool and the interactive "I-Warp" filter. But, the cage grid tool doesn't handle well the connections between the selected zone and the rest of the drawing. The I-Warp doesn't provide a good zoom level and is quite laggy, at least on my PC, and there's no undo function... So here's a little work around.

Be aware that this method is not straight-forward and requires a minimum of setup in blender, but it can handle large-scale smooth deformations in real-time, with various levels of zoom, and undo function. It can save you hours of work on a drawing where you missed a perspective default...

I - Setting up the image plane and material

  • Launch Blender
  • Suppress the default cube
  • In file -> User preferences  -> Addons -> Import/Export, activate the "Import images as planes" addon
  • Import the image you want to modify, don't forget to activate the following options: shadeless, use alpha, premultiply
  • In 3D view, in top view, activate the texture render mode. You should see your image on the plane 
Plane with the base image to modify

 II - Setting up the camera

The goal is to make a render with the same size as your original image
  • Set the rendering resolution to the same size as your image. For example 1600x900 px. Choose RGBA if you want to handle a transparent image.
  • Position the camera right above the plan, let's say at (0,0,2), facing -Z (rotations = 0)
  • Use an orthographic projection.
  • Select a vertical sensor fit of the camera. Choose an orthographic scale of 2 (this is the Y size of the textured plane created by the import)
Now the camera field of view should fit exactly your image with the good ratio and the render will generate an image with the same size.

Camera well-aligned with the plane

III - Finally deforming the image

  • Select your plane, and in edit mode subdivise it many times. This will create the lattice used to deform the image. Be careful! Do not use too many divisions or it will slow down your computer
  • Turn on proportionnal editing and move vertices of the lattice to locally deform your image! Use the mouse wheel to control the deformation radius. You can benefit from Blender real-time texture rendering, 3D zoom/move and undo options.
Subdivising the plane

Proportional editing to locally deform the image


Once you're done, render and save your modified picture! That's it!



No comments :

Post a Comment