38
DATA VISUALIZATION AND RENDERING WITH BLENDER AND VTK Matt Cragun Total Sim USA [email protected]

DATA VISUALIZATION AND RENDERING WITH BLENDER · PDF fileDATA VISUALIZATION AND RENDERING WITH BLENDER AND VTK Matt Cragun Total Sim USA [email protected]

Embed Size (px)

Citation preview

DATAVISUALIZATIONANDRENDERINGWITHBLENDERANDVTK

[email protected]

OUTLIN

EIntroduction

UsingBlender

ImportingDatafromParaview

UsingBlenderDirectlywithVTKandPython

3

7

18

34

INTRODUCTION

INTRO

DUCTIO

NIntroduction

What:UseBlenderandVTKtoproducemorerealisticrenderingsofdatageneratedinOpenFOAM

Why:•  Highqualityvisualizationsareexcitingtolookatandcanattracttheinterestofnon‐science

types.•  Goodformarketingimagesorotherapplicationswhereformmightoutweighfunction•  Notasuitablealternativetoastandardpost‐processingprogramsuchasParavieworEnsight

Ojectivesofthistutorial:•  LearnBlenderUI•  ExportdatafromParaviewandimportinBlender•  UnderstandbasicsofmaterialpropertiesinBlender•  Learnhowtocreatecameras•  Learnhowtosetuplights•  PerformbasicrenderinginBlender•  DemonstratedirectVTK/Blenderintegration

INTRO

DUCTIO

NSoftwareOverview

Blender:•  Opensource3Drenderingsoftware•  www.blender.org•  www.blenderartists.org•  Largecommunityandactivelydeveloped•  Reasonablystable•  Highlyscriptable•  Currentreleaseis2.5x

•  BasedonPython3.x•  Veryniceinterface•  Faster,higherqualityrendering

•  Blender2.49bisusedduringthistutorial•  BasedonPython2.x•  Slowerrendering•  Notasuserfriendly

VTK:•  VisualizationToolkit•  PowerfulopensourceC++LibrariesusefulformanipulatingdatabyKitware•  ParaviewisbasedonVTK•  VTKcontainsPython2.xwrappers•  CurrentlynoPython3.xsupport

*BasicknowledgeofOpenFOAM,Python,andParaviewareassumedforthistutorial

INTRO

DUCTIO

NMethod1

Simple:A.  GenerateOpenFOAMdataB.  VisualizeinParaviewC.  RenderinBlender

Pros:•  RequiresfewerBlenderskills•  Mostusersarealreadyfamiliar

withParaview•  Noscriptingneeded•  ModelscanbemovedtoBlender

2.5x

Cons:•  Cannotrenderanimations(orit

wouldbeverypainfultodoso)•  Requirestheintermediatestepof

usingParaview

Method2

Complex:A.  GenerateOpenFOAMdataB.  UseVTKpythonwrappingtoreaddata

intoBlenderwithblenderVTK.pymodule

C.  RenderinBlender

Pros:•  Everythingdonefrominsideof

Blender•  Capableofrenderinganimations/time‐

dependentdata

Cons:•  ScriptingrequiredwithbothBlender

andVTKmodules

INTRODUCTIONTOBLENDER

GETTIN

GSTARTED

StaringBlenderandUnderstandingtheUI

• Fromaterminaltype“blender”• Mousebuttonsaredifferentfrommostprograms:

• OtherImportantShortcuts

Button Function

LMB Move3dCursor

RMB Select

MMB RotateModel

Shift+MMB Pan

Ctrl+MMB/Scroll Zoom

Button Function

LMB Move3dCursor

RMB Select

MMB RotateModel

Shift+MMB Pan

Ctrl+MMB/Scroll Zoom

Esc StopCurrentAction

Ctrl+Z UNDO!

F12 RenderImage

Tab Switchbetweenobjectandeditmode

Shift+D Duplicate

GETTIN

GSTARTED

StaringBlenderandUnderstandingtheUI

OptionButtons

WindowMode

SwitchViews

SwitchBetweenObject/EditMode

DefaultCube

AxisTriad

Light

3dCursor

Camera

GETTIN

GSTARTED

StaringBlenderandUnderstandingtheUI

1.  RMBbetweenframes2.  Click“SplitArea”3.  CreateSecondArea4.  RMBCamerain3Dview5.  InsmallFrameLMB

View>>Cameras>>SetActiveObjectAsActiveCamera

Wecannowseethe3dView,plustheviewthecamerawillsee

GETTIN

GSTARTED

FirstRender

PressF12toRender

GETTIN

GSTARTED

Rotating/Translating/ScalingGeometry

Button Function

G Grab

S Scale

R Rotate

(G,S,R)>>(X,Y,Z) Grab,Scale,orRotatealongX,Y,orZaxis

CreateSimple3PointLighting:1.  RMBthelightsource2.  Shift+Dtoduplicate3.  Dragnewlighttobehindtheboxand

thenLMBwheninplace4.  Shift+Dtoduplicateagain5.  Dragnewlighttothesideofthecamera

andLMBtoplace6.  Thesearetheiill,backlightandkeylights

12

3

GETTIN

GSTARTED

SecondRender

PressF12toRenderIt’sstartingtolookalittlebetter

GETTIN

GSTARTED

AdjustLightProperties

AdjusttheKeyLight:

Thekeylightshouldbeabout2Xasbrightastheiill:1.  RMBthekeylight2.  SelecttheShadingtab(F5)3.  DoubleclicktheEnergyBoxandAdjustto2.004.  RMBthebacklight5.  ChangeEnergyto0.5 2

31

GETTIN

GSTARTED

ThirdRender

PressF12toRenderThelightsaregettingmorerealistic

GETTIN

GSTARTED

Addagroundplane(meshobject)

Nowaddagroundplane:1.  ‘Spacebar’>>Add>>Mesh>>Plane2.  Planewillbeaddedatthe3dCursor3.  ‘S’,‘10’toscale10units4.  ‘G’,‘Z’,‘‐1’tomoveitdown1unitintheZ

direction

31

GETTIN

GSTARTED

FourthRender

PressF12toRenderThelightsaregettingmorerealistic

VISUALIZEINPARAVIEW/RENDERINBLENDER

PARA

VIEWANDBLEN

DER

ReadVTKdataintoParaview

1.  OpenParaview(Earlierthan3.10)–Notsurewhytheexporttooldoesnotworkin3.10

2.  OpenexampleFluid.vtk3.  Openmonkey.stl

PARA

VIEWANDBLEN

DER

GenerateDatainParaview

1.  Selecttheiluidiileandcreateastreamtraceriilter

2.  OntheStreamTracerFilter:I.  SettheVectorstoUII.  Settheseedlocationto(‐2,0,0)III.  Changethenumberofseed

pointsto303. SelecttheStreamTracerandaddaTubeiilter

I.  Changetheradiusofthetubesto0.05

4. ColortheTubesbyU

PARA

VIEWANDBLEN

DER

ExportParaviewData

1.  HidetheFluidBox2.  File>>Export>>vrmlThevrmlexporterisWYSWYG—thereforemakesureeverythingyouwantexportedisshown/coloredthewayyoulike

PARA

VIEWANDBLEN

DER

PrepBlenderforParaviewData

1.  Switchtheboxontherighttotheoutlinermode

2.  Thenselectthebox3.  Deletedtheboxbypressing‘X’andclicking

the‘EraseselectedObject(s)’

PARA

VIEWANDBLEN

DER

ImportParaviewDataintoBlender

1.  Importthevrmliile:I.  File>>Import>>X3Dand

VRML97II.  SelecttheiileIII.  SelectLoadIV.  Select‘OK’toimportthe

hierarchy2. ThedatafromParaviewloadsintoblenderwithsomeotherdatasuchaslightsandviewpoints

PARA

VIEWANDBLEN

DER

ClearoutExcessParaviewData

1.  Shift+Clickeachofthe“DirectLight”(notthe“lamp”)objectsandthe“viewpoint”objectintheoutlinerpanel

2.  ‘X’toDeletealloftheseobjects

PARA

VIEWANDBLEN

DER

SixthRender

1.  Renderingtheplane,monkey,andstreamlines

PARA

VIEWANDBLEN

DER

TurnonDataColorMap

1.  Selectthestreamlines(RMB)2.  Clickthebuttonforthematerial

context3.  Turnon‘VcolPaint’

1

2

3

PARA

VIEWANDBLEN

DER

SeventhRender

1.  Renderingtheplane,monkey,andColoredstreamlines

PARA

VIEWANDBLEN

DER

RenderButton

AddingNewmaterials:•  It’susuallymostefiicienttousematerials

alreadycreatedandimporttheminsteadofcreatingfromscratch

1.  Downloada.blendiilewithmaterialsofinterest

2.  Appendthenew.blendiiletothecurrentiile3.  File>>AppendorLink>>Colored

Glass.blend>>scene>>scene4.  ClickLoad

Thenewmaterialsshouldnowbepartofthelibrary

PARA

VIEWANDBLEN

DER

RenderButton

1.  Selectthemonkey(RMB)2.  Gotothematerialssettings3.  IntheMA:LinktoObjectiield,changeto

CG001

1

23

GETTIN

GSTARTED

RenderButton

1.  Renderingtheplane,monkeywithglassproperties,andColoredstreamlines

GETTIN

GSTARTED

RotatetheGeometryandCleanuptheShadows

1.  Rotatethemonkeyandthestreamlines90degreestobetterfacethecamera

2.  ‘R’–torotate,‘X’–fortheXaxis,‘90’–for90degrees

5.  RemovetheshadowsfromtheFillandBackLightsby:

•  Selectthebacklight•  Selectthematerialtab•  UnchecktheRayShadowtab

PARA

VIEWANDBLEN

DER

ChangetheCameraPosition

Adjustthecameratozoominonthesubject1.  Selectthecamera(RMB)2.  Clickuse3dmanipulatorand3dtranslator3.  Grabandslidethearrowstomovethe

camera1

23

PARA

VIEWANDBLEN

DER

EighthRender

1.  Renderingtheplane,monkeywithglassproperties,andColoredstreamlines

INTEGRATINGVTKANDBLENDERUSINGBLENDERVTK.PY

VTKBLEN

DERIN

TEGRA

TION

BlenderPythoninterpreter

Blenderhasapythoninterpreter.UsingtheVTKpythonwrappersandamodulecalledVTKblenderbyUniversityofAlbertaCSdepartment.

Thismodulecaniteratethroughanimationsortimedependentdata. 1

23

VTKBLEN

DERIN

TEGRA

TION

VTKPythonDemo

StepstorunningtheUAICTDemo:1.  CopyVTKBlend.pyto/usr/lib/python26/

(Youwillneedtosudoforthiscommand)2.  OpentheVTKBlender_demo2.py3.  Gototherenderingtab4.  ClickANIM

ThisdemoworksbyusingVTKtogeneratethedataandthenreplaceameshiilewiththenewmeshdataateachtimestep

1

23

CONCLU

SIONS

Summary

Conclusions:• Blenderisagreattoolforhigh‐qualityrendering• Thereisabitofalearningcurve,butitismanageable• Blender2.5Xismuchnicerandfaster,however,itisbuiltonpython3.0(VTKis2.xonly)anditcurrentlydoesnotimportvrmliilesdirectly• Blender2.49iilescanbeopenedin2.5x,soif2.5xispreferred,theiilecanbeimportedin2.49andthenusedin2.5x• BlenderisnotasuitablealternativetoParavieworothertruedatavisualizationpackage• Renderingisanartandisafairlyindepthsubject

RESO

URCES

ReferencesandUsefulLinks

ArticleonSettingup3PointLighting:http://www.3drender.com/light/3point.html

BlenderMaterials:http://www.freewebs.com/blendermats/

UniversityofAlbertaCSdepartment:http://www.ualberta.ca/CNS/RESEARCH/Vis/VTKBlender/index.html