9/30/13

How to enable CUDA in Linux (Ubuntu) for Blender

You can easily enable CUDA in Ubuntu. CUDA is capable of delivering faster render in supported GPU.
First of all make sure that you have CUDA supported Nvidia graphics card. If so connect to Internet,

Open Ubuntu software center.
Go to editsoftware sources→other software
and turn on
Canonical partners and independent
Save and close.
Open terminal and type
“sudo apt-get update” .
Press enter and give password for root. Wait for the update to finish. Then type
“sudo apt-get install”
Press enter and wait for the installation to finish. Close the terminal and reboot.
You can use Ubuntu DVD also if you haven't internet connection. Just turn on DVD as installation media.
Open Ubuntu software center.
Go to editsoftware sources→Additional drivers
And look for available nvidia drivers. If found any install the latest proprietary driver. (you wont get the latest as from the developers site).
If you can't find any drivers,
In the Ubuntu software center search for “ additional drivers” and click on that link. Install or use this source. Restart your computer and repeat the steps.

Once installed you need to restart your computer to get the driver to work properly.
Open a new Blender, turn on CUDA and do a test render with GPU. You will get the GPU render.
If the render yields only black output you need to add some libraries.
Open terminal and type

“sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev”

then
“sudo apt-get update”
“sudo apt-get install”
Reboot your computer. CUDA will work perfectly.
Some times you may not get the correct CUDA rendering. Then you need to update Blender first. Update nvidia driver manually.

Update nvidia driver manually.

You can get the latest nvidia driver by manual installation. But you need to manually install the driver whenever you update your Linux kernel.
Download latest nvidia driver from manufactures website. Select the correct version suited for your system (32/64).
Copy it in desktop and rename to nvidia.run
Press CTRL+ALT+F1.
Login with your user name and password.
Then type
sudo service lightdm stop”
then
“cd Desktop”
“sudo ./nvidia.run”
carefully follow the on screen instructions and install the driver.
You will get several error message. Proceed further by clicking ok until you reach installation can continue.
Type
“sudo reboot”.
After reboot repeat the process from CTRL+ALT+F1
Follow the onscreen instructions and you can successfully install nvidia driver.
 Once finished either you can restart or start using your desktop by typing
sudo service lightdm start”

9/28/13

Glass bottle in Blender Modeling tutorial

Hi. In this tutorial you will learn about the basic modeling tricks in Blender. We will discuss about the modeling of a photo realistic glass in Blender. Starting from a cylinder we will gradually add more details to the mesh.

Difficulty      : Beginners
Software      : Blender 2.68 a
Total time     : 15 minutes
Download the finished scene file  :  Download .blend file
Topics covered.
  • Primitive -Cylinder 
  • Mesh editing 
  • Edge loop cut and slide
  • Bevel edge 
  • Edge loop 
  • Fill hole 
  • subdivision modifier
  • Solidify modifier 
  • Glass material 
Glass Bottles in 3d
In the next part we will discuss about photo realistic rendering (studio lighting) set up in Blender.


Here is the quick text version
  • Open blender and delete the default cube.
  • Create a new cylinder from add object menu. (add>mesh>cylinder).
  • Change the depth (from tool box) to 6. Also turn on smooth preview.
  • Locate the object property panel in the right side, change the name to glass bottle.
  • Under display turn on wire and draw all edges.
  • Change to edit mode. Press 'a' to deselect all vertices.
  • Jump to front orthographic view and turn on wire frames.
  • In the tool shelf find loop cut and slide (you can find at add tab just below extrude).
  • Click it and create a cut at the center of the cylinder.
  • Change the number of cuts to 6.
  • De select all.
  • Select the bottom vertices (use b) and scale it to 0.75.
  • Select the second edge loop and move it down ward (z=-3.9).
  • Also select the 3rd edge loop and move it downward (z=0.9).
  • Select the 4th edge loop and move it to the center cut.
  • Select the 5,6 and 7th edge loops and scale it in z axis (z=0.3) and move it towards the top edge loop.
  • Select the 6th edge loop and scale it to 0.45.
  • Select 7th and 8th edge loops and scale it to 0.65.
  • Select the 4th edge loop and scale it to 0.75.
  • Change to edge mode and press ctrl+b to bevel and drag. Change the offset to 1 and segments to 4.
  • Select one edge from 2nd and 3rd edge loops and press ctrl+e and chose edge loop.
  • Do a bevel again.
  • Select the 5th edge loop and bevel it with 6 segments. offset 0.33 Also press smooth vertex under tool shelf.
  • Select 6th edge loop and bevel it.
  • Also do a bevel for 7th edge loop.
  • Change to solid mode then select the bottom and top faces of the cylinder and delete.
  • Then add a subdivision modifier and apply.
  • In the edit mode select the bottom edge loop and press 'f' to fill the hole.
  • In the object mode add a solidify modifier. Change the thickness to 0.07. Click apply.
  • Try smoothing the top edges a little bit.
  • Move the bottle in z=3
  • Use the origin to the 3d cursor.
  • Save the scene.
  • You can add a glass material under cycles for rendering.
