Texturing split floors and roofs.

726
5
10-13-2020 10:58 AM
BenHammer1
New Contributor

About 10% of the time the bottom floor texture doesn't repeat to the second floor. Is there a way to ensure the same texture is used for all floors? See image below. I also noticed my roof texture doesn't follow the edge where the roofline meets the facade. I'm using v 2020.0

Thank you

0 Kudos
5 Replies
by Anonymous User
Not applicable

You will have to share your CGA code if you want a good answer.  

BenHammer1
New Contributor

Thanks, Brian. Here is the code.

/**
* File: Res_Rule.cga
* Created: 14 Oct 2020 19:16:56 GMT
* Author: bhammer
*/

version "2020.0"

@Range (min=0, max=3, stepsize=1)
attr LOD = 0

@Range (min=3, max=6.25, stepsize=.25)
attr BldgHeight = 4

const RandomFacadeTextureRES = fileRandom("/San_Saba/assets/Facades/Residential/Window/*")
const RandomFacadeTextureRES_NoWindow = fileRandom("/San_Saba/assets/Facades/Residential/NoWindow/*")
const RandomWindowTextureRES = fileRandom("/San_Saba/assets/Windows/Residential/*")
const RandomRoofTextureHIP_RES = fileRandom("/San_Saba/assets/Roofs/Residential/Hip/*")
const RandomDoorTexture = fileRandom("/San_Saba/assets/Doors/*")

BasementTex = "assets/Facades/Basement/Facade_Basement.jpg"

Lot -->
extrude (BldgHeight)
Mass

Mass -->
Residential

Residential -->
case LOD == 0 :
comp(f)
{all: Res}
case LOD == 1 :
comp(f)
{top : ResTop |
side : ResSide |
bottom : Basement
}
case LOD > 1 :
comp(f)
{top : ResTop |
left : ResLeft |
right : ResRight |
front : ResFront |
back : ResBack |
bottom : Basement
}
else :
comp(f)
{all : Res}

Res -->
color("#FF6767")

ResTop -->
ResRoofHip

ResRoofHip -->
case LOD > 2 :
roofHip(15,.5)
setupProjection(0, scope.xz, 8, 8, 0, 0, 0)
texture(RandomRoofTextureHIP_RES)
projectUV(0)
else :
roofHip(15)
setupProjection(0, scope.xz, 8, 8, 0, 0, 0)
texture(RandomRoofTextureHIP_RES)
projectUV(0)

ResSide -->
case LOD == 1 :
ResWallWindow
case LOD >= 2 :
case geometry.height < 4.25 :
split(y)
{ 2.5 : ResFloor |
~3 : ResWallNoWindow
}
else :
split(y)
{ 2.5 : ResFloor |
{~3 : ResFloor}*
}
else :
ResWallWindow

ResWallWindow -->
setupProjection(0, scope.xy, 3, 3, .5, 0, 0)
texture(RandomFacadeTextureRES)
projectUV(0)

ResFloor -->
// case LOD == 1 : ResWallWindow
case LOD > 2 :
split(x)
{ 1 : ResWallNoWindow
| { ~2.3 : ResWindowTile }*
| 1 : ResWallNoWindow
}
else: ResWallWindow

ResWallNoWindow -->
case LOD == 3 :
s('1,'1,0.4)
t(0,0,-0.4)
primitiveCube()
setupProjection(0, scope.xy, 3, 3, .5, 0, 0)
texture(RandomFacadeTextureRES_NoWindow)
projectUV(0)
else :
setupProjection(0, scope.xy, 3, 3, .5, 0, 0)
texture(RandomFacadeTextureRES_NoWindow)
projectUV(0)

ResWindowTile -->
split(x)
{ ~1 : ResWallNoWindow
| 1 : split(y)
{ ~1 : ResWallNoWindow |
1.55 : ResWindow |
~1 : ResWallNoWindow
}
| ~1 : ResWallNoWindow
}

ResWindow -->
case LOD == 3 :
s('1,'1,.15)
t(0,0,-.1)
i("builtin:cube")
setupProjection(0,scope.xy,scope.sx,scope.sy)
texture(RandomWindowTextureRES)
projectUV(0)
else :
s('1,'1,-1.0)
t(0,0,0)
setupProjection(0,scope.xy,scope.sx,scope.sy)
texture(RandomWindowTextureRES)
projectUV(0)

