Blender 3D: Noob to Pro/Import and Render a SolidWorks Model
Note: This content is being actively developed on the main Blender Tutorial
Content can still be added here on Wikibooks, but you should be aware that this is a fork. Please add to the discussion page if you make any substantial changes or want to do something else to this content.
How to import your SolidWorks model in Blender and render it using Yafaray.
Introduction[edit | edit source]
SolidWorks is one of the main product design solid modellers. It has a built in render engine called PhotoWorks. With the release of PhotoWorks 2, rendering within SolidWorks has become more realistic and easier. In a lot of cases PhotoWorks will be the most convenient way to render your model, because you don't have to leave SolidWorks. However, sometimes you will find the need to make renders that are more realistic (or even photo-realistic), and PhotoWorks is not sufficient anymore. This is when you might consider using an external program for rendering. In this how-to, I will describe how to do this using Blender with Yafaray.
Both programs are open-source software, and you can download them for free:
If you use different versions (especially YafaRay), you might have difficulties trying to follow this how-to.
You need a basic understanding of the Blender interface to be able to follow this how-to. If you have never worked with blender before, I advise you to read the Blender Interface chapter of the Blender 3D: Noob to Pro wikibook first.
Exporting from SolidWorks[edit | edit source]
I will be working with a model of a lighter (Created by Marko M. Markovic) that I downloaded from the SolidWorks Users Group Network (SWUGN) at the bottom of the "FREE SolidWorks models" section.
Before you can import your model into Blender, you need to export it to the VRML 2.0 (VRML 97) format first. In this how-to I will describe how to do this with an assembly, but it is essentially the same for a separate part.
- Open your assembly.
- If you don't want to export all the objects, suppress the objects you don't want to export first.
- The export quality (strangely enough) depends on the screen settings. To improve this, go to Tools > Options > Document Properties tab > Image Quality. If your model looks faceted in your viewport, just set the "Shaded and draft quality HLR/HLV resolution" to a higher value. Especially for complex shapes with a lot of curvature, you'll probably want a higher value. Take into account, however, that a higher value means a bigger file and slower operations within Blender.
- Go to File > Save As...
- Select VRML as your file-type and click on the "Options..." button.
- Make sure "VRML 2.0" is selected. Usually you need to set the unit to something bigger than millimeters; normally centimeters will do, but for the bigger models I advice you to set the unit to meters. You'll be able to scale the model again once you're in Blender.
- uncheck "save all components of the assembly into a single file"
Because SolidWorks appears to be making a mess out of large assemblies (randomly combining several parts into one mesh), we'll export the assembly as separate files into one directory. To be able to load these files easily, you need to create a new directory for this export first. Later on, we'll import all the files in this directory at once (time saver), so make sure there's no other files in this directory!
- Close the "Export Options" window (click OK).
- Create a new directory for the export (or use an empty one), and hit "Save".
Creating an HDRI environment[edit | edit source]
Because the aim of this how-to is to get you started on photorealistic rendering, we will be using an HDRI environment. HDRI stands for High Dynamic Range Imaging, and is basically a technique to use a picture of the environment to light your scene. This will result in very realistic and convincing shadows, highlights and reflections. This is very important for realistic emulation of chrome for example.
First of all, you'll need an HDR image. There is a whole range at http://debevec.org/Probes/ that you can download for free. I will use the Uffizi Gallery probe, but any other HDR image will do just fine.
Now start Blender. To apply the HDRI environment to your scene:
- Go to the shading settings (press F5) and click the World button.
- In the "Texture and Input" tab, click "Add New" and "Angmap".
- Then go to the "Map To" tab and deactivate "Blend" and activate "Hori".
- Now go to the Texture settings (press F6) and change the "Texture Type" to "Image".
- Click the "Load Image" button and locate your HDR image.
- To be able to render using this environment, you need to enable YafaRay. Press F10 and change the "Blender Internal" to "YafaRay".
- Go to the YafaRay tab and deactivate the XML button and set Exp (the exposure control) to 1.5.
- Set the Raydepth to 6.
- In the YafaRay GI tab, select "Full" as your method, and "Low" quality (that's good enough for a preview). Also enable the "Cache" button.
- Set both Depth and CDepth to 10.
- For caustic effects you can activate the "Photons" button, but in my case (a lighter lying on a table), it won't make much difference.
Assigning materials[edit | edit source]
Plastic[edit | edit source]
The first material we'll create will be plain plastic. We'll apply this material to the middle part, the gas regulator and the push button. Whenever you're going to create a new material, think of it in terms of how much it should reflect, how much it diffuses light, how transparent it is etc. because these are your parameters within Blender's material editor. To create the plastic material:
- Select the two middle parts, the push button and the gas regulator (use SHIFT + click to select more than one mesh at once).
- Go to the shading settings (F5) and add a new material (Click "Add New").
- Press CTRL + L (in the viewport) and select Materials from the popup to use this material on all the objects you selected.
- Change the color to almost completely black (RGB: 0.07/0.07/0.07).
- In the Shader tab, set the specular shader to "Blinn".
- Set the "Spec" value to 1.4 and "Hard" to 320.
- Press "Ray Mirror" in the Mirror Transp tab, and set the "rayMir" value to 0.3.
Transparent plastic[edit | edit source]
For the fuel part, we'll assign a nice green transparent material.
- Select the fuel part, and add a new material to it (again, F5, "Add New").
- Set the color to a bright green (HSV: 0.220/1.000/1.000) and the alpha value (A) to 0.300.
- Set the Amb value to 1.000.
- Go to the Mirror Transp tab and enable both "Ray Mirror" and "Ray Transp".
- Set rayMir to 0.20 and IOR to 1.45 (which is an approximate index of refraction).
- Set Filt to 0.250.
Chrome[edit | edit source]
The metal part needs to be nice & shiny, so we'll make a chrome-like material for that.
- Set the Ref value to 1.000.
- Set the specular shader to "Blinn", and use the following values: Spec 2.000, Hard 50 (default), Refr 6.500.
- In the Mirror Transp tab, enable "Ray Mirror" and set the rayMir value to 0.9. Leave the rest unchanged.
Wood Texture[edit | edit source]
As stated before, to make it make the lighter more realistic, it needs a realistic environment. We already made part of this environment with the HDR-image, but to make it even more convincing, we're going to turn the ground-plane into a realistic looking table. We need an image of wood to apply to the plane. I'll use one from Mayang's Free Texture Library, called "parallel wooden planks".
- Because this texture is 1600x1200, we'll scale the ground-plane to the same aspect-ratio - S, 1.6 (TAB), 1.2.
- Set the Ref value of the diffuse shader (Lambert) to 0.600.
- Set the Spec value to 0.175, Hard to 30.
- In the Texture tab, press "Add New". Press F6 to switch to the texture properties.
- Change the Texture Type to "Image" and load your texture (in my case the wood texture from Mayang) in the Image tab ("Load Image").
Rendered with materials applied[edit | edit source]
To render, you can hit F12 directly, or you can go to the render settings first (F10). Because of the render settings we use (GI and an HDRI environment), my render took about 3 minutes on a AMD64 3200+ with 1GB of RAM. If you just want a preview, you can either make a smaller render (set it to 25% in the Render tab), or use worse quality GI settings. For a final render, I advice you to use at least High for the GI quality - it will take more time but the result will be better looking!
Below you can see the result I got with all the settings from this how-to. Remember that this is just a general guide, and I encourage you to change the settings (Exposure for example), to see the effect. You have to get a little bit of 'feeling' with the material settings to be able to create a satisfying material quickly. I hope this how-to helps to get started with a SW to Blender workflow.
note: if your result is very different from the picture below, please report this on the discussion page (the tab at the top of this page). That way we can keep improving the tutorial. You can upload the render as well, but make sure it has a specific name (lighter-yourname.jpg for example).
[edit | edit source]
- http://www.blender.org The official Blender site, where you can find a lot of info.
- http://www.yafaray.org The official YafaRay site.
- http://www.elysiun.com/forum/ The elYsiun.com forum, a huge Blender community where you can ask questions or show your work.
- http://forums.cgsociety.org/forumdisplay.php?f=91 The CGTalk Blender forum, smaller than Elysiun, but considered more serious.
- http://forum.yafray.org/ the YafRay forum, for YafRay specific questions