Difference between revisions of "Using plane textures for trees, people, etc.. in still rendering"

From Blender for Architecture
Jump to: navigation, search
(Deal with many 2D planes : a forest)
(corrected grammar, not sure what unlick means)
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
Most of the time, pixel images are more suitable to represent people, cars, trees, etc... than 3D model. If these are not the main subject of your render, it often doesn't worth to model a precise 3D object. Moreover, it's very hard to make human or tree models realistics. In addition, they require a huge modelling which increase a lot rendering times and memory consumption.
+
Most of the time pixel images are more suitable for representing people, cars, trees, etc... than a 3D model. If these are not the main subject of your render it's often not worth modelling a precise 3D object. Moreover, it's very hard to make human or tree models look realistic. In addition, they require a lot of modelling which increases rendering times and memory consumption.
  
So, there is a trick to use plane pixel images to fake 3D model in your render. In fact, we will use a cut out image and use it as texture on a plane facing the camera. The result will be the same as a postproduction in Gimp. The advantage to use this trick in Blender rather postprodction is less time consumption because wherever you move you camera, images will always face you, cast shadow on your 3D model and be cutted by a 3D foreground. However, if you use a tree picture shooted from an human height(~1.7m), you cannot use it to render a "from the sky view" of your model.  
+
So, the trick is to use plane pixel images to fake 3D models in your render. We will use a cut out image and use it as texture on a plane facing the camera. The result will be the same as a postproduction in Gimp. The advantage to using this trick in Blender, rather than in postprodction, is that less time will be consumed because wherever you move you camera, images will always face you, cast shadow on your 3D model and be obscured by a 3D foreground. However, if you use a tree picture shot from an human height(~1.7m), you cannot use it to render a "from the sky view" of your model.  
  
 
== Prepare your texture ==
 
== Prepare your texture ==
This is quite a hardwork here. You could find on the web libraries of these cut out pictures of trees and people to skip this part.  
+
This is quite hard work here. You could skip this part by finding libraries of these cut out pictures of trees and people on the web.  
  
Otherwise, take a digicam and shot around you. Prefer to zoom max to avoid perspective effect. Especially for people, make sure feet are horizontal on pictures.
+
Otherwise, take a digital camera and take shots of what's around you. Setting your lens to it's maximum zoom will help avoid the distortion caused by wider angles. When photographing people, make sure feet are horizontal on pictures.
Cut out the subject in your favorite image software (Gimp, Photoshop). The best technique is to use masks to have blurred transition between plains and holes. Once it's done save your picture in PNG for example to keep and alpha layer.
+
Cut out the subject in your favorite image software (Gimp, Photoshop). The best technique is to use layer masks and have a blurred transition around the cut out image. Once it's done save your picture in a format that supports an alpha layer, PNG is a good choice.
  
 
[[Image:lime.png|300px]]
 
[[Image:lime.png|300px]]
Line 30: Line 30:
 
[[Image:tree scene-02b.png|300px]]
 
[[Image:tree scene-02b.png|300px]]
  
Plane dimensions should be the same ratio as the texture size. For example if your texture is 500x1000px, your plane could be 2.5x5 blender unit.
+
Plane dimensions should be the same ratio as the texture size. For example if your texture is 500x1000px, your plane could be 2.5x5 blender units.
 
In our example, the texture size is 477x664px so : select the plane object, press "N" and set the dimensions as follow.
 
In our example, the texture size is 477x664px so : select the plane object, press "N" and set the dimensions as follow.
  
 
[[Image:tree scene-02c.png|300px]]
 
[[Image:tree scene-02c.png|300px]]
  
This also means that our tree is 6.64 units tall. That's a bit small for that kind of tree. We can resize it by the pressing the "S" button and moving until we get 8 units tall. Ratio will be preserved ;-).
+
This also means that our tree is 6.64 units tall. That's a bit small for that kind of tree. We can resize it by the pressing the "S" button and moving until we get 8 units tall. The ratio will be preserved ;-).
  
Move the plane until the base just reach the ground.
+
Move the plane until the base just reaches the ground.
  
 
Start a render.
 
Start a render.
Line 45: Line 45:
 
[[Media:tree scene-02.blend|Blend file of the scene]]
 
[[Media:tree scene-02.blend|Blend file of the scene]]
  
Tips: If you don't see the tree transparent shadow on the ground, tick the TraShadow button of the ground material (not the tree material).
+
Tip: If you don't see the tree transparent shadow on the ground, tick the TraShadow button of the ground material (not the tree material).
  
 
== Deal with many 2D planes : a forest ==
 
== Deal with many 2D planes : a forest ==
  
This a good start, not to say the basis. But one tree is something, a forest is another one. We must be careful using 2D objects.  
+
This a good start, but a single tree is one thing, a forest is another. We must be careful using 2D objects.  
First, 2D have to be always facing the camera.  
+
:First, 2D images always have to face the camera.  
Second, their shadows must fit with you main shadow lamp.
+
:Second, their shadows must fit with your main shadow lamp.
Third, you must be able to duplicate your 2D objects (in our case, trees) to spread them among you scene.
+
:Third, you must be able to duplicate your 2D objects (in our case, trees) to spread them among your scene.
  
I have UVmapped the plane to see our tree in the 3D view so you can understand what happen easily. (Uvmapping is another topic not explained here)
+
Prepare your object to constraints
 +
 
 +
Select your tree object, press N and fill RotZ: to 0. Press CTRL-A to apply size and rotation. This was to fix correct rotation and size before constraint.
 +
Go to material panel (F5).  In texture map input, tick Cube because our plane is vertical now.
 +
 
 +
I have UVmapped the plane to see our tree in the 3D view so you can understand what happened easily. (Uvmapping is another topic not explained here)
  
 
[[Media:tree scene-03.blend|Downlad the .blend source file]]
 
[[Media:tree scene-03.blend|Downlad the .blend source file]]
  
 
=== Face the camera ===
 
=== Face the camera ===
 
Select you tree object, press N and fill RotZ: to 0. Press CTRL-A to apply size and rotation. This was to fix correct rotation and size before constraint.
 
 
Go to Object panel (F4) and add a "Copy rotation" constraint. Fill the target object name with the camera name. Switch off X and Y, keep Z.
 
Go to Object panel (F4) and add a "Copy rotation" constraint. Fill the target object name with the camera name. Switch off X and Y, keep Z.
 
Ok, so the tree will follow the camera rotation to always face it.
 
Ok, so the tree will follow the camera rotation to always face it.
  
[[Image:tree scene-03.png|300px]]
+
[[Image:tree scene-03.png]]
  
=== Shadow face the main lamp ===
+
=== Shadows face the main lamp ===
Another issue is that if you tree face your camera but not the lamp, you will get a tiny shadow or weak shadow. If it were a real 3D tree, would have been always the same and in the same direction.
+
Another issue is that if your tree faces your camera but not the lamp, you will get a tiny shadow or a weak shadow. If it were a real 3D tree, the shadow would be right in any direction.
  
Therefore, we need to separate the tre image from the shadow.
+
Therefore, we need to separate the tree we will see and it's shadow.
(WIP)
+
Duplicate (Shift-D to duplicate without link) your tree on the same place.
  
 +
In the constraint, change the target to the main lamp of your scene.
  
You can now duplicate (ALt-D to duplicate link) your tree around the camera to create a forest :D.
+
[[Image:tree scene-04.png]]
  
[[Image:tree scene-03b.png|300px]]
+
Thus, we have one tree facing the camera and one tree facing the lamp.
  
[[Image:tree scene-03c.jpg|300px]]
+
We must modify materials to get one showing the tree without casting shadows and the other one only casting shadow.
  
[[Media:tree scene-03.blend|Downlad the .blend source file]]
+
Select the tree facing the camera and go to material panel (F5)
 +
 
 +
Untick "Traceable"
 +
 
 +
[[Image:tree scene-05.png]]
 +
 
 +
Select the tree facing the lamp. Create a new Material to unlick the two tree materials. Tick "Traceable" and "OnlyCast"
 +
 
 +
[[Image:tree scene-06.png]]
 +
 
 +
[[Media:tree scene-04.blend|Downlad the .blend source file]]
 +
 
 +
=== Duplicate the trees ===
 +
We will use the Duplivert function. A tree will grow out of earth on each vertex of an third party object.
 +
 
 +
Position your cursor to a tree origin (Shift S). Go to top view (7), add a plane to your scene. Subdivide it 4 times to get a grid. Size it to fit with the ground already there. Trees must not be too close. Select your two trees and the plane (Shift+Reight button mouse). The plane should be selected in last. Press Ctrl-P to create a parent link. While plane selected, go to object panel (F7) and tick "Dupliverts".
 +
 
 +
[[Image:tree scene-08.png]][[Image:tree scene-07.jpg]]
 +
 
 +
[[Media:tree scene-05.blend|Downlad the .blend source file]]

Latest revision as of 22:38, 14 April 2007

Most of the time pixel images are more suitable for representing people, cars, trees, etc... than a 3D model. If these are not the main subject of your render it's often not worth modelling a precise 3D object. Moreover, it's very hard to make human or tree models look realistic. In addition, they require a lot of modelling which increases rendering times and memory consumption.

So, the trick is to use plane pixel images to fake 3D models in your render. We will use a cut out image and use it as texture on a plane facing the camera. The result will be the same as a postproduction in Gimp. The advantage to using this trick in Blender, rather than in postprodction, is that less time will be consumed because wherever you move you camera, images will always face you, cast shadow on your 3D model and be obscured by a 3D foreground. However, if you use a tree picture shot from an human height(~1.7m), you cannot use it to render a "from the sky view" of your model.

Prepare your texture

This is quite hard work here. You could skip this part by finding libraries of these cut out pictures of trees and people on the web.

Otherwise, take a digital camera and take shots of what's around you. Setting your lens to it's maximum zoom will help avoid the distortion caused by wider angles. When photographing people, make sure feet are horizontal on pictures. Cut out the subject in your favorite image software (Gimp, Photoshop). The best technique is to use layer masks and have a blurred transition around the cut out image. Once it's done save your picture in a format that supports an alpha layer, PNG is a good choice.

Lime.png

Tree cut out picture in PNG

Create your tree in Blender

To make it easier, this a Blender start scene where your tree could grow in serenity. (A green grass plane with a sunlight and a blue sky :)

Tree scene-01.jpg

Blend file of the start scene

First, create a vertical plane object in the center of your grass plot.

Create a new material for this plane object in the shading panel (F5). Create a new texture for this material, choose "bitmap" as type and load your tree picture. Tick "UseAlpha" and the "Alpha" button near the preview to see transparency.

Tree scene-02.png

Go back to the material panel. Tick Ztransp, Shadeless, put Alpha slider to 0. Tick Alpha in the "Map To" tab. That's it for the material.

Tree scene-02b.png

Plane dimensions should be the same ratio as the texture size. For example if your texture is 500x1000px, your plane could be 2.5x5 blender units. In our example, the texture size is 477x664px so : select the plane object, press "N" and set the dimensions as follow.

Tree scene-02c.png

This also means that our tree is 6.64 units tall. That's a bit small for that kind of tree. We can resize it by the pressing the "S" button and moving until we get 8 units tall. The ratio will be preserved ;-).

Move the plane until the base just reaches the ground.

Start a render.

Tree scene-02d.jpg

Blend file of the scene

Tip: If you don't see the tree transparent shadow on the ground, tick the TraShadow button of the ground material (not the tree material).

Deal with many 2D planes : a forest

This a good start, but a single tree is one thing, a forest is another. We must be careful using 2D objects.

First, 2D images always have to face the camera.
Second, their shadows must fit with your main shadow lamp.
Third, you must be able to duplicate your 2D objects (in our case, trees) to spread them among your scene.

Prepare your object to constraints

Select your tree object, press N and fill RotZ: to 0. Press CTRL-A to apply size and rotation. This was to fix correct rotation and size before constraint. Go to material panel (F5). In texture map input, tick Cube because our plane is vertical now.

I have UVmapped the plane to see our tree in the 3D view so you can understand what happened easily. (Uvmapping is another topic not explained here)

Downlad the .blend source file

Face the camera

Go to Object panel (F4) and add a "Copy rotation" constraint. Fill the target object name with the camera name. Switch off X and Y, keep Z. Ok, so the tree will follow the camera rotation to always face it.

Tree scene-03.png

Shadows face the main lamp

Another issue is that if your tree faces your camera but not the lamp, you will get a tiny shadow or a weak shadow. If it were a real 3D tree, the shadow would be right in any direction.

Therefore, we need to separate the tree we will see and it's shadow. Duplicate (Shift-D to duplicate without link) your tree on the same place.

In the constraint, change the target to the main lamp of your scene.

Tree scene-04.png

Thus, we have one tree facing the camera and one tree facing the lamp.

We must modify materials to get one showing the tree without casting shadows and the other one only casting shadow.

Select the tree facing the camera and go to material panel (F5)

Untick "Traceable"

Tree scene-05.png

Select the tree facing the lamp. Create a new Material to unlick the two tree materials. Tick "Traceable" and "OnlyCast"

Tree scene-06.png

Downlad the .blend source file

Duplicate the trees

We will use the Duplivert function. A tree will grow out of earth on each vertex of an third party object.

Position your cursor to a tree origin (Shift S). Go to top view (7), add a plane to your scene. Subdivide it 4 times to get a grid. Size it to fit with the ground already there. Trees must not be too close. Select your two trees and the plane (Shift+Reight button mouse). The plane should be selected in last. Press Ctrl-P to create a parent link. While plane selected, go to object panel (F7) and tick "Dupliverts".

Tree scene-08.pngTree scene-07.jpg

Downlad the .blend source file