62
SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

Embed Size (px)

Citation preview

Page 1: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

1

SE 313 – Computer Graphics

Lecture 11: Projection Painting and Merging Textures

Lecturer: Gazihan Alankuş

Page 2: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

2

Quiz• Turn off monitors• Take out a piece of paper and a pen/pencil• 5 minutes

Page 3: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

3

Texture painting with the clone tool• We have seen – Texture painting on 3D objects – Using Bprojection and the clone tool to use parts

of images on our models.• Clone tool demonstrated in Gimp

Cursor Start drag

Cursor mimics

drag path

Copies current location under

cursor

Page 4: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

4

Texture painting with the clone tool• Great for using details in parts of images• Precise matching can be difficult to master

Page 5: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

5

Texturing in Blender• While Bprojection and the clone tool are great

for collecting parts of your texture from different images, getting the whole texture of a model from an image requires more precision

• We will learn projection painting and merging textures for different points of view to create more precise textures

Page 6: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

6

Projection Painting in Blender• The idea– Get photographs of the object from different

angles– Paint them on the object as different textures– Merge them together

Page 7: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

7

Projection Painting in Blender• The idea– Get photographs of the object from different

angles– Paint them on the object as different textures– Merge them together

Page 8: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

8

We will continue with our ice cream truck example

Page 9: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

9

Getting the model ready for texturing• We will repeat what we did last week in the

following slides (slides 10-26)

Page 10: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

10

Modeling a truck• The initial cube has material on it, remove it

and add a new cube

Page 11: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

11

Modeling a truck• Press tab to go to edit mode. Hit A to select

all.• Press subdivide to add more vertices and

edges

Page 12: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

12

Modeling a truck• Select faces in the front (multi-select with

shift) and do “extrude region”– If you do “extrude individual” they would be two

separate pieces

Page 13: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

13

Modeling a truck• Select and move around edges and faces to

make it look more like a truck• Feel free to play with other mesh tools to

make it better-looking

Page 14: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

14

Preparing for texturing• While it’s simple, we’re happy with our model.

Now let’s prepare it to be textured. You have to do these steps to put textures on your models.

Page 15: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

15

Preparing for texturing• First we need to unwrap our model. This maps

the 3D model to 2D. Since images are 2D, this will help us cover the model with parts of an image. This is called texturing.

• Earlier in the semester we saw that we can mark seams in our model to unwrap it nicely. – Now we will take a more practical approach and

use automatic unwrapping

Page 16: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

16

Preparing for texturing• While in edit mode, select all by pressing A

and making everything orange.• Click on unwrap to bring up its menu• Beside “Unwrap” there are many other

options. Select Smart UV Project.

Page 17: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

17

Preparing for texturing• To see things better, on top of the screen click

on the layout button and select UV editing. This will open the image editor on the left.

• There we see where the selected faces are mapped. Since we selected all, we see them all.

Page 18: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

18

Preparing for texturing• While the unwrapped model is a bit

discontinuous, we do not care. We will draw on the model itself and will not care how they are located in the 2D image.

Page 19: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

19

Preparing for texturing• Now add an image. You can choose to initialize

it with the UV test grid to understand which parts of the image is mapped to which parts of the model.

• Name the image well. “truck texture” is what I wrote.

Page 20: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

20

Preparing for texturing• Scroll out and you will see your image

initialized to the UV test image• Under the 3D view on the right, select

“texture” to see the texture on the model

Page 21: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

21

Preparing for texturing• Go back to the default layout to have more

screen area for setting up the material. • Even though we are seeing the texture on our

truck, we have to also set the texture as a material on the truck for it to work

Page 22: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

22

Preparing for texturing• On the properties pane, go to the material tab• Add a new material if there isn’t already one

there

Page 23: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

23

Preparing for texturing• Now go to the textures tab and add a texture

to this material if there isn’t one already

Page 24: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

24

Preparing for texturing• Set the type of the texture to “Image or Movie”• Scroll down and browse for the image that we

created earlier • Under mapping, select UV for Coordinates

Page 25: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

25

Preparing for texturing• Congratulations, you have successfully added

the texture to the model. Here are the things you can do to verify that you have done everything correctly:– Render and see the texture on the model– Select texture in viewport shading and see the

texture in the 3d view

Page 26: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

26

Preparing for texturing• Next we will start painting the texture. Before

that, we will save the texture image. An early reminder: don’t forget to save the image every time after you paint. File->Save’ing the .blend file is not enough.

Page 27: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

27

Reviewing the model• Now our model is unwrapped nicely and has a

simple texture on it• We can remove the light in the environment if

some faces of our truck are black– But then when you render it will all be black– Here is how you can fix it:

Page 28: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

28

Projection Painting in Blender• The idea– Get photographs of the object from different

angles– Paint them on the object as different textures– Merge them together

Page 29: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

29

Reviewing the model• Go to the Object Data tab while

the truck is selected• There you see a section called UV

Maps– This is where the unwrapped UV

coordinates are stored– We will have more than one of

these for different angles. • Rename this to “Main UVMap”

Page 30: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

30

Adding a new UV map• Add a new UV map by clicking

the plus button• Rename it to Front

Page 31: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

31

Adding a new UV map• In the image editor, we still see

the old UV map and the image. This is because we created an exact copy of it

• To verify this, move one of the vertices in the image editor

• Switch between Main UVMap and Front. You will see that you edited Front and not Main UVMap

Page 32: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

32

Using a photo as a texture image• Now we want to load the front

