data visualization and rendering with blender

data visualization and rendering with blender
DATA
VISUALIZATION
AND
RENDERING
WITH
BLENDER
AND
VTK
Matt
Cragun
Total
Sim
USA
mcragun@totalsim.us
3
Using
Blender
7
Importing
Data
from
Paraview
18
Using
Blender
Directly
with
VTK
and
Python
34
OUTLINE
Introduction
INTRODUCTION
What:
Use
Blender
and
VTK
to
produce
more
realistic
renderings
of
data
generated
in
OpenFOAM
Why:
• 
• 
• 
High
quality
visualizations
are
exciting
to
look
at
and
can
attract
the
interest
of
non‐science
types.
Good
for
marketing
images
or
other
applications
where
form
might
outweigh
function
Not
a
suitable
alternative
to
a
standard
post‐processing
program
such
as
Paraview
or
Ensight
Ojectives
of
this
tutorial:
•  Learn
Blender
UI
•  Export
data
from
Paraview
and
import
in
Blender
•  Understand
basics
of
material
properties
in
Blender
•  Learn
how
to
create
cameras
•  Learn
how
to
setup
lights
•  Perform
basic
rendering
in
Blender
•  Demonstrate
direct
VTK/Blender
integration
INTRODUCTION
Introduction
Blender:
• 
• 
• 
• 
• 
• 
• 
• 
Open
source
3D
rendering
software
www.blender.org
www.blenderartists.org
Large
community
and
actively
developed
Reasonably
stable
Highly
scriptable
Current
release
is
2.5x
•  Based
on
Python
3.x
•  Very
nice
interface
•  Faster,
higher
quality
rendering
Blender
2.49b
is
used
during
this
tutorial
•  Based
on
Python
2.x
•  Slower
rendering
•  Not
as
user
friendly
VTK:
• 
• 
• 
• 
• 
Visualization
Toolkit
Powerful
open
sourceC++
Libraries
useful
for
manipulating
data
by
Kitware
Paraview
is
based
on
VTK
VTK
contains
Python
2.x
wrappers
Currently
no
Python
3.x
support
*Basic
knowledge
of
OpenFOAM,
Python,
and
Paraview
are
assumed
for
this
tutorial
INTRODUCTION
Software
Overview
Method
2
Simple:
Complex:
A.  Generate
OpenFOAM
data
B.  Use
VTK
python
wrapping
to
read
data
into
Blender
with
blenderVTK.py
module
C.  Render
in
Blender
A.  Generate
OpenFOAM
data
B.  Visualize
in
Paraview
C.  Render
in
Blender
Pros:
Pros:
• 
• 
• 
• 
• 
Requires
fewer
Blender
skills
Most
users
are
already
familiar
with
Paraview
No
scripting
needed
Models
can
be
moved
to
Blender
2.5x
• 
Everything
done
from
inside
of
Blender
Capable
of
rendering
animations/time‐
dependent
data
Cons:
Cons:
• 
• 
Cannot
render
animations
(or
it
would
be
very
painful
to
do
so)
Requires
the
intermediate
step
of
using
Paraview
• 
Scripting
required
with
both
Blender
and
VTK
modules
INTRODUCTION
Method
1
INTRODUCTION
TO
BLENDER
• From
a
terminal
type
“blender”
• Mouse
buttons
are
different
from
most
programs:
Button
Function
LMB
Move
3d
Cursor
RMB
Select
MMB
Rotate
Model
Shift
+
MMB
Pan
Ctrl
+
MMB
/
Scroll
Zoom
• Other
Important
Shortcuts
Button
Function
LMB
Move
3d
Cursor
RMB
Select
MMB
Rotate
Model
Shift
+
MMB
Pan
Ctrl
+
MMB
/
Scroll
Zoom
Esc
Stop
Current
Action
Ctrl
+
Z
UNDO!
F12
Render
Image
Tab
Switch
between
object
and
edit
mode
Shift
+
D
Duplicate
GETTING
STARTED
Staring
Blender
and
Understanding
the
UI
Axis
Triad
3d
Cursor
Light
Default
Cube
Switch
Between
Object/Edit
Mode
Switch
Views
Window
Mode
Option
Buttons
Camera
GETTING
STARTED
Staring
Blender
and
Understanding
the
UI
1. 
2. 
3. 
4. 
5. 
RMB
between
frames
Click
“Split
Area”
Create
Second
Area
RMB
Camera
in
3D
view
In
small
Frame
LMB
View>>Cameras>>Set
Active
Object
As
Active
Camera
We
can
now
see
the
3d
View,
plus
the
view
the
camera
will
see
GETTING
STARTED
Staring
Blender
and
Understanding
the
UI
Press
F12
to
Render
GETTING
STARTED
First
Render
Button
Function
G
Grab
S
Scale
R
Rotate
(G,S,R)
>>
(X,
Y,
Z)
Grab,
Scale,
or
Rotate
along
X,Y,
or
Z
axis
Create
Simple
3
Point
Lighting:
1.  RMB
the
light
source
2.  Shift
+
D
to
duplicate
3.  Drag
new
light
to
behind
the
box
and
then
LMB
when
in
place
4.  Shift
+
D
to
duplicate
again
5.  Drag
new
light
to
the
side
of
the
camera
and
LMB
to
place
6.  These
are
the
iill,
backlight
and
key
lights
GETTING
STARTED
Rotating/Translating/Scaling
Geometry
1
2
3
Press
F12
to
Render
It’s
starting
to
look
a
little
better
GETTING
STARTED
Second
Render
GETTING
STARTED
Adjust
Light
Properties
Adjust
the
Key
Light:
The
key
light
should
be
about
2X
as
bright
as
the
iill:
1.  RMB
the
key
light
2.  Select
the
Shading
tab
(F5)
3.  Double
click
the
Energy
Box
and
Adjust
to
2.00
4. 
5. 
RMB
the
back
light
Change
Energy
to
0.5
2
1
3
Press
F12
to
Render
The
lights
are
getting
more
realistic
GETTING
STARTED
Third
Render
GETTING
STARTED
Add
a
ground
plane
(mesh
object)
Now
add
a
ground
plane:
1.  ‘Spacebar’
>>
Add>>Mesh>>Plane
2.  Plane
will
be
added
at
the
3d
Cursor
3.  ‘S’
,
‘10’
to
scale
10
units
4.  ‘G’,
‘Z’,
‘‐1’
to
move
it
down
1
unit
in
the
Z
direction
1
3
Press
F12
to
Render
The
lights
are
getting
more
realistic
GETTING
STARTED
Fourth
Render
VISUALIZE
IN
PARAVIEW/RENDER
IN
BLENDER
1.  Open
Paraview
(Earlier
than
3.10)
–
Not
sure
why
the
export
tool
does
not
work
in
3.10
2.  Open
exampleFluid.vtk
3.  Open
monkey.stl
PARAVIEW
AND
BLENDER
Read
VTK
data
into
Paraview
1.  Select
the
iluid
iile
and
create
a
stream
tracer
iilter
2.  On
the
Stream
Tracer
Filter:
I.  Set
the
Vectors
to
U
II.  Set
the
seed
location
to
(‐2,0,0)
III.  Change
the
number
of
seed
points
to
30
3. 
Select
the
Stream
Tracer
and
add
a
Tube
iilter
I.  Change
the
radius
of
the
tubes
to
0.05
4. 
Color
the
Tubes
by
U
PARAVIEW
AND
BLENDER
Generate
Data
in
Paraview
1.  Hide
the
Fluid
Box
2.  File>>Export>>vrml
The
vrml
exporter
is
WYSWYG—therefore
make
sure
everything
you
want
exported
is
shown/colored
the
way
you
like
PARAVIEW
AND
BLENDER
Export
Paraview
Data
1.  Switch
the
box
on
the
right
to
the
outliner
mode
2.  Then
select
the
box
3.  Deleted
the
box
by
pressing
‘X’
and
clicking
the
‘Erase
selected
Object(s)’
PARAVIEW
AND
BLENDER
Prep
Blender
for
Paraview
Data
1.  Import
the
vrml
iile:
I.  File>>Import>>X3D
and
VRML97
II.  Select
the
iile
III.  Select
Load
IV.  Select
‘OK’
to
import
the
hierarchy
2. 
The
data
from
Paraview
loads
into
blender
with
some
other
data
such
as
lights
and
viewpoints
PARAVIEW
AND
BLENDER
Import
Paraview
Data
into
Blender
1.  Shift+Click
each
of
the
“Direct
Light”
(not
the
“lamp”)
objects
and
the
“viewpoint”
object
in
the
outliner
panel
2.  ‘X’
to
Delete
all
of
these
objects
PARAVIEW
AND
BLENDER
Clear
out
Excess
Paraview
Data
1.  Rendering
the
plane,
monkey,
and
streamlines
PARAVIEW
AND
BLENDER
Sixth
Render
PARAVIEW
AND
BLENDER
Turn
on
Data
Color
Map
1.  Select
the
streamlines
(RMB)
2.  Click
the
button
for
the
material
context
3.  Turn
on
‘Vcol
Paint’
1
2
3
1.  Rendering
the
plane,
monkey,
and
Colored
streamlines
PARAVIEW
AND
BLENDER
Seventh
Render
Adding
New
materials:
•  It’s
usually
most
efiicient
to
use
materials
already
created
and
import
them
instead
of
creating
from
scratch
1.  Download
a
.blend
iile
with
materials
of
interest
2.  Append
the
new
.blend
iile
to
the
current
iile
3.  File>>Append
or
Link>>Colored
Glass.blend>>scene>>scene
4.  Click
Load
The
new
materials
should
now
be
part
of
the
library
PARAVIEW
AND
BLENDER
Render
Button
1.  Select
the
monkey
(RMB)
2.  Go
to
the
materials
settings
3.  In
the
MA:Link
to
Object
iield,
change
to
CG001
1
2
3
PARAVIEW
AND
BLENDER
Render
Button
1.  Rendering
the
plane,
monkey
with
glass
properties,
and
Colored
streamlines
GETTING
STARTED
Render
Button
1.  Rotate
the
monkey
and
the
streamlines
90
degrees
to
better
face
the
camera
2.  ‘R’
–
to
rotate,
‘X’
–
for
the
X
axis,
‘90’
–
for
90
degrees
5.  Remove
the
shadows
from
the
Fill
and
BackLights
by:
•  Select
the
backlight
•  Select
the
material
tab
•  Uncheck
the
Ray
Shadow
tab
GETTING
STARTED
Rotate
the
Geometry
and
Clean
up
the
Shadows
Adjust
the
camera
to
zoom
in
on
the
subject
1.  Select
the
camera
(RMB)
2.  Click
use
3d
manipulator
and
3d
translator
3.  Grab
and
slide
the
arrows
to
move
the
camera
PARAVIEW
AND
BLENDER
Change
the
Camera
Position
1
3
2
1.  Rendering
the
plane,
monkey
with
glass
properties,
and
Colored
streamlines
PARAVIEW
AND
BLENDER
Eighth
Render
INTEGRATING
VTK
AND
BLENDER
USING
BLENDERVTK.PY
Blender
has
a
python
interpreter.
Using
the
VTK
python
wrappers
and
a
module
called
VTK
blender
by
University
of
Alberta
CS
department.
This
module
can
iterate
through
animations
or
time
dependent
data.
VTKBLENDER
INTEGRATION
Blender
Python
interpreter
1
3
2
Steps
to
running
the
UAICT
Demo:
1.  Copy
VTKBlend.py
to
/usr/lib/python26/
(You
will
need
to
sudo
for
this
command)
2.  Open
the
VTKBlender_demo2.py
3.  Go
to
the
rendering
tab
4.  Click
ANIM
VTKBLENDER
INTEGRATION
VTKPython
Demo
1
This
demo
works
by
using
VTK
to
generate
the
data
and
then
replace
a
mesh
iile
with
the
new
mesh
data
at
each
time
step
3
2
Conclusions:
• Blender
is
a
great
tool
for
high‐quality
rendering
• There
is
a
bit
of
a
learning
curve,
but
it
is
manageable
• Blender
2.5X
is
much
nicer
and
faster,
however,
it
is
built
on
python3.0
(VTK
is
2.x
only)
and
it
currently
does
not
import
vrml
iiles
directly
• Blender
2.49
iiles
can
be
opened
in
2.5x,
so
if
2.5x
is
preferred,
the
iile
can
be
imported
in
2.49
and
then
used
in
2.5x
• Blender
is
not
a
suitable
alternative
to
Paraview
or
other
true
data
visualization
package
• Rendering
is
an
art
and
is
a
fairly
in
depth
subject
CONCLUSIONS
Summary
Article
on
Setting
up
3
Point
Lighting:
http://www.3drender.com/light/3point.html
Blender
Materials:
http://www.freewebs.com/blendermats/
University
of
Alberta
CS
department:
http://www.ualberta.ca/CNS/RESEARCH/Vis/VTKBlender/index.html
RESOURCES
References
and
Useful
Links

Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising