[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.
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.
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.
@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.
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.
- Learn previous workflow in [061] How to Set Up Texture Projections in Esri CityEngine - setupProjection()
- Continue learning with [063] How to Apply Multiple UV Sets and Maps in CityEngine
Comments
Post a Comment
Feel free to leave a comment if you have any questions about Global Mapper or CityEngine. I will get back to you with a sincere response as soon as possible. (Please note that all comments are moderated and manually approved to maintain a high-quality community. Promotional or spam content will not be published.)