[063] How to Apply Multiple UV Sets and Maps in CityEngine

Learn how to layer multiple UV sets in Esri CityEngine using the set() command and material map attributes to overcome texture overlay issues.

This tutorial explains the limitations of using the texture() command when handling multiple UV sets on a single object in Esri CityEngine and demonstrates how to properly assign multiple texture channels like colormap and dirtmap using set() and projectUV().

We already covered the 10 uv-sets in the last lesson.

Each has a unique index number, and each unique index has its designated texture attributes.

CityEngine texturing essential knowledge doc
figure 1 : https://doc.arcgis.com/en/cityengine/latest/cga/cga-texturing-essential-knowledge.htm

As seen above, a total of 10 uv-sets from 0 to 9 each have their own unique texture attributes.

So let's apply a colormap and a dirtmap using setupProjection(), texture(), and projectUV() learned in the previous lesson.


Lot -->
	setupProjection(2,scope.xz,'1,'1,0,0,1)
	texture("images/back_image.jpg")
	projectUV(2)

	setupProjection(0,scope.xz,5,5,0,0,1)
	texture("images/texture.jpg")
	projectUV(0)

	X.

texture.jpg to uv-set 0,

texture.jpg
figure 3 : texture.jpg

and back_image.jpg to uv-set 2

back_image.jpg
figure 4 : back_image.jpg

were applied.

The expected result was

Expected overlaid texture result
figure 5 : Expected visual overlay

that texture.jpg should be overlaid on top of back_image.jpg as shown above.

However, the result was.....

Actual failed texture result
figure 6 : Actual rendered output in CityEngine

As shown in Figure 6, the expected overlay completely fails. Only the texture intended for UV Set 2 (back_image.jpg) is rendered on the screen, while texture.jpg assigned to UV Set 0 disappears entirely.

This issue occurs because the texture() command cannot target specific UV sets—it continuously overrides the single material.colormap channel. When multiple texture() commands and projectUV() indices conflict, only one layer survives while the other texture binding breaks completely.

Therefore, when working with multiple UV sets on a single object, you should avoid using texture() and instead use the set() command to explicitly specify material map attributes (e.g., material.colormap, material.dirtmap).

If you rewrite the above code using set(), it becomes as follows.


Lot -->
	primitiveSphere
	setupProjection(0,scope.xz,5,5,0,0,1)
	setupProjection(4,scope.xz,'1,'1,0,0,1)
	set(material.colormap,"images/texture.jpg")
	set(material.dirtmap,"images/back_image.jpg")
	projectUV(0)
	projectUV(2)
	X.

The result is

Correct result using set command
figure 8 : Successful overlay rendering

Yes.. we got the desired result.

Just by looking at the code, you can tell how to use it.

1. Set up the slots using setupProjection.

2. In set(), specify the material.map attribute shown below and write the corresponding texture path.

material map attribute documentation
figure 9 : https://doc.arcgis.com/en/cityengine/latest/cga/cga-material-map-attribute.htm

3. Finally, execute projectUV() to apply that texture, and that's it.

This way, you can apply multiple uv-sets.

Since you only need to change the code, it's not very difficult.

There is one downside,

Although all uv-sets can be applied in CityEngine, only color.map, dirtmap, and opacitymap can be previewed in real-time on screen. As for the rest... whether they can be considered visible is questionable.

Exporting is another matter entirely.

Check the following link to see which uv-sets are imported/exported depending on the format.

https://doc.arcgis.com/en/cityengine/latest/cga/cga-material-attribute.htm

That's all for today.

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