image for the truck and map it to the front of the truck.

• Select Front from UV Maps• Open the image for the front

• Now we want to place the vertices in the image editor such that they match the photo

Page 33: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

33

Using a photo as a texture image• In the 3D view, turn the view so that

our truck is oriented the same way as the truck in the photo

• Now select all, click Unwrap and Project from View

Page 34: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

34

Using a photo as a texture image• The vertices started really small.

You will always have to resize and locate them by hand

• Select all (“A”), press “S” on keyboard to start scaling

• Press “G” to start moving, and “R” to start rotating if you need to

Page 35: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

35

Using a photo as a texture image• Now lets ignore the faces that we

cannot see. In the 3D View, deselect all

• Select the visible edges by clicking and dragging the mouse

• In the image editor we will only have these visible

Page 36: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

36

Using a photo as a texture image• Now move around individual

vertices in the image editor so that they match the photo

• You don’t have to get everything. Don’t get any background inside the model.

• You can view the result as you drag

Page 37: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

37

Using a photo as a texture image• While this was good for the front of the truck,

the side is not so good.• We will get the side from another texture

later. First, let’s get the back just like the front

Page 38: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

38

Using more photos• To get the back of the truck, we

will create a new UV Map• Create a new UV Map and

rename it to Back. Again, it duplicated the current UV Map.

• Load the back image in the image editor.

• We will need to do another unwrap for this

Page 39: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

39

Using more photos• Turn the 3D view so that the back of

our truck is in a similar orientation as the photo

• In the 3D view, in edit mode, select all

• Select Unwrap and Project From View

Page 40: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

40

Using more photos• Again select all (A), scale (S),

rotate (R), and move (G) the points.

• Select only the visible faces of the truck and move individual points to match the photo

Page 41: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

41

Doing the sides from one photo• Now for the sides of the truck, we want to

create another UV Map• Load the side photo• Orient the truck and Unwrap,

Project From View • Select only the visible faces and adjust

the UV coordinates

Page 42: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

42

Doing the other side from the same photo• Turn the other side of the truck.

Orient it similarly to our photo.• Select only the faces on this side

(deselect with “A” and select one by one)

• Unwrap, Project From View again. This will not touch the other side that is not visible.

Page 43: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

43

Doing the other side from the same photo• In the image editor select all

(A) and mirror these vertices so that they look more like the photo

• Adjust and match the photo

Page 44: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

44

Doing the other side from the same photo• Now both sides of the truck are done in this

UV Map

Page 45: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

45

Using multiple texture images• Now we have three different UV Maps that all

texture only parts of the model

Page 46: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

46

Projection Painting in Blender• The idea– Get photographs of the object from different

angles– Paint them on the object as different textures– Merge them together

Page 47: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

47

Using multiple texture images• Problem is, we need only one texture. – Now we want to merge them into one single

texture.• We will copy parts of each texture into the

Main UVMap

Page 48: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

48

Merging textures• For this, we will again use texture painting and

the clone brush tool. • Select the Main UVMap from UV Maps and

switch to texture paint mode• On the left, select the clone brush

Page 49: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

49

Merging textures• Similar to Bprojection, where we cloned

visuals from a plane, now we will clone from the other UV maps that we cannot see.– We will not place a cursor, it will handle all that

itself. • Scroll down to the Project Paint section. It

should already be checked.

Page 50: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

50

Merging textures• The Clone property here lets

us clone from other UV maps• We will start by cloning the

front of the truck from the “Front” UV map.

• Check Clone and select the “Front” UV map that youcreated earlier.

• Also, increase the strength of the brush

Page 51: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

51

Merging textures• Now when you click and drag on the model, it

will bring in parts of the Front UV map.• Paint the whole front like this• This way, we will bring in parts of

the truck from different texturemappings

Page 52: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

52

Merging textures• Select “Back” and start painting the

back.

Page 53: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

53

Merging textures• Select “Sides” and start painting the

sides. Be careful not to paint over the front or the back. If you do,press Ctrl+Z to undo.– Tip: zoom in so that you can’t see

other faces• Paint both sides

Page 54: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

54

Merging textures• This looks better than what we did last week.

Page 55: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

55

Painting the rest• However, the top and the bottom are not

painted.

Page 56: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

56

Painting the rest• We can select a color and paint these, but it

would be difficult to choose the correct color. You can get the value of the color in external programs like Gimp if you want and use that.

• I will do something that’s more hacky.

Page 57: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

57

Painting the rest• Select the clone brush, Ctrl+click on the

model where you have color that you want for the top of the model. The cursor will go there.

• Now deselect Clone so that we don’t copy from other UV maps

• Make your brush smaller and paint on top of the truck with very short strokes

Page 58: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

58

Painting the rest• Now that we got some color on

top, get the cursor there with Ctrl+click and continue to paint from there

• Let your strokes move away from the cursor. This will avoid messing it up.

Page 59: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

59

Painting the rest• Paint the bottom to black with the

regular brush tool

Page 60: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

60

Finishing up• Now if you want, you can remove the “Front”, “Back”

and “Sides” UV Maps but you don’t have to. • When you select “truck texture” in the image editor,

you should see your truck unwrapped and textured nicely. Save it next to the blend file.

Page 61: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

61

Finishing up• Now when you drag the model and the

texture into Unity, you should see it textured fine.

Page 62: SE 313 – Computer Graphics Lecture 11: Projection Painting and Merging Textures Lecturer: Gazihan Alankuş 1

62

No homework• Work on your projects!