World-Aligned Road Texturing

374
1
01-18-2019 02:23 AM
BernhardRainer1
New Contributor III

Hello, 

I'm working on a road rule file that does texturing based on the world position of the shape in order to minimize texture discontinuities. I'm using the GetMapData function to retrieve the road layout and. However, the world-space uvs do not line up for multiple street shapes and are shifted in curved shapes. 

The following code is used: 

RoadAsphalt -->
   setupProjection(0, world.xz, 4, 4)
   projectUV(0)

   translateUV(0, -OffsetX/4, -OffsetZ/4)
   scaleUV(0,1,-1)

   texture("builtin:uvtest.png")X.

OffsetX/Y/Z is the centroid of the scene (without it single-precision uvs have trouble)

Does anyone have an idea on how to get continous UVs over multiple shapes?

Cheers, 

Bernhard

0 Kudos
1 Reply
CherylLau
Esri Regular Contributor

Using world.xz would be the way to set up the projection, but unfortunately when the scene contents are far away from the origin, there are some problems with floating point precision.  This is why you get the results above.

  • With setupProjection(0, world.xz, 4, 4), the texture is blurry.
  • Adding an offset in setupProjection(0, world.xz, 4, 4, 525363, -5221099), fixes the blurry textures, but the textures are discontinuous.  (Offset numbers are taken from your screenshot).

While we investigate the problem and see if we can fix it, there is a not-so-nice workaround to get continuous textures on the street shapes which are far away from the scene origin.  This workaround imposes some limitations though (e.g. no more dynamic shapes, no more separate shapes).

  1. Convert the street shapes to static shapes (Graph -> Convert to Static Shapes)
  2. Combine the shapes into a single shape (Shapes -> Combine Shapes)
  3. Apply setupProjection using scope instead of world.
0 Kudos