Computer graphics Labs: Blender (1/3) Modelling, transparency and

Transcription

Computer graphics Labs: Blender (1/3) Modelling, transparency and
Computer graphics Labs: Blender (1/3)
Modelling, transparency and reflection
University of Liège – Department of Aerospace and Mechanical engineering
Designed with Blender 2.66
Introduction to the interface
Default interface
The default Blender window is partitioned in several sub-windows:
The 3D visualization window. See below for further details.
The information window containing the main software’s menus.
The “Timeline” window used for managing animations.
The “Outliner” window displaying in a tree fashion all the objects on the scene.
Expanding the tree allows to see how the objects are linked with each other, as well as
their properties (material, and so on).
The properties window further described here below.
3D visualization window
The 3D-window allows editing the scene interactively. It is possible to change the default
viewpoint of the scene by holding down the mouse central wheel. Combining the mouse
wheel with the [Shift] key allows moving the scene. Similarly, combining the mouse wheel
with the [Ctrl] key allows zooming. For mouse lacking the central wheel, the following table
shows how to bypass the wheel by combining mouse clicks and keyboard shortcuts.
LMB
MMB
Mouses with two buttons
LMB
Alt LMB
Apple mouse with one button
LMB (mouse’s button)
⌥Opt LMB
⌘ Cmd LMB
RMB
RMB
The keypad holds shortcuts for setting views: key [7] stands for the top view, [1] for the front
view, [3] for the profile view. Toggling between perspective view and the orthographic
projection is done via the keypad [5]. The keypad [0] enables/disables the camera view.
2
Finally, the “Quad View” mode partitions the visualization window in 4: three sub-windows
contain the three main views (front, profile and top) while the last sub-windows contains the
camera view. The “Quad View” mode is enabled by the [ctrl-alt-q] key combination.
The cursor of the 3D-window defines where in the scene new objects will be created.
This cursor can be moved by clicking left. By default, some elements are already presents in
the scene: a cube, a camera representing the rendering point of view, and a light illuminating
the scene.
Moreover, the 3D-window has:
An “Object Tools” panel on the left (keyboard shortcut [t]). This panel allows
applying several transformations (translations, rotations...) to the selected object.
A properties panel for editing the properties of the selected object (position...)
This panel can be accessed via the ‘+’ mark on the upper-right side of the window, or
via the keyboard shortcut [n].
A header bar (as all Blender’s windows) described here below.
Header of the 3D-window
By default, the header is located at the bottom of the 3D-window. Several functions are
available:
The mode selector allows defining how the scene will be edited. The two main useful
modes are the “Object Mode” and the “Edit Mode”. The “Object Mode” allows
modifying the scene globally (objects are seen as non-modifiable blocs). Whereas, the
“Edit Mode” aims to modify a particular object (we want to change the shape of the
object).
The handling buttons define the behaviour of the “grips” available on a selected object
in the 3D-window. We will mostly use the “Translate Manipulator”
and the
“Rotation Manipulator”
. The “Translate Manipulator” exhibits a reference frame
which allows moving the object in a given direction by clicking on the corresponding
frame axis. The “Rotation Manipulator” rotates the object around each axis.
3
The properties window
Thanks to the properties window it is possible to edit the properties of the selected object as
well as the global properties of the scene. The header holds a variable set of buttons from
which it is possible to access to different property panels.
For instance, by selecting the cube (right click) one can access to the “Material” button
and edit material properties (diffuse colour, transparency, reflection...) This button is disabled
when the camera is selected, while the “Texture” button
(which applies a texture to an
object) is enabled for both objects. Several global properties exist. Among them, there is the
“World” button
which defines the sky colour and the ambient light; and the “Render”
button
which setups the render options and launch a rendering.
Customizing the interface
The interface may be customized by changing the window layouts and sizes, or by adding
new windows.
Resizing a window is done by a left click on its edge.
A right click on a window edge brings up a context menu:
o « Split Area » splits a window into two parts.
o « Join Area » joints two adjacent windows.
Moreover, thanks to the leftmost button of the header it is possible to change the type of any
window. This button provides an access to the “Editor Type” menu, from which we can select
the window type to display in a given frame. Hence, it is possible to convert any window type
into any other.
4
Drawing an octopus with the subsurfs method.
(From http://biorust.com/tutorials/detail/1/fr/)
Drawing the body
1. Start by deleting the default cube located at the centre of the 3D-window.
o Select the cube with a right click: the contour become orange.
o Press the [Delete] key for erasing it and confirm in the shortcut menu by
clicking on “Delete” (or by pressing [Enter] without moving the mouse).
2. Inserting a circle.
o Make sure you have selected the top view by pressing the key [7] of the
keypad.
o Position the cursor on the origin thanks to a left click on it. The cursor’s
position defines where new objects will be created.
o In the upper toolbar, select Add→Mesh→Circle.
You can also use the control search engine integrated in Blender by pressing
[space] and then entering the wanted command name.
Here, the name “circle” brings back a list of similar commands. Choose “Add
circle” in order to construct a circle.
o A new tab named “Add circle” then pops up on the left panel of the 3Dwindow. This tab defines the circle’s properties (radius, position...) Assign the
vertices number to 8 and the radius to 1.5.
5
3. Extruding the circle.
o Check if the “Edit Mode” is indeed selected (not the “Object Mode”). If not,
press [Tab] for toggling from one mode to another.
o Select the front-view (key [1] of the keypad).
o Make sure that all the circle vertices are selected (key [a]).
o Press key [e] for initializing the extrusion*. Then press key [z] for locking the
vertical direction of the extrusion.
o Move the cursor upwards in order to position the new vertices as shown in
figure 1. Left click to confirm the locations of the new vertices.
o Perform again an extrusion by repeating the preceding steps in order to obtain
a similar shape as the one shown in figure 2.
o Keep the last vertices selected and press key [s] for setting the scale of the
section. Adjust the section size so to obtain the object sketched in figure 3.
* Warning: when extruding, the key [Esc] does not delete duplicated nodes. In
case of mistake, it is better to accept the wrong extrusion by a left click and
then to undo the last operation with the command [ctrl+z].
Remember to regularly save your work. Save it into a folder with your name (LASTNAMEFirstname). This folder should be located into the folder Infographie on the Desktop.
4. Creating the tentacles
o First, disable the “Limit selection to visible” option. This option allows
only the selection of visible nodes. The corresponding button is located in the
3D-window header. If the button is not displayed, press key [z] in order to
toggle from the wired viewing mode to the solid viewing mode.
o Toggle to the top-view (key [7] of the keypad).
o Unselect all the vertices by pressing [a].
o The key [b] defines a selection box. By keeping key [b] pressed and moving
the mouse with its left button pressed, select two neighbouring vertices of the
larger circle (figure 1 of the next page). As the option “Limit selection to
visible” is disabled (grayed), the vertices located below the visible ones will
also be selected.
o Extrude these vertices [e] as shown in figure 2. Press the central mouse wheel
to release the constraint of perpendicularity.
o Repeat this extrusion procedure twice in order to obtain a similar result to
figure 3.
6
o Proceed the same way for the other seven tentacles.
Do not forget to unselect the last vertices generated by an extrusion before
selecting new ones for creating a new tentacle.
5. Raising the body
o This step aims to raise the octopus body above the plane of reference, while
letting the tentacles dangling. This will be done thanks to the “Falloff” effect.
The falloff allows moving rigidly a part of an object while the other vertices of
the object will be altered accordingly to their distance of the moved part.
o Unselected all vertices [a] and select [b] the vertices of the body (vertices
located on and inside the larger circle).
o Toggle to the front view [1] and press key [o] for activating the falloff mode.
7
o A new icon shows up into the 3D-window header. By clicking on it, a dropdown menu allows selecting the falloff magnitude. Select “Sharp Falloff”.
o Check if the mode “translate Manipulator” is enabled
and click on the
vertical blue arrow in order to move the selection upwards while pressing the
left mouse button. A circle shows up: it is the influence area of the falloff.
While keeping the left button pressed, adjust the circle size with the central
wheel so that it encompasses the whole object. Finally, move the selection
upwards.
o Deactivate the falloff mode [o].
8
6. Drawing the head.
o In the profile view [1], select [b] the upper vertices of the body. Afterwards,
make several successive vertical extrusions [e][z] and scaling [s] in order to
obtain the head profile.
o By using again the upper vertices, perform a last extrusion [e] and scale so that
these vertices become coincident.
o On the left panel of the 3D-window, click on the “Remove Doubles” button
under the title “Remove”. This tool will merge the height duplicated vertices at
the top of the head.
o A new tab shows up in the lower part of the left panel. Set to 0.1 the value of
the field “Merge Threshold” and press Enter. The duplicated nodes will be
automatically deleted. You can check the number of selected points in the
upper information window.
7. Creating the “Subdivision Surface”.
o In the properties window located on the right-hand side of the screen, activate
the “Modifiers”.
o Click on “Add Modifier” and select « Subdivision Surface » at the bottom of
the column “Generate”.
o A rounded shape shows up inside the mesh we have just created. It is possible
to adjust the Subdivision Surface with the fields:
 “View”: number of pre-visualized subdivisions (as seen in the
3D-window).
 “Render”: number of subdivisions used for the rendering.
More the number of subdivisions increases, better will be the image quality but
longer will be the computation time. In our case, an acceptable result will be
obtained with “View” set at 2 and “Render” set at 3.
9
8. Finalizing the all thing.
o Quit the Edition mode by pressing the key [Tab].
o If the wiring mode is activated, toggle to the solid mode either by pressing [z]
or by selecting the option “Solid” inside the menu “Viewport Shading” of the
visualizing window header.
o The achieved result is not quite realistic, as the octopus surface is uniformly
facetted and coloured by Blender. In order to improve the rendering, it is
possible to ask Blender to apply a gradient on each facet following the
computed colour at the nodes. To do this, click on the button “Smooth” under
“Shading” in the left panel of the 3D-window (Object Tools).
9. Remedy to frequent problems.
o If some connections between the body and the tentacles seem irregular, there
was probably some duplicated point during the extrusion.
Remedy:
 Toggle back to the Edition Mode [Tab].
 Select all the nodes located on the base of the tentacles [b] and press
again the button “Rem Double”. Validate the number of deleted nodes.
o If some tentacles stay open
 Toggle back to the Edition Mode [Tab].
 Select the 4 nodes at the tentacle tip.
 Press key [f] for creating a facet linking the nodes together.
10
o If dark or bright vertical lines show up, there is a problem of normals.
To solve this problem, the normals have to be recomputed:
 Toggle to the “Edit Mode” with the key [Tab].
 Select all the mesh [a].
 In the left panel “Shading/UVs”, click on the button “Recalculate”
under the title “Normals”.
 Toggle back to “Object Mode” [Tab].
10. Assigning a material.
o To assign a material property to an object, click on the button “Material” of the
properties window (right panel).
o Click on the button “New” that shows up below for creating a new material. A
set of tabs is then displayed for defining the properties of the new material.
o For our material, we will only define a diffuse colour and let the other
parameters at their default values.
o In the tab “Diffuse”, click on the white frame (default material colour). A
dialog box will open for defining the colour. Setup the values of the R, G, B
channels as written in the below right-hand side figure.
11
Drawing the eyes
1. The eye will be created as an object independent from the body. If not already done,
quit the “Edit Mode” [Tab] and toggle to the “Object Mode”. Otherwise, the eyes will
be added to the object constituting the body.
2. Creating the starting sphere.
o Toggle to the front view [1].
o Move the cursor in an empty area of the 3D-window (left click).
o Add a sphere: menu Add→Mesh→UVsphere.
o In the lower part of the left panel of the 3D-window, set the number of
“Segments” and “Rings” both to 20. Check the box “Align to View”.
o In order to use the smoothing, click on the button “Smooth” of the left panel of
the 3D-window.
3. Adding materials.
o We will add two materials to this sphere. Click on the button “Materials”
of the properties window.
o The sphere that we have just created holds no material. The list of materials is
therefore empty. Add two “Slots” to this list thanks to the button “Add
Material Slot” located nearby the
list.
o Then, select the first created “Slot”
and click on the button “New”
located under the list. This will
assign a new material to this “Slot”.
o Define a white diffuse colour for this first material. It will be used for the white
part of the eyes.
o Repeat the last two steps for the second “Slot”. However, use a black diffuse
colour for this material, which will be used as pupil.
4. Assigning the materials.
We will now assign the two materials to two different regions of the sphere in
order to create a pupil.
o Toggle to the “Edit Mode” [Tab], three new buttons shows up under the list of
materials in the properties window: “Assign”,
“Select” and “Deselect”.
o Select all the vertices of the sphere (if necessary,
use the key [a]) and select in the list the white
material. Click on the “Assign” button.
o For defining the pupil, unselect [a] all the vertices.
Now, select all the vertices located at the middle of
the sphere.
12
Use the circular selection tool [c] (if needed, adjust the size of the selection
circle with the mouse wheel) and press [Enter] to confirm the selection.
o In the list of the properties window, select the black material and click
“Assign”.
5. Shaping the sphere.
o Use the profile view [3], reselect all the vertices [a][a], and apply a shear [ctrlalt-shift-s] in order to flatten the eye. Repeat the process several times if
needed. End with a rotation [r] in order to align the eye with the vertical plane.
Shear
Rotation
o Inside the front view, carry out a scaling following z axis [s][z] to round the
pupil.
6. Positioning and creating a copy.
o Quit the edit mode [Tab] and position the eye on the octopus by using [g] for
moving it and [r] for rotating it. Do not hesitate to change the view or to use
the “Quad View” [ctrl-alt-q]. A scaling should probably be required [s].
o Once the eye positioned, copy it [shift-d] and position the copy.
13
Finalizing the octopus
1. Adjusting the camera’s location.
o The camera’s location should be adjusted to the scene we have just created.
For more ease, activate the “Quad View” mode [ctrl-alt-q].
o In the top right view, the camera field of view is given by the orange frame.
Use the three other visualization windows for adjusting the camera’s position
in order to encompass the octopus in the field of view.
o Once the camera positioned, press key [F12] for computing a rendering of the
scene. The computed image replaces the 3D-window. To go back to the
3D-window, press [Esc].
14
2. Changing the illumination.
o As is, the scene is probably not properly illuminated. Firstly, we will change
the light source type.
o Select the light and click on the button “Object Data” in the header of the
properties window.
o Change the source type from “Point” to “Sun” (inside the object “lamp”) in
order to obtain a more suited illumination for the remainder of this tutorial.
Indeed, the source type “Sun” illuminates the scene uniformly with parallel
rays, while the source type “Point” has a limited illumination range and its rays
are not parallel.
o After the modification of the source type, the symbol figuring the light source
is changed. A discontinuous line originating from the light source indicates the
rays’ direction. Change this direction in order to properly illuminate the object.
If needed, change the value of the field “Energy” inside the tab “Lamp” if the
scene is too dark.
Creating the ground
1. Adding a plane.
o Set the cursor below the octopus and then select the top view [7]. Next, add a
plane: Add→Mesh→Plane.
o Scale the plane [s] so it covers the whole camera field.
2. Applying a texture.
o For obtaining a more realistic ground, we will use a texture. Firstly, create a
material. In the properties window, click on the button “Material”
and then
on the button “New”.
o For creating a texture, click on the button “Texture”
located on the righthand site of the button “Material”, in the header of the properties window.
o Click on “New” and select “Stucci” inside the menu “Type” which appears
immediately below.
o Next, go to the tab “Colors” and check the box “Ramp” for applying a gradient
to the texture.
o A gradient is defined by a sequence of colours that Blender will interpolate. It
is possible to change each colour of the sequence individually by selecting it
thanks to its index. The default gradient holds two colours of index 0 and index
1 respectively. For changing a colour, click on its preview.
15
o Define the colour of index 0 to R=1, G=0.85, B=0.5 and A=1.
o Define the colour of index 1 to R=0.65, G=0.6, B=0.35 and A=1.
o Go to the tab “Mapping”, located
lower in the properties window.
This tab defines how the texture
should be applied to the plane. To
ensure the texture seems small
enough, an increase of the scale of
the texture space is necessary.
Change the values of X, Y, and Z
under the title “Size” to 8.
o The ground is now finished, you can compute a rendering [F12] for obtaining
the final result.
16
Creating the water surface
1. Adding the water surface.
o We consider that the camera lies above the water surface and that the octopus
lies below it. The light rays coming from the octopus will pass through two
different materials (the water and air) before reaching the camera. As a
consequence, the ray trajectory will not be straight anymore (refraction effect).
Thus, the perceived image by the camera
will be modified.
o As Blender can process only surfaces, the
refraction effect will be modelised at the
water surface. Set the cursor above the
octopus but below the camera (raise the
camera upwards if necessary) in order to
define where the water surface will be
created. Next, using the top view [7], add a
plane (Add→Mesh→Plane).
o Scale the plane so it is as big as the ground
[s]. Then, use translations and rotations so
that the plane covers half of the camera field (use the “Quad View” mode for
this). Covering the half of the camera field will help us to assess the effects of
refraction.
2. Applying material properties to the water surface.
o Quit the “Edit Mode” [Tab] if it is enabled.
o Click on the button “Material”
in the header of the properties window.
Add a new material to the plane by clicking on “New”.
o Define a diffuse colour for the water, as described in the figure below.
17
o The tab “Transparency” enables the calculation of transparency and defines the
refractive properties of the material.
Transparency is enabled by checking
the box located on the left of the title
“Transparency”.
Enable
the
transparency calculation by raytracing computation by clicking on
the button “Raytrace”. Next, define
the transparency level by setting the
parameter “Alpha” to 0.2 and the
refraction value index “IOR” to 1.33
(which is the “IOR” of the water).
o If you try to render the scene now,
you will notice that the shadowed
parts of the image are totally black.
Actually, the materials used for the
octopus need to be configured so they
can handle “transparent” shadows.
To configure the materials, select
each object and, in the “Material” properties, check the box “Receive
transparent” in the tag “Shadow” (located below the material properties). This
process needs to be repeated for the two materials applied on the eyes. Note
that this configuration change is only needed for one eye, as the two eyes share
the same material properties.
o The scene rendering can now be computed in order to check the effects of the
added surface.
18
3. Adding a wave effect to the surface
o From a realistic point of view, a water surface is seldom perfectly flat and
smooth. Therefore, the image we have just obtained seems unnatural.
Fortunately, Blender offers a quite easy way for introducing image
deformations caused by waves on the water surface.
o Select the plane that models the water surface and, as for the ground, add a
texture to it. In the header of the properties window, click on the button
“Texture”
and then “New”. Select again a new type of texture “Stuccy”.
o In the tag “Mapping” of the “Texture” properties, use the value 10 for the X, Y
and Z parameters under the title “Size”, in order to get waves close enough to
each other.
o Go to the tag “Influence” of
“Texture” properties. This step is
the most important for obtaining a
convincing wave effect. This tag
defines the influence that the texture
will have on the object. Unselect the
option “Color” (the texture will not
affect the object’s colour). Check
the box “Normal” so that the texture
will affect the normal. The normal
vector to the surface is used by the ray-tracer for computing the refraction.
Change the field value of the “Normal” to 0.01. This value defines how much
the normal is changed by the texture (i.e. it defines the wave amplitude).
o Compute the rendering.
19
o If needed, adjust the field values of parameters X, Y and Z of the tag
“Mapping” as well as the field value of the parameter “Normal”. Indeed, these
values depend on the size of the water surface.
4. Reflection on the water surface.
o As it is, the water seems to be too transparent. As a matter of fact, the water
surface reflects an image of its surrounding environment.
o Reflection can be defined into the tag “Mirror”, in the section “Material”
of the properties window.
 Begin by enabling the effect by checking the upper box of the tag.
 Next, as shown in the figure below, define the values of “Reflectivity”
(intensity of the reflection) and “Fresnel” which influences how the
reflection evolves with the incidence angle.
5. Changing the sky
o The default sky of Blender is gray and uniform. We will replace it by using a
texture which will generate a partially cloudy sky.
o Click on the button “Texture”
in the header of the properties window.
Next, click on the button “Show World Texture” at the top of the “Texture”
section.
20
o Then, click on the button “New” for adding a texture. Select “Cloud” as type
and adjust the gradient colours in the tag “Colors” as following (enable the
option “Ramp”).
 Define the colour of index 0 to R=0.3, G=0.6, B=0.9 and A=1.
 Define the colour of index 1 to R=1.0, G=1.0, B=1.0 and A=1.
o Finally, in the tag “Influence”, check the box “Horizon” in order to apply the
texture to the sky.
o The last remaining step consists in adjusting the camera position and the sizes
of the ground plane and water surface plane in order to obtain the final scene.
21