[062] How to Apply and Project UV Textures in CityEngine - texture(), projectUV()

Learn the texture() and projectUV() commands to accurately apply 2D image maps onto 2D polygons and 3D architectural models in Esri CityEngine.

This tutorial covers the complete step-by-step workflow for procedural texturing in Esri CityEngine CGA. Learn how to map texture file paths with texture() and map UV projection coordinates using projectUV(), complete with code examples, 3D volume extrusions, and scope orientation considerations. Understanding these three commands—setupProjection(), texture(), and projectUV()—is essential for procedural texturing in CityEngine.

Last time, we looked at setupProjection(), which prepares space for textures.

Today, we'll cover the remaining two commands required to apply textures: texture() and projectUV().

Let's start with the texture() command.

CityEngine CGA texture command documentation reference
Figure 1 https://doc.arcgis.com/en/cityengine/latest/cga/cga-texture.htm

The texture() command simply specifies the path to the image file. It is one of the simplest CGA commands.

Now, let's look at the next projectUV() reference.

CityEngine CGA projectUV command documentation reference
Figure 2 https://doc.arcgis.com/en/cityengine/latest/cga/cga-project-uv.htm

Simply specify the same uvSet index used in setupProjection().

The entered number is identical to the uvSet declared in setupProjection().

Compared to setupProjection(), the remaining two commands are straightforward and require very little explanation.

Now that we have covered all three steps, let's simply apply a texture.

As always, we start from a plane.

Those who need the image files used can download them and place them inside the images folder of the project folder.

texture.jpg, back_image.jpg


@Enum("scope.xy", "scope.xz", "scope.yx", "scope.yz", "scope.zx", "scope.zy", 
		"world.xy", "world.xz","world.yx","world.yz","world.zx","world.zy")
attr map_direction = "scope.xy"

@Range(min=1, max=10, stepsize=0.5)
attr map_size = 1

@Range(min=-10, max=10, stepsize=0.5)
attr map_offset = 0

@Range(min=0, max=2, stepsize=0.1)
attr UWfactor = 0

Lot -->
	setupProjection(0,map_direction,map_size,map_size,map_offset,map_offset,UWfactor)
	texture("images/texture.jpg")
	projectUV(0)
	X.

By now, you can probably imagine the result.

Depending on the axes selector, there are cases where only stripes are drawn straight across; in that case, remember the scope we learned earlier. Because the texture is projected according to the scope orientation.

Next, we will add extrude() to the above code and see how the texture behaves on a 3D object.


@Enum("scope.xy", "scope.xz", "scope.yx", "scope.yz", "scope.zx", "scope.zy", 
		"world.xy", "world.xz","world.yx","world.yz","world.zx","world.zy")
attr map_direction = "scope.xy"

@Range(min=1, max=10, stepsize=0.5)
attr map_size = 1

@Range(min=-10, max=10, stepsize=0.5)
attr map_offset = 0

@Range(min=0, max=2, stepsize=0.1)
attr UWfactor = 0

Lot -->
	extrude(20)
	setupProjection(0,map_direction,map_size,map_size,map_offset,map_offset,UWfactor)
	texture("images/texture.jpg")
	projectUV(0)
	X.

The only change is the addition of extrude(20).

Let's see the result.

When applying textures, the most important thing is selecting the correct axis selector.

Note that, the image path of texture can be written as a relative path from the project folder.

The texture images used above are located in the path below.

Project folder structure for texture image paths
figure 5 : Texture asset placement inside project images folder

This covers the fundamentals of applying textures in CityEngine.

Next, we'll learn how to use multiple UV sets to apply different textures to the same model.

"Things are not done beautifully. The beauty is an integral part of their being done."
— Robert Henri, The Art Spirit
Continue Learning
Explore complete tutorial collections for CityEngine and Global Mapper.

Comments

Popular posts from this blog

029] How to Split Polygon Areas with Intersecting Lines in Global Mapper

[008] How to Understand CGA Rule Structure in CityEngine (Beginner Guide)

046] How to Create Parallel Offset Lines in Global Mapper