ResLeft -->
case geometry.height < 4.25 :
split(y)
{ 2.5 : ResFloor |
~3 : ResWallNoWindow
}
else :
split(y)
{ 2.5 : ResFloor |
{~3 : ResFloor}*
}

ResRight -->
case geometry.height < 4.25 :
split(y)
{ 2.5 : ResFloor |
~3 : ResWallNoWindow
}
else :
split(y)
{ 2.5 : ResFloor |
{~3 : ResFloor}*
}

ResFront -->
case LOD > 1 :
case geometry.height < 4.25 :
split(y)
{ 2.5 : ResGrndFloor |
{~3 : ResWallNoWindow}* }
else :
split(y)
{ 2.5 : ResGrndFloor |
{~3 : ResFloor}* }
else : ResGrndFloor

ResBack -->
case LOD > 1 :
case geometry.height < 5 :
split(y)
{ 2.5 : ResFloor |
~3 : ResWallNoWindow
}
else :
split(y)
{ 2.5 : ResFloor |
{~3 : ResFloor}*
}
else : ResWallWindow


ResGrndFloor -->
case LOD == 1 :
split(x){
~1 : ResWallWindow |
1 : ResEntTile |
~1 : ResWallWindow
}
case LOD == 2 :
split(x){
~1 : ResWallWindow |
1 : ResEntTile |
~1 : ResWallWindow
}
case LOD > 2 :
split(x){
~1 : ResWindowGrndFloorTile |
1 : ResEntTile |
~1 : ResWindowGrndFloorTile
}
else :
split(x)
{1:ResEntTile}

ResEntTile -->
split(x){
~1 : ResWallNoWindow
| 1 : ResDoor
| ~1 : ResWallNoWindow
}

ResWindowGrndFloorTile -->
split(x){
~1 : ResWallNoWindow
| 1 :
split(y)
{ ~1 : ResWallNoWindow |
1.55 : ResWindow |
~1 : ResWallNoWindow
}
| ~1 : ResWallNoWindow
}*

ResDoor -->
case LOD == 3 :
s('1,'1,0.1)
t(0,0,-.2)
texture(RandomDoorTexture)
primitiveCube()

else :
s('1,'1,-1.0)
t(0,0,0)
setupProjection(0,scope.xy,scope.sx,scope.sy)
texture(RandomDoorTexture)
projectUV(0)


Basement -->
extrude(3)
comp(f)
{side:
BasementFacade |
bottom: NIL |
top: NIL
}

BasementFacade -->
setupProjection(0, scope.xy, 10, 15, 1, 0, 0)
texture(BasementTex)
projectUV(0)

0 Kudos
by Anonymous User
Not applicable

For the texture switch issues, I think you have the texture switch for windows set at different Y heights for different faces. Make sure they are all the same Y heights.  That's my hunch.  Or maybe you are refering to your LOD2.  I think you are referencing the wrong texture on that.

For the roof, I think you might be looking at the 0.5 overhang on LOD2 for the RoofPlane?  Set that to 0.  That's my guess at your issue.

Let me know if that helps.

0 Kudos
BenHammer1
New Contributor

Hi Brian,


Thank you for looking over the code. The problem seems to occur at LOD2, when I switch to LOD3 the textures are all correct.

I checked the Y heights and made sure they were all the same. Still having the same issue.

-Ben

0 Kudos
CherylLau
Esri Regular Contributor

From what I read, I think you want the texture on the first floor to be the same as the texture on the second floor.  When LOD=2, this is not always the case.  Here is why.

For example, when BldgHeight=4 (default value) and LOD=2, the first floor is textured in the rule ResWallWindow with the texture RandomFacadeTextureRES, and the second floor is textured in the rule ResWallNoWindow with the texture RandomFacadeTextureRES_NoWindow.  The first and second floors, therefore, have different textures in this case.

Tip:  You can use the Model Hierarchy (Window -> Model Hierarchy -> Inspect Model) to see which piece of code generates a certain part of the model.  Click on a part of the model in the viewport, and its corresponding node will be highlighted in the Model Hierarchy.  Double click on that node to go to its corresponding rule in the cga code.

This screenshot of your rule applied to a footprint shows what I mean by first (pink) and second (blue) floors.  The lowest floor is the underground (basement) part of your rule.

With regards to the roof problem you mentioned, I'm not sure what you want to happen with the roof.