The online racing simulator
Rendering with Blender Tutorial
(194 posts, closed, started )
Rendering with Blender Tutorial
NOTE: this tutorial is obsolete now, Go here if you want better and easier result.

Hi all :jester:
this is my promised tutorial for rendering in Blender.

CHANGELOG:
27/05/2007 - A package with all the cars converted into .blend files is now available, click here to download it, and skip the third paragraph in the tutorial.
06/03/2007 - the tutorial is merged in one post, it's easier for me to edit it now (thanks to admins )

WARNINGS:
  • I have doubts about alpha texture channel activation in this tutorial, I think I missed some steps. Just PM me if it's true
  • This tutorial was written under 2.42a version of Blender, .obj importation within Blender 2.43 crashes, so the current best solution to import .obj file is to keep a 2.42a Blender installation for importing .obj files. 2.42a and 2.43 installed on the same computer work fine, there's no conflict if they don't share the same directories. Of course an ultimate solution consists to write only one script which imports cmx files directly into Blender and uses its interface...
Let's start:

----------------------------------------------------------------
  1. tutorial objectives
  2. prerequisites
  3. the import processus
  4. arranging the model
  5. First render
  6. Fixing problems
  7. High quality render
  8. Precision tweaks, advanced materials, scene environment
----------------------------------------------------------------

1. TUTORIAL OBJECTIVES
So you want to render your great skin(s) but you don't want to buy the very expensive 3dsmax+brazil (or illegally download it ) or simply want to use the cool free open source Blender software? You made a good choice
Blender and the rendering engine Yafray are powerful enough to get impressive results just like 3dsmax. They are powerful enough to make LFS renders anyway. So, in this tutorial I will try to be explicit enough to be understood by the true noob, however I highly recommend to be familiar with Blender and Yafray interface and functions.
I will not teach you anything how to manipulate image files; It's a Blender "how to" only.

Unfortunately, English is not my mother language, so I may do mistakes in this text. Feel free to send me private messages if I write something like a 2 year old child. Of course, this tutorial is not finished and will be enhanced. I'm opened to suggestions and questions
2. PREREQUISITES
The software part: Of course you need:Note that I don't send direct links to the files, they can change without notice, and I want you to take the time to visit the sites and learn about what you are downloading.

The mental part: I said in the previous chapter that this tutorial can speak to true noobs, but in order to understand easier, I recommend to do "RTFM":I insist you should understand the Yafray's functions, since a good render calculation can take 1-2 hours. So be careful about it.
I know that Blender's interface is not intuitive, but it's not its goal. Keyboard shortcuts are used most of the time, and production is easy and fast. Only one thing to do to success: learn it. In my case I read the entire manual before creating my first models. Tutorials are not very helpful, it's more comfortable to know what we are talking about.
3. THE IMPORT PROCESSUS
Now the interesting part. First of all, install Blender, Yafray and LFS viewer. It should not be difficult. Installation paths are not important, install them where you want.

Setup Blender
Execute Blender. If you are familiar with Blender and Yafray, skip this paragraph. If you run Blender for the first time, you should see a cube in the center of the weird interface. It's the default scene. Simply select the cube by clicking it with the right mouse button (sorry I lost this default scene I can't post a screenshot). The cube must be highlighted. Next press "Suppr" keyboard key to erase it. Confirm "erase selected object". Now the scene is empty. The final easy step, press "Ctrl+U" keys to save the scene as the user default scene which appear every time you start Blender.

The conversion script
Now we will use the Tomdemuer's script to convert cmx files to obj files. This is a script written in python language, a great language easy to learn and IMHO easier and better than basic. But you don't have to learn python. Since it's a python script, you need a python interpreter to run it. Fortunately Blender integrates an interpreter, we will use it. Open blender and open the "Text editor window" in "window type" selector.



