Hi,
I have an isssue with texturizing walls of my building model. What I want to is to texturize only walls but leave objects (e.g. window and door) without additional texture, because these objects have their own textures defined. Here is my cga script and screenshot of current model:
testWall -->
extrude(4)
comp(f){front : Wall1}
Wall1 -->
setupProjection(0, scope.xy, 1, 1)
texture(test)
projectUV(0)
split(x){ '0.5 : Window | '0.5 : Doors }
Window -->
split(x){ ~1 : Wall.
| 1 : split(y){ ~1 : Wall.
| 1 : WindowAsset
| ~1 : Wall. }
| ~1 : Wall. }
Doors -->
split(x){ ~1 : Wall.
| 1.5 : split(y){ 2.5 : DoorsAsset
| ~1 : Wall. }
| ~1 : Wall. }
WindowAsset -->
i(window)
mirror(false,false,true)
set(material.specular.r, 0)
set(material.specular.b, 0)
set(material.specular.g, 0)
DoorsAsset -->
i(plain_door)
mirror(false,false,true)
set(material.specular.r, 0)
set(material.specular.b, 0)
set(material.specular.g, 0)
Solved! Go to Solution.
Treat texturing as the final mesh object and you will encounter this error much less. For example make a rule:
Final_Wall_wTexture--> setupProjection(0, scope.xy, 1, 1) texture(test) projectUV(0)
Replace your "Wall." rule with this rule and delete the texturing part at the beginning in Wall1.
Use this rule any time you think you are at the model's last branch of the shape tree (instead of making an unused shape with no rule like "Wall."
Further note, to make all the textures look seemless even though they are different meshes, try to use the setupProjection ("world.x,y,or z") as opposed to scope, or possibly try using the tileUV rule.
But, If you want to texture early in the process you will have to use the deleteUV rule when you get to the shape with the problems. But it's harder in my opinion to keep track of texturing this way.
Treat texturing as the final mesh object and you will encounter this error much less. For example make a rule:
Final_Wall_wTexture--> setupProjection(0, scope.xy, 1, 1) texture(test) projectUV(0)
Replace your "Wall." rule with this rule and delete the texturing part at the beginning in Wall1.
Use this rule any time you think you are at the model's last branch of the shape tree (instead of making an unused shape with no rule like "Wall."
Further note, to make all the textures look seemless even though they are different meshes, try to use the setupProjection ("world.x,y,or z") as opposed to scope, or possibly try using the tileUV rule.
But, If you want to texture early in the process you will have to use the deleteUV rule when you get to the shape with the problems. But it's harder in my opinion to keep track of texturing this way.
Thanks! That works perfectly for me.
Another way would be similar to how the facade and windows are textured in Tutorial 6.
https://doc.arcgis.com/en/cityengine/latest/tutorials/tutorial-6-basic-shape-grammar.htm
The idea is that the UVs are setup across the whole facade when the facade is created using setupProjection(). Then, the rule goes on to break up the facade into walls and windows. On the wall pieces, the texture is assigned using texture(), and the UVs are projected onto the shape using projectUV(). On the window pieces, you can either insert geometry that already has UVs in which case those UVs will be used, or you can insert a primitiveQuad() which automatically has UVs on it, or you can assign UVs to the window shape using setupProjection(). Here's a simplified version of what Tutorial 6 does.
Lot -->
extrude(height)
comp(f) { front: Facade }
Facade -->
setupProjection(0, scope.xy, 1.5, 1) // setup 1.5m x 1m texture tiles across whole facade
split(y) { ~floor_height: Floor }*
Floor -->
split(x) { ~tile_width: Tile }*
Tile -->
split(x) { ~1: Wall
| window_width: split(y) { ~1: Wall
| window_height: Window
| ~1: Wall }
| ~1: Wall }
Wall -->
texture(wall_tex)
projectUV(0)
Window -->
i(window_asset) // uses UVs on inserted asset
texture(randomWindowTexture)
// alternative window option
Window2 -->
primitiveQuad // has UVs that stretch across quad
texture(randomWindowTexture)
// alternative window option
Window3 -->
setupProjection(0, scope.xy, '1, '1) // define UVs that stretch across scope of shape
texture(randomWindowTexture)
projectUV(0)