In the next part we will discuss about studio lighting in Blender.
Some Blender fluid simulation renders

9/23/13

Windows vs. Linux in 3d rendering

Which operating system is the best for rendering? A question I often ask and search; I think it is often asked by you also. Ok, what is the answer?
In my experience Linux is 1.62X or 62% faster than windows. That means Linux can render more than 3 frames where Windows can render only 2 frames at a given time. Unfortunately I don’t have a Mac computer, so it is not in the comparison list.
The operating system or OS included in this test are
  • 1. Microsoft Windows 7 64 bit
  • 2. Ubuntu studio (Linux) 13.04 64 bit
3d application used
  • Blender 2.68 a 64 bit
Rendering software used
  • Cycles render (pre installed with Blender).
All the tests are done on a multi boot single laptop. The hardware configurations are
  • Dell XPS 14 laptop
  • Intel core i7 processor with 1.74 GHz speed.
  • NVidia GT 425M Graphics card
  • 4 GB DDR3 RAM 1333 MHz
  • 500 GB HDD 7200 RPM
Display Drivers used,
  • NVidia display driver 314.07 for Windows 7
  • NVidia Binary display driver 310 for Ubuntu
You can see, the hardware components are identical. The scene file used is the same for both operating systems. 3d program used is the same for both OS.
Here is the final render.
rbcs on glass bottle
Here are the details of the scene.
  • A photorealistic (?) glass bottle with studio lighting.
  • Dynamically driven RBCs are present inside the bottle.
  • All the materials used are Cycles shaders.
  • Indirect lighting with full global illumination.
  • Total samples of 1000 are used in rendering.
  • Total number of polys includes 8072. Total size of the scene is 1.64 MB.
  • The final output is HD 720P i.e. 1280x720.

Conditions
Windows 7 64 bit
Ubuntu studio 64 bit
Before optimizing the PC
Total RAM usage
1.52 GB i.e. 38% 360 MB i.e. 9%
After optimizing the PC
Quit unwanted programs and services, total RAM usage
1.06GB i.e. 26.5% No optimization performed
After opening the scene in Blender total RAM usage 1.48 GB 37% 548 MB 13.7 %
During rendering RAM usage 1.44 GB 36% 520 MB 13%
During rendering CPU used for Blender 98-99% Rest is reserved for system. 97-98% Rest is reserved for system
Total render time 18 minute 12 seconds 11 minute 16 seconds

So Linux is the winner in 3d rendering race.
Unfortunately CUDA rendering is not working in Ubuntu studio (I need to add some CUDA libraries in Ubuntu). So there is no test for CUDA or GPU rendering. May be in some other time.

Update

OK, I successfully updated my CUDA driver in Linux.See how I enabled CUDA in Ubuntu Now it is perfectly working. So what? I rendered the above scene in Blender using GPU in both Linux and Windows. Surprisingly the result is almost same! A slight performance gain in Windows.

Windows 7 64 bit
Linux Ubuntu Studio 64 bit
GPU rendering (CUDA)
12.53 Minutes
12.58 Minutes
So for GPU rendering, Windows 7 64 is the winner (with photo finish).
I think it is because the CUDA driver and graphics card driver have better optimization in windows than Linux.

Conclusion

According to my hardware specification Ubuntu CPU rendering is the fastest.
Here is the final comparison,
1st prize
Ubuntu 64 CPU rendering
  11.16 minutes
2nd prize
Windows 64 GPU rendering
12.53 minutes
3rd prize
Ubuntu 64 GPU rendering
12.58 minutes
4th prize
Windows 7 64
18.12 minutes

I also noticed that Maya also have a clear performance boost in Linux environment. But Maya will work only in RPM based Linux environment. For Maya Cent OS is the best.
I don’t know about Mac OS.
Have you ever feel slow rendering? Try switching your operating system first. Then upgrade your hardware.
So what you think? Post your comments and result below.

9/14/13

Waving flag-cloth stimulation in Blender

India celebrated 66th Independence Day on August 15 2013. In honour with my country I am giving a free Independence Day template for Blender users. And also a full length tutorial about Independence Day theme. This template is based on Indian theme you can easily change it to suits with your country. If you are eager to render out just download the blender file. If you have enough time, watch the video tutorial and create from scratch.
Difficulty : Beginner
Software : Blender 2.68a
Download : independence Day Blender template. (You can use it with your commercial project. Do not redistribute in any form. You can directly link to this page instead.
clip_image002
In this tutorial you will learn about
  • Adding text in Blender
  • Modifying text in Blender
  • Interactive changing of text properties (font, letters etc.) in Blender
  • Basic material editing in Blender
  • Camera animation in Blender
  • Cloth stimulation/ flag stimulation in Blender
  • Lighting and rendering with cycles in in Blender
  • Open a new blender scene and delete the default cube.
  • Add a text object (add>text, shift + A> text).






9/11/13

Render Layer in Cycles Blender tutorial

Blender is an awesome free 3d application which provide similar functionality like Autodesk Maya, 3ds Max and Cinema 4d. Blender is a powerful easy to use 3d application if learned wisely. If you are a user of other 3d application you may get confused with nonstandard GUI, keyboard shortcuts and lack of well detailed documentation.
I was one of the failed Blender climbers who tried several times Blender before. But being stuck with Autodesk Maya, it was a pain to learn other 3d software. I even tried Cinema 4d which is very easy to learn but failed. So I understood that Blender is not hard but my love for Maya is so strong. So I just started using Blender in my home and production and soon I get used with Blender. Now I can make motion graphics with Blender easily and am still learning it. Anyway during my experiments with Blender I found that there are so many gaps in the area of Blender tutorials. So I am adding more tutorials about Blender.

blender render layer
Enough introductions. We can now learn to use Blender render layers efficiently in production. Don’t expect very complex set up, but I will guide you through three cubes in a scene and with render layers. It will be easy to follow and understand. I am adding a text version but I recommend watching the video tutorial.

Author : FermiCG
Software : Blender 2.68a
Difficulty : Beginner
Download : Render Layer cubes finished.blend
Blender has a well coded render layer, render passes and compositing work flow. Once you learn how things works inside Blender it is easy to use and straight forward than Maya’s render layer system.
This tutorial is based on blender 2.68a.But 2.6x series will work fine. If you don’t have blender download it free from blender.org.
 
Start with a new scene. You will get a default cube, camera and a light. Select the cube and add a new material and change the colour to red. (Find the material tab and press the + button and add a material. Change the diffuse colour to red.). materials in blender
In viewport duplicate the cube (shift +d) and delete the existing material by clicking – button on material tab. Add a new material and change colour to green.
Duplicate the cube again and replace the material with blue one.
Place the cubes in such a way that they intersect each other. See the image.
materials in blender
Press 0 to look through the camera. If needed, adjust the camera so three cubes are in focus.
materials in blenderWe are going to render the scene with cycles. So change to cycles render. Set the quality and dimensions. Optionally you can turn on transparency and RGBA. Press render and see how the render looks.
camera in blenderJump to composite mode and see the connections. You will get a render layer node connected to composite node (just turn on nodes). We need to get three cubes in three different render layers. Back to default view.
composite in blenderIn order to get render layers properly, we need scene layers also. So select the green cube and press M and select 2nd layer. This will cause the green cube to be in 2nd scene layer.
layers in blenderSelect the blue cube and press M and select 3rd layer. You can click on each scene layer to confirm they are in correct order. Select first layer and render. Now we have the red one with lighting. Select second layer and render. 2nd and 3rd layer won’t have any lights or shadow. Select 1, 2 and 3 layer (shift select) and render again. We will get all the cubes with light and shadow.
We successfully created scene layers. But we need render layers. So find the render layer tab in properties menu.
layers in blenderYou can see a drop down window with render layer inside and “+, -“sign outside. This is the render layer tab. Below that you can see layer tab. Expand it and you will get scene, layer, exclude and mask with 20 columns each. They are different render layer settings. The first one scene is same for the scene layer in viewport. You can click on 1, 2 and 3 scene layer to check. The layer in the right is actual render layer. So select the 1st scene layer and rename the render layer to red. Also select the 1st column in layer. Make sure you are not selecting anything else.
layers in blenderSelect the 2nd scene layer and add a new render layer by pressing + button. Rename to green. Select the 2nd column under layer.
render layers in blenderSelect 3rd scene layer and add a new render layer. Rename it to blue. Select the 3rd column under layer.
Select all the three scene layer and render.
render layers in blenderBlender will render the cubes one after other. You may see black holes in render. You will get something similar to this.
render layers in blender
black hole in blenderSwitch to composite view. You can see render layers is connected to composite node. Select the render layers and click on the layers and chose different layer. You can use this for further compositing.
node editor in blenderLeave it to red. Duplicate render layers 2 times (shift +d) and change the 2nd one to green and 3rd to blue. (Shift+ backspace for full view).
render layer nodes in blenderWe need to combine these layers. In order to do so add an alpha over node (add>colour>alpha over)
Now connect the image of red to the bottom image of alpha over node.
alpha over node in blenderConnect green image to the top image of alpha over node.
alpha over node in blenderAdd another alpha over node. Connect the blue image to bottom image of 2nd alpha over node. Also connect image of 1st alpha over to the top image of 2nd alpha over node.
alpha over node in blenderNow we need to connect the 2nd alpha image to the composite node. You can lose the connection between red layer and composite node.
connection in blenderNow we need to check our composition. Add a viewer node. (Add>output> viewer)
 viewer node
Connect the second alpha over image to the image of viewer node.

backdrop in blenderAlso turn on backdrop.
final compositNow we have the composited image. You can swap the connection between render layers with alpha over node. But still you won’t get the original output. The black hole remains there. In order to get rid of those black holes we need to add mask layers. Switch to default view. Select the red render layer (which contains red cube) and under mask layers select 2nd and 3rd columns because we need them as mask for the first layer. Repeat the same for all the layers. Remember you need to choose the layers you want to mask. For green, use 1st and 3rd. for blue use 1st and 2nd.
mask layersRender again to see the magic. Jump to composite mode.
composited renderNow we have the cubes in correct order. You can swap the connection and still the render is the same.
We need to explain one more render layer settings named exclude layer. Exclude layer in Blender is used for excluding something from render. For example we have a plane just intersecting the three cubes. We need to render the plane separately without having any shadow or mask, we can use exclude layer. Additional use of exclude layer can be explored on further tutorials.
So add a plane and place it in such a way that it intersects the cubes and faces towards the camera.
intersectMove it to a new scene layer (4).Add a new render layer named plane. Set the render layer. Don’t use any mask layer.
soloJump to composite mode. Add a new alpha over node and a render layer node. Change the render layer to plane. Connect it to the bottom image of 3rd alpha over node. You need to connect the 2nd alpha over node to the top image of 3rd alpha over node. Also connect the 3rd alpha over to the viewer node and composite node. Render to see the result. You should get something like this.
extra node in blenderWe need the plane as it is. Shift to default view and in the render layer settings select the plane render layer. In the exclude layer select 1, 2 and 3 column. Select the entire scene layer and render again. Now we will get blender tutorial
This concludes the render layer in Blender tutorial.
Hope you enjoyed this tutorial. Drop your comments and critiques.