Next open the script file (stored anywhere on your computer). And look at the parameters. This is the tricky part, first of all python language uses Unix style slashes for filepaths ("/" instead of micro$oft's "\") yeah python language is multi-platform. Now setup the lines:
  • filePath = enter the path where LFS viewer's "cmx" folder containing the cmx files is located, in other word, enter the "data" folder filepath, BECAUSE this script will locate the "cmx" folder automatically. Don't forget to enter the paths between " characters, and to enter "/" slashes instead of "\" anti-slashes.
  • fileToLoad = enter the cmx file's filename you want to convert. If the file is called FZR - FZ50 GTR.cmx, then enter "FZR - FZ50 GTR" (the filename without the extension). In the script, there a line #fileToLoad = "FOX - Formula XR", it's only a comment line, it does not affect the script at all, you can erase it if you think it's useless for you.
  • outputDir = the destination directory where the .obj and .mtl files will be stored after conversion. I personally like to create a dedicated folder for these files to avoid a mess.
  • outputFileName = the .obj and .mtl filenames, enter what you want whithout the file extension.
When all is OK, you can run the script by pressing "Alt+P" keys. Don't expect any reaction, just check if the files are correctly created. Note that the script convert one file only. Repeat the operations for each car you want to convert.

Import the file
Ok now click "File>New", confirm "Erase all", and then "File>Import>Wavefront (.obj)"



Locate the converted file you want to import and click "Import a Wavefront OBJ" to open it. A new box appears, check the same buttons as the next screenshot:



Be careful: your mouse must not exit the box area, otherwise it will disappear and you must redo the import procedure . Yeah, it's boring me too.. Blender's interface weak point... Click OK and:


:woohoo:
Immediately save your .blend file.
4. ARRANGING THE MODEL
Currently we have an basic model, it lacks of texture and material.
Now we will prepare the textures. The LFS models use dds texture images and one jpeg file (your skin). However, nor Blender or Yafray support .dds file format. So, do this boring operation:
Convert with your favorite image manipulation program all the .dds files located in "dds" folder of LFS Viewer or LFS the-game, to .tga files in a dedicated folder to be easily exploitable with Blender. Why .tga files? because:
Quote from the Yafray's FAQ :YafRay only supports a limited set of texture formats, which are Targa (.tga), Jpeg (.jpg), Radiance (.hdr/.pic) and OpenEXR (.exr)

So to keep good quality and alpha blending, .tga is IMO the best choice.
I can't tell you how to convert these files, personally, I use Photoshop with nvidia's dds plugin, and used a script to convert all the files in one operation. There's many other methods and many other softwares.

Next step is applying textures. Here are some basics commands:
  • select an object with right mouse button
  • rotate the view by moving the mouse while mouse wheel button is pressed
  • translate the view by moving the mouse while mouse wheel button and "Shift" key are pressed
Now check if you are in "Object mode", "Shading" and "Material" buttons selected.



Select a body part, the hood for example, and check if the material's name is "DEFAULT". We will apply your skin on the body. Click "Add new" button, replace "TE:Tex.001" by "TE:myskin". It's important to name the different elements to avoid confusions. Click on the "Texture button" just on the right of "Material button", or press "F6" key. We just entered in the texture definition panel, and are about to edit "myskin" texture. In "Texture type" rollout, select "Image", and in the just appeared panel, click on "Load image" button. It should not be difficult. Now located your skin, a .jpg file. Once your skin is loaded, you should see it in the preview panel. Ok the image texture is loaded, now it's time to apply it correctly on the body mesh. Return to the "Material" panel (press "F5" key), and select the "Map input" tab



Check "UV" Button to activate the correct texture coordinates, and enter the value "-1" in "sizeX" and "sizeY", because the conversion script invert all the UV texture coordinates.. I already tried to fix the problem but my coding skills are not enough powerful . Anyway it doesn't matter, we just want to render the car.

The body part is now textured, I suggest to separate it from the other parts since we can't directly see if a mesh is textured. So keep the body selected, press "m" key. A little box should appear with 20 little squares. Select the second and "OK". We just moved the body object into the second layer of the scene. If you want to make appear it back, toggle the second layer by clicking on it while pressing "shift" key.

The next is similar than the body mesh, except the loaded texture. Each part has its one (remember the .dds files you converted earlier) So select another part, and check the material's name. The body material's name was "DEFAULT", but the other parts material's name is the texture file's name it must use.
So in my example, if I select the roof of the LX4 in the 3D view, I see "MA:LX_interior1" in the material's name. OK I add a new texture, rename it "LX_interior1", edit it (by pressing "F6"), select "Image" in "Image type" rollout, and load "LX_interior1.tga". Next, is exactly the same than the body part, I return to "Material" (F5), check UV button, enter "-1" in "sizeX" and "sizeY", and finally move the mesh in the second layer. Great, if you understood everything until now, repeat the same operation for the remaining untextured parts, but Be Advised: some meshes can share the same material, don't reload a texture if everything is already done for this part (eg: seats, mirrors, interior parts), just move it in the second layer.
  • About the "(null)" material: it's a pure black material, don't add a texture for it, just set the diffuse color to black.

  • About windows and glass-equipped parts: these parts don"t need a texture, just move it in the second layer.
  • About textures with alpha channel: click on "Use Alpha" button just above "Load image" button. I hope you saved alpha channel of your .tga files when you converted the .dds ones. What is Alpha? it defines transparency of the image texture. It is useful to see through holes of radiator grids for example.
5. FIRST RENDER
Well, we are far to have all the conditions to make a great render, but I think now it would be interesting to see what we have done.
What we will do now:
  • setup a lamp
  • setup a camera
  • setup the world
  • setup the rendering engine
  • surprise
Setup the lamp
We need to add a lamp to see something in the dark :dopey:, and to add shading to the model.
Click on the menu View>View properties. A box should appear in the 3D View. Setup the 3D cursor coordinates to X=0, Y=0, Z=10. check if the 3D cursor is actually 10m above the ground.
Next press "Numpad7" key to set the 3D View to "Top view". Now the conditions to add a lamp are good, the lamp will be added at the cursor position and in a ground-parallel orientation.
Click on Add>Lamp>Area. Setup the "Size", "Energy", and "Dist" values like the next screenshot:



The lamp is now set up

Setup the camera
Close the "View properties" box, click anywhere in the 3D View and click on Add>Camera. We need to see what the camera is watching. Right click on the bottom 3Dview border, select split areas, and click on the 3D view. A new window must appear.



Click on View>Camera on the new 3D view menu

Next press the "N" key to make appear the "Transform properties" box. The camera should be selected, next enter "RotX: 90", "RotY:0", "RotZ:0", in order to set the camera in a good basic position.



Setup the camera properties just like the above screenshot (lens, clipping and show).
Activate the transformation gizmo by clicking on the hand icon, and set the local mode on. You can translate and rotate the camera by click'n'drag on the gizmo axis. Try to get a correct cadrage (is this word correct?)
If you can't see the car in the camera view when the camera is pointed to it, adjust the clipping values, the car must be in the camera distance range.

Setup the world
Yafray uses the world color to create an ambient light. Click on the "Shading" button, then the "World" one, and set the left color to white. That's all!



Setup the rendering engine
Click on the scene button
  • In the "Output tab, select "Render window" in the rollout, and toggle the spawn position to center.
  • In the "Render tab", select "Yafray" rendering engine, unpress "OSA" button
  • In the "Yafray" tab, unpress "xml" button, "auto AA" button, and set "AA passes" value to zero.
  • In the Yafray GI tab, select "Full" method, "Low" quality, and press "Cache" button.


Now save your work (Ctrl+W)

Are you ready? press the big yellow button called "Render" in the "Render tab...

Surprise



:wtf2: :vomit:

Yeah it's ugly, Yafray doesn't seem to be powerful, but all the settings are low, and we don't need to make a 10 hours calculated render to see what is wrong with our model.

First of all, the most shocking is the tire colour, I don't like white tires, you too. Next there's a problem with rims, we must unify the rims element into one object with its own rim material.
We can see that there are some white parts, it's actually a texture problem, we can correct it easily.
Finally the glasses are not transparent.

We can conclude we still have a lot of work :yipee:
6. FIXING PROBLEMS
Fix the rims
Select all the wheels and move them in the first layer (maintain "Shift" key to perform a multi-selection).
We need to separate the rim part from the tire part. Select a rim, enter in "Edit mode" (press "Tab" key), toggle "Face selection mode", and select all the faces that should be the rim.



There's several method to select:
  • the traditional right click, maintain shift for multi-selection
  • press the "B" key once to activate the box selection method, it's the same than selecting files in explorer by clicking and draging a box over them.
  • press the "B" key twice to activate the circle-zone selector (my favorite). Every face under it will be added to selection when you click. Right-click to exit this mode, and use the mousewheel to change the circle size, middle click to unselect.
Rotate the view to check if you selected all the rim's faces. When done, press "P" key and confirm "Separate>Selected".
Now the rim part is separated from tire part.

Repeat the same procedure for the other wheels and don't hesitate to move the finished parts in another layer.

We must define a new material for the rims. Select one rim part and activate "Material panel". Click on the small material selector icon on the left of material's name then click "Add new". Rename this new material to "Rims", change the diffuse color to a light grey one, and clear the image texture currently used.



The material is now set up, you need to select each rim parts in the 3D view, and use the material selector icon to choose the "Rims" material you created.

Fix the tires

Select a tire. In the "Material" tab, choose a very dark grey color for the diffuse color, and "multiply" in the "Texture blending mode" in the "Map to" tab.



Now we have dark grey tires, with the tire black sculptures only added.

Fix the white parts

Easy, open the concerned texture in your image editor. In my example, it is "LX_interior1.tga", and repaint the little black square's interior with a very dark grey color, not black, to keep better shading results.



Return to Blender, select one of the white part, press "F6" to edit its texture definition, and press the "Reload" button to refresh the texture in Blender. The texture preview shows now the black painted small square.

Fix the glasses
Select a window in 3D view, activate the "Material button".
In the "Mirror transp" tab, press "Ray mirror" and "Ray transp". Adjust "rayMir" value to 0.2, "frsOfs" value to 1, "IOR" to 1.
In the "Material tab, select a more realistic diffuse color for car glass, and a whate mirror color. Set Alpha value to 0.1. Admire the result in the preview panel.



Assign this material to all glass parts if your car is equipped.

Save your work and press "F12" key to render again:



OK it starts to look like a car.
7. HIGH QUALITY RENDER
Huh? you want to make a better looking render now? ok, configure rendering engine like this:


Then select the area lamp, press "F5", and enter the "Samples" value to 3 in "Yafray: Shadow and Photons". If you have a multi-thread capable computer, set the number of thread you have in the "Render" tab.

Save your work, get you ready (and your computer) to a LONG render calculation. You are advised.

What are you waiting for to press the big yellow button?

-------------------------------------------------



:woohoo:

Press "F3" key to save your render image.
8. PRECISION TWEAKS, ADVANCED MATERIALS, SCENE ENVIRONMENT
It's the most interesting chapter of rendering, now we touch "the art". That's the problem, it's an art. I can't teach you directly with this tutorial how to create a great render, actually I can't. I'm currently working on materials, lightning and scene environment to create my killer renders. In fact I think render techniques should be more personal than preformatted. You are free to do what you want, creating pure white scene for your car, a beach scene, a race scene, sunset scene in the desert, on the moon... You can also choose the material you want, modify the rims, the headlights, tail lights, car shape... But I'm not against the idea to create a thread in this forum to share your tips and tricks, your materials and scenes, many of us just want to see his skins in a render.

Rendering with Blender Tutorial by Bogey Jammer
-
part #2 (Bogey Jammer) DELETED by Bogey Jammer
-
part #3 (Bogey Jammer) DELETED by Bogey Jammer
-
part #4 (Bogey Jammer) DELETED by Bogey Jammer
#2 - joen
Wow mate, it must have been a lot of work to create that tutorial
I don't use Blender myself, but I appreciate you taking the time to make this, should be very helpful to people. I may even try out Blender now just for fun
#3 - (SaM)
Sticky!
#4 - lippy
I think you have just achieved hero status.
w00t...

The ultimate tutorial.

I'll try it out tonight.
#6 - robps
Great stuff, bookmarked for future reference.
Quote from lippy :I think you have just achieved hero status.

you really did, thank you very much. this is great.
#8 - Davo
I haven't used blender but this looks like a very detailed and excellent tutorial! Good to see people making the effort to help others out
I'm happy that this tutorial satisfies people, I'm impatient to see the first renders from the readers.

I would like a moderator let me post more that 10 images in a post, to fit the tutorial in one piece, and easily modify it. I have doubts about alpha texture channel activation in this tutorial, I think I missed some steps.

I've also discovered there's bugs in the imported models, too many vertices that cause break lines in smooth surfaces. I'm trying to find an easy correction.
Select all, press 'W' key and then 'Remove Doubles'?

Also, there is quite a nice rendering engine call Indigo, which works very well with Blender. http://www.indigorenderer.com/
Look in the forums for test versions of the blender scripts.
Quote :
Also, there is quite a nice rendering engine call Indigo, which works very well with Blender. http://www.indigorenderer.com/

Here is my work in progress with Indigo.

I know I dont yet have tyres yet...
Attached images
im1171920575.png
This is mine currently, having a horrible time getting the glass to look right (so in this shot I tried increasing the number of polys on some of the glass and turned off smoothing).

Using Indigo 0.7 beta 5, probably shouldn't have used an environment map, but never mind
Attached images
im1171932429.png
I tried indigo once, and crashed it, so I must learn more about it. But we can get better result with it than Yafray.

About double vertices, it's better to keep it to simulate the smooth groups. Removing them disturb normals and lose all the hard edges. I'll correct the non-wanted edges only.
Since I've removed them already, do you happen to know how to get the hard edges back?
you can't, afaik, Blender is unable to support smooth groups like 3dsmax, or hard edges. Just re-import the car model in your work to replace the altered meshes.
Quote from robps :Since I've removed them already, do you happen to know how to get the hard edges back?

Try selecting the edges, press shift+e and move the mouse
Thanks, but adding a crease wasn't working. It would partly work if I add the crease (value +1.0) and then extruded the mesh - but only on the original faces, the extruded faces were still smoothed and the appeared to be un-creasable . Probably a newbie error though.

I did find another solution though. I extruded the glass meshes as before, checked the normals were pointing outwards, and then (with the glass object selected) went into the 'Modifiers' panel (F9 - editing) and added the 'EdgeSplit' modifier. Now they render with correct IOR. Just need to sort out the lighting now...

This is what it was looking like
http://www.robrps.ukshells.co.uk/im1172137139.png
and now it looks like
http://www.robrps.ukshells.co.uk/im1172147551.png
http://www.robrps.ukshells.co.uk/im1172148507.png
(only quick indigo renders)
Quote from TysCaargh :Try selecting the edges, press shift+e and move the mouse

It only works in subsurf mode

Quote from robps :Thanks, but adding a crease wasn't working. It would partly work if I add the crease (value +1.0) and then extruded the mesh - but only on the original faces, the extruded faces were still smoothed and the appeared to be un-creasable . Probably a newbie error though.

I did find another solution though. I extruded the glass meshes as before, checked the normals were pointing outwards, and then (with the glass object selected) went into the 'Modifiers' panel (F9 - editing) and added the 'EdgeSplit' modifier. Now they render with correct IOR. Just need to sort out the lighting now...

I'm not sure I understood.. IOR was wrong after removing double vertices in the glass? there's no relation with IOR setting in the glass material's properties?
IOR was being messed up with or without double vertexes being removed.

When I extruded the faces of the glass mesh, to give the glass some thickness, blender was set to smooth everything. When Indigo rendered the glass with all of its smoothing turned on it looks like it messes up (looks like http://www.robrps.ukshells.co.uk/im1172137139.png)

What I needed to do was to tell blender that the certain edges need to be sharp. Like you've mentioned, crease only works with SubSurf objects and not meshes. With meshes you can add the EdgeSplit modifier which from what I can tell acts a bit like the 'auto smooth' button, but the auto smooth does not get exported out to Indigo.

Does that make any sense? A lot of this is down to me not understanding how blender works.

This is my render 1hr in, with double vertexs remove on everything, and EgdeSplit used on everything
http://www.robrps.ukshells.co.uk/im1172160511.png
Quote from robps :with double vertexs remove on everything, and EgdeSplit used on everything

Is it really useful?
For the most part, no. But, it gives you control on what parts of the mesh are defined as edges and which part can be smoothed - also, its easier to fix specific areas where blender's 'set smooth' causes rendering issues, such as the area between the rear lights and rear wheel arch on the FXR.
It doesn't inport for me

My import .obj dialog box is different? I did my best guess as to what it should be but it came up with a script error.

Which version of Blender are you guys using?
Attached images
import_obj.jpg
console_error.jpg
oh

I'm using some the new features in other projects so I can't revert. Could someone send me a .blend file of the FOX? Is there a library of .blend files somewhere?
arrgh :doh:

my tutorial is already outdated

I must find a solution
This thread is closed

Rendering with Blender Tutorial
(194 posts, closed, started )
FGED GREDG RDFGDR GSFDG