Skip to content

Commit

Permalink
doc: Fix typo in URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Jun 27, 2022
1 parent 01d8657 commit f426673
Show file tree
Hide file tree
Showing 34 changed files with 133 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
---
uid: tutorial_plastics_2
title: Realistic Looking Plastics - Create Mesh
description: How to create the meshes in Blender
---

# Create Mesh

We're now going to import the SVG created in the [previous step](xref:tutorial_plastics_1) and create a mesh that is beveled on the top.

## Step 1: Import

Open Blender, clear the scene with `A`, `X`, `Enter`. Then, click on *File -> Import -> Scalable Vector Graphics (.svg)*, navigate to where you've saved the SVG in the previous step, select `Plastics.svg`, and hit *Import*.

You might not see much due to the imported size. If there were no errors, you should see your imported plastics in the Outliner. Select them and press `.` on the numpad (not the main keyboard) while hovering over the 3D viewport to zoom in.

> [!note]
> You might run into another issue due to the size of the plastics: Camera clipping. To fix that, press `N` with your cursor over the 3D Viewport, select *View* and set something like 0.001m for *Clip Start*.
Your viewport should look like this now:

![2D Outlines](blender-shapes.png)

## Step 2: Setup

The way we're going for this is to extrude and bevel our SVG on one side only. This however results in the bottom faces missing. To fix that, we'll duplicate our SVG and use one for extrusion and the other for the bottom mesh.

Before we start, let's make it one single object so we can easily apply everything we do in one step. Select one element, hit `A` for select all, then `Ctrl`+`J` for joining all curves.

Hit `Shift`+`D`, `Esc` to duplicate at the same position. In the *Outliner*, let's name our objects "bottom" and "extruded":

![Duplicated Surface](blender-duplicated-surface.png)

## Step 3: Extrude

Select "extruded" in the outliner and click on the *Object Properties* tab in the *Properties* view on the right side. Under *Geometry*, there is an *Extrude* field, and a bit below a *Bevel* section.

Now, the *Extrude* value is difficult to judge. If you have access to the physical plastics, you can calculate the scale between the real world and the object in Blender by physically measuring the size of a plastic and dividing it by the [measured value](https://docs.blender.org/manual/en/latest/editors/3dview/toolbar/measure.html) in Blender. Then, also measure the thickness of the real-world plastic and multiply it by that factor. Personally, I just eyeballed it and ended up with 0.003 m for the *Extrude* value and 0.001 m for the *Bevel Depth*.

Then there are three more properties to change:

- We only want to extrude the front, so set *Fill Mode* to *Front*.
- We don't want to make the object larger by beveling, so enter the negative value of the bevel depth under *Offset*.
- Finally, a *Resolution* of `0` will do.

Here are all the non-default options in red:

![Extrude Parameters](blender-extrude.png)

## Step 4: Convert, Join and Clean

As seen in the previous screenshot, our bottom object now sits in the middle of the extruded mesh. Let's fix that by typing `G` (move), `Z` (on z-axis only), and the extrude value of the previous step, in our case `0.003`, followed by `Enter`.

Then type `A` to select all objects, choose *Object -> Convert -> Mesh*, and hit `Ctrl`+`J` to join them all. Finally, clean up the duplicated vertices from the extrusion by hitting `Tab` for edit mode, `A` to select all vertices, and choose *Mesh -> Clean Up -> Merge by Distance*.

Exit edit mode and this is how it should look:

![Extruded Shapes](blender-extruded.png)

If that's the case, congrats, you're done with the meshes! Maybe now it's a good moment to save your Blender file. `Ctrl`+`S` and enter `Plastics.blend`.

In the [next part](xref:tutorial_plastics_3) of this tutorial, we're going to UV-Map them.
---
uid: tutorial_plastics_2
title: Realistic Looking Plastics - Create Mesh
description: How to create the meshes in Blender
---

# Create Mesh

We're now going to import the SVG created in the [previous step](xref:tutorial_plastics_1) and create a mesh that is beveled on the top.

## Step 1: Import

Open Blender, clear the scene with `A`, `X`, `Enter`. Then, click on *File -> Import -> Scalable Vector Graphics (.svg)*, navigate to where you've saved the SVG in the previous step, select `Plastics.svg`, and hit *Import*.

You might not see much due to the imported size. If there were no errors, you should see your imported plastics in the Outliner. Select them and press `.` on the numpad (not the main keyboard) while hovering over the 3D viewport to zoom in.

> [!note]
> You might run into another issue due to the size of the plastics: Camera clipping. To fix that, press `N` with your cursor over the 3D Viewport, select *View* and set something like 0.001m for *Clip Start*.
Your viewport should look like this now:

![2D Outlines](blender-shapes.png)

## Step 2: Setup

The way we're going for this is to extrude and bevel our SVG on one side only. This however results in the bottom faces missing. To fix that, we'll duplicate our SVG and use one for extrusion and the other for the bottom mesh.

Before we start, let's make it one single object so we can easily apply everything we do in one step. Select one element, hit `A` for select all, then `Ctrl`+`J` for joining all curves.

Hit `Shift`+`D`, `Esc` to duplicate at the same position. In the *Outliner*, let's name our objects "bottom" and "extruded":

![Duplicated Surface](blender-duplicated-surface.png)

## Step 3: Extrude

Select "extruded" in the outliner and click on the *Object Properties* tab in the *Properties* view on the right side. Under *Geometry*, there is an *Extrude* field, and a bit below a *Bevel* section.

Now, the *Extrude* value is difficult to judge. If you have access to the physical plastics, you can calculate the scale between the real world and the object in Blender by physically measuring the size of a plastic and dividing it by the [measured value](https://docs.blender.org/manual/en/latest/editors/3dview/toolbar/measure.html) in Blender. Then, also measure the thickness of the real-world plastic and multiply it by that factor. Personally, I just eyeballed it and ended up with 0.003 m for the *Extrude* value and 0.001 m for the *Bevel Depth*.

Then there are three more properties to change:

- We only want to extrude the front, so set *Fill Mode* to *Front*.
- We don't want to make the object larger by beveling, so enter the negative value of the bevel depth under *Offset*.
- Finally, a *Resolution* of `0` will do.

Here are all the non-default options in red:

![Extrude Parameters](blender-extrude.png)

## Step 4: Convert, Join and Clean

As seen in the previous screenshot, our bottom object now sits in the middle of the extruded mesh. Let's fix that by typing `G` (move), `Z` (on z-axis only), and the extrude value of the previous step, in our case `0.003`, followed by `Enter`.

Then type `A` to select all objects, choose *Object -> Convert -> Mesh*, and hit `Ctrl`+`J` to join them all. Finally, clean up the duplicated vertices from the extrusion by hitting `Tab` for edit mode, `A` to select all vertices, and choose *Mesh -> Clean Up -> Merge by Distance*.

Exit edit mode and this is how it should look:

![Extruded Shapes](blender-extruded.png)

If that's the case, congrats, you're done with the meshes! Maybe now it's a good moment to save your Blender file. `Ctrl`+`S` and enter `Plastics.blend`.

In the [next part](xref:tutorial_plastics_3) of this tutorial, we're going to UV-Map them.
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
---
uid: tutorial_plastics_3
title: Realistic Looking Plastics - UV-Map Mesh
description: How to UV-map the texture onto your mesh in Blender
---

# UV-Map Mesh


## Step 1: Create Material Slots

We need three material slots, for the top and bottom faces, as well as for the edges. We'll split the vertices by firstly assigning everything to an "edge" slot, and then re-assigning the top and bottom faces to their own slots.

<img src="blender-material-slots.png" width="235" class="img-responsive pull-right" style="margin-left: 15px">

In object mode, open *Materials* properties and remove the current material slot (hit `-`). Add three new slots (press 3× `+`), and for each slot, create a new material by hitting the *New* button when the slot is selected. Name them "top", "bottom" and "edge" and set their base color to red, green, and blue respectively. Your slots should now look like in the screenshot.

Set the 3D viewport to *Material Preview*. Select your mesh, press `Tab` to switch to edit mode. Press `A` to select all vertices, select the "edge" material slot, and hit *Assign*. Your plastics should turn blue. Press `A` twice to deselect everything.

Then, press `7` on the numpad to switch to top view, zoom in a bit so you can clearly see the triangles, switch to *Face Select* and click on one face of the top surface:

![Triangle selected](blender-triangle-selected-2.png)

<img src="blender-select-coplanar.png" width="280" class="img-responsive pull-right" style="margin-left: 15px">

Click on *Select -> Select Similar -> Coplanar*, which should result in all top faces of all plastics being selected (but *not* the bottoms ones). However, you might get the bottom faces selected too, because there's a threshold that might be too large. You can check it by rotating the camera and verify that the bottom faces are not selected. If they are, expand the parameters and set the threshold to a small enough value. Then, select the "top" material slot and hit *Assign*. The top surfaces should turn red.

For the bottom faces, hit `7`, `9` on the numpad to switch to bottom view, and select again one face. Like before, select all coplanar faces, click the "bottom" material slot, and *Assign*. You should see the bottom faces turn green.

Now, the "edges" material slot should only contain the edges. Check by unselecting all (`A` `A`), then selecting the "edge" material slot and hitting *Select*. This should only select the edges, like here:

![Edges selected](blender-edges-selected.png)

Your meshes should now be colored like this (from top / bottom):

![Selecting edges](blender-material-geometry.png)

## Step 2: UV-Map

Switch to the *UV Editing* workspace. In the left *UV Editor*, choose *Image -> Open*, and select the exported `Plastic-01.png` you've created in part one. On the right, enter edit mode, click on the "top" material slot in the *Materials* property tab, and hit *Select*. Click on "bottom" and then on *Select* again.

From the *UV* menu, select *Cube Projection*. Move your cursor to the left view and press `A`. You should see both the top and bottom surfaces projected onto your texture:

![UV Mapping in Blender](blender-uv-mapping.png)

We're now going to align the projection with the texture. You can do that by using the `G` and `S` keys. What's important is to align the **outer** contour with the texture, like so:

![UV mapped correctly](blender-uv-mapped.png)

## Step 3: Prepare and Export

Once done, switch back to the *Layout* workspace. Before we export, there's still a bit of a clean up to do. In edit mode, hit `A` to select all and choose *Mesh -> Clean Up -> Limited Dissolve*. Exit edit mode, go to *Modifier Properties*, add the *Triangulate* modifier, and hit `Ctrl`+`A` to apply.

What we just did reduced the complexity of our topology. We triangulate at the end to avoid problems during export.

![Reduced polygons](blender-poly-reduction.png)

From left to right:
- Original (102k vertices, 44k triangles)
- After limited dissolve (66k vertices, 30k triangles, but errors in mesh)
- After triangulation (66k vertices, 30k triangles)

Switch to the *Object Data* properties, and under *Normals*, enable *Auto Smooth*. This will properly align the normals on the bevel side, giving it a more realistic refraction effect.

We still have one single object, so before exporting, let's split it. In edit mode, hit `A` to select all and choose *Mesh -> Separate -> By Loose Parts*. Before exporting, feel free to rename your objects in the Outliner, it's what you'll see in Unity.

Lastly, in object mode, hit `A` to select all objects and click on *Object -> Set Origin -> Origin to Geometry*. This will set the local origin of each object to the object itself, making it easier to place it.

Export the plastics by selecting *File -> Export -> FBX*. Name it `Plastics.fbx` and hit *Export FBX*.

Now let's [import this into Unity](xref:tutorial_plastics_4)!
---
uid: tutorial_plastics_3
title: Realistic Looking Plastics - UV-Map Mesh
description: How to UV-map the texture onto your mesh in Blender
---

# UV-Map Mesh


## Step 1: Create Material Slots

We need three material slots, for the top and bottom faces, as well as for the edges. We'll split the vertices by firstly assigning everything to an "edge" slot, and then re-assigning the top and bottom faces to their own slots.

<img src="blender-material-slots.png" width="235" class="img-responsive pull-right" style="margin-left: 15px">

In object mode, open *Materials* properties and remove the current material slot (hit `-`). Add three new slots (press 3× `+`), and for each slot, create a new material by hitting the *New* button when the slot is selected. Name them "top", "bottom" and "edge" and set their base color to red, green, and blue respectively. Your slots should now look like in the screenshot.

Set the 3D viewport to *Material Preview*. Select your mesh, press `Tab` to switch to edit mode. Press `A` to select all vertices, select the "edge" material slot, and hit *Assign*. Your plastics should turn blue. Press `A` twice to deselect everything.

Then, press `7` on the numpad to switch to top view, zoom in a bit so you can clearly see the triangles, switch to *Face Select* and click on one face of the top surface:

![Triangle selected](blender-triangle-selected-2.png)

<img src="blender-select-coplanar.png" width="280" class="img-responsive pull-right" style="margin-left: 15px">

Click on *Select -> Select Similar -> Coplanar*, which should result in all top faces of all plastics being selected (but *not* the bottoms ones). However, you might get the bottom faces selected too, because there's a threshold that might be too large. You can check it by rotating the camera and verify that the bottom faces are not selected. If they are, expand the parameters and set the threshold to a small enough value. Then, select the "top" material slot and hit *Assign*. The top surfaces should turn red.

For the bottom faces, hit `7`, `9` on the numpad to switch to bottom view, and select again one face. Like before, select all coplanar faces, click the "bottom" material slot, and *Assign*. You should see the bottom faces turn green.

Now, the "edges" material slot should only contain the edges. Check by unselecting all (`A` `A`), then selecting the "edge" material slot and hitting *Select*. This should only select the edges, like here:

![Edges selected](blender-edges-selected.png)

Your meshes should now be colored like this (from top / bottom):

![Selecting edges](blender-material-geometry.png)

## Step 2: UV-Map

Switch to the *UV Editing* workspace. In the left *UV Editor*, choose *Image -> Open*, and select the exported `Plastic-01.png` you've created in part one. On the right, enter edit mode, click on the "top" material slot in the *Materials* property tab, and hit *Select*. Click on "bottom" and then on *Select* again.

From the *UV* menu, select *Cube Projection*. Move your cursor to the left view and press `A`. You should see both the top and bottom surfaces projected onto your texture:

![UV Mapping in Blender](blender-uv-mapping.png)

We're now going to align the projection with the texture. You can do that by using the `G` and `S` keys. What's important is to align the **outer** contour with the texture, like so:

![UV mapped correctly](blender-uv-mapped.png)

## Step 3: Prepare and Export

Once done, switch back to the *Layout* workspace. Before we export, there's still a bit of a clean up to do. In edit mode, hit `A` to select all and choose *Mesh -> Clean Up -> Limited Dissolve*. Exit edit mode, go to *Modifier Properties*, add the *Triangulate* modifier, and hit `Ctrl`+`A` to apply.

What we just did reduced the complexity of our topology. We triangulate at the end to avoid problems during export.

![Reduced polygons](blender-poly-reduction.png)

From left to right:
- Original (102k vertices, 44k triangles)
- After limited dissolve (66k vertices, 30k triangles, but errors in mesh)
- After triangulation (66k vertices, 30k triangles)

Switch to the *Object Data* properties, and under *Normals*, enable *Auto Smooth*. This will properly align the normals on the bevel side, giving it a more realistic refraction effect.

We still have one single object, so before exporting, let's split it. In edit mode, hit `A` to select all and choose *Mesh -> Separate -> By Loose Parts*. Before exporting, feel free to rename your objects in the Outliner, it's what you'll see in Unity.

Lastly, in object mode, hit `A` to select all objects and click on *Object -> Set Origin -> Origin to Geometry*. This will set the local origin of each object to the object itself, making it easier to place it.

Export the plastics by selecting *File -> Export -> FBX*. Name it `Plastics.fbx` and hit *Export FBX*.

Now let's [import this into Unity](xref:tutorial_plastics_4)!

0 comments on commit f426673

Please sign in to comment.