Texture alignment on pillars.

Tutorials and discussions about Mapping - Introduce your own ones!
Post Reply
Higor
Godlike
Posts: 1789
Joined: Sun Mar 04, 2012 6:47 pm

Texture alignment on pillars.

Post by Higor » Sun May 24, 2020 3:02 am

This tutorial is about getting perfect texture alignment on a pillar, the pillar can be full or partial, the only requirement is that all of the surfaces on the pillars should have the same horizontal dimensions.

This is all going to be about numbers, and to make sure everything is perfect you'll need to choose the amount of times the texture is going to be horizontally tiled over the pillar (as in, how many times the texture repeats around the pillar).

We have to make sure the result of the following equation has no fractions.

Code: Select all

OFFSET = NUMBER_OF_H_TILES * TEXTURE_SIZE / NUMBER_OF_PILLAR_FACES
As you can see, the size of the pillar is completely irrelevant.
Let's try a simple example:
Pillar_1.PNG
- Texture: 128 pixels.
- Pillar: 8 sides, radius=64, AlignToSide=True.
- Number of tiles: 2

Code: Select all

OFFSET = 2 * 128 / 8 = 32
In this case, offset has no fraction, and we can do perfect alignment here.

Once you figured out the 'OFFSET', we need to figure out the horizontal scaling.
In order to do so, we need to measure one of the pillar's sides, or calculate it if we can't directly measure.
The best way to measure is using clip markers snapped to the pillar's vertices.
You're better off disabling 'Drag Grid' and creating the clip markers somewhere other than the pillar you're working on, then moving each marker on the 3d viewport into two of the pillar's points you want to measure. The editor will then snap the markers to said points, make sure you have the pillar already built into the map or there won't be any snapping.
Pillar_2.PNG
Pillar_3.PNG
Pillar_4.PNG
Once you've created two clip markers as shown above, calculate the distance between said points (it's a lot easier if done over one dimension).
Considering the pillar of the previous example, the measurement of one of the faces results in:
- 53.019165
Pillar_5.PNG
Pillar_5.PNG (4.4 KiB) Viewed 148 times
Then we apply the following formulat to obtain the horizontal scale:

Code: Select all

H_SCALE = PILLAR_FACE_LENGTH * NUMBER_OF_PILLAR_FACES / (NUMBER_OF_H_TILES * TEXTURE_SIZE)
Given the data of our previous example, the formula looks like this:

Code: Select all

H_SCALE = 53.019165 * 8 / (2 * 128) = 1.656848
When we apply that scale to the texture (at least horizontally, vertical can be anything), we'll be able to apply the offset incrementally on each of the faces and end up with perfectly aligned textures on the pillar.
Select all of the pillar's side surfaces:
- Hit 'Unalign'
- Apply the 'H_SCALE' you just calculated.
- Apply to (U or V pan) OFFSET (32 on our example).
- Deselect one surface, apply offset again.
- Deselect another surface, apply offset again.
- Keep doing that until you're done with the surfaces.

Due to rounding of some numbers the results may not be 100% perfect but the texture alignment's precision will be down to the pixel.
Pillar_6.PNG
ImageImage
Image unreal://23.111.157.138:7777
Image unreal://46.228.199.205:7788

User avatar
papercoffee
Godlike
Posts: 9606
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Texture alignment on pillars.

Post by papercoffee » Sun May 24, 2020 3:23 am

I made this thread sticky.

User avatar
Swanky
Adept
Posts: 388
Joined: Sun Mar 16, 2008 9:06 pm
Personal rank: Brush Commander
Location: inside ze bocks
Contact:

Re: Texture alignment on pillars.

Post by Swanky » Sun May 24, 2020 12:13 pm

Note: 256² textures on a 45° angle have ~1.42 scale for alignment (I believe 1.4166666). That or half. Pretty handy number to know if you're texture aligning.

Quietus
Novice
Posts: 10
Joined: Thu Oct 11, 2018 6:01 pm

Re: Texture alignment on pillars.

Post by Quietus » Sun May 24, 2020 2:48 pm

Swanky wrote:
Sun May 24, 2020 12:13 pm
Note: 256² textures on a 45° angle have ~1.42 scale for alignment (I believe 1.4166666). That or half. Pretty handy number to know if you're texture aligning.
Not that you're a million miles out, but I'm sure when I tested the maths with this, it came to 1.414, or 0.707 if you're halving (great for diaginal trims). I recall it being an easy one to remember, as the numbers had a repeating pattern. :)

User avatar
Swanky
Adept
Posts: 388
Joined: Sun Mar 16, 2008 9:06 pm
Personal rank: Brush Commander
Location: inside ze bocks
Contact:

Re: Texture alignment on pillars.

Post by Swanky » Sun May 24, 2020 2:59 pm

Something like that. Shouldn't make much of a difference on 256 pixels, though.

User avatar
Feralidragon
Godlike
Posts: 5179
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Texture alignment on pillars.

Post by Feralidragon » Sun May 24, 2020 3:20 pm

This should be translated to a new alignment option in the new UEd. :)

User avatar
papercoffee
Godlike
Posts: 9606
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Texture alignment on pillars.

Post by papercoffee » Mon May 25, 2020 9:14 pm

Feralidragon wrote:
Sun May 24, 2020 3:20 pm
This should be translated to a new alignment option in the new UEd. :)
^^^THIS!!^^^

User avatar
Swanky
Adept
Posts: 388
Joined: Sun Mar 16, 2008 9:06 pm
Personal rank: Brush Commander
Location: inside ze bocks
Contact:

Re: Texture alignment on pillars.

Post by Swanky » Mon May 25, 2020 9:47 pm

Yeah, align to wall would be a dream.

User avatar
Barbie
Godlike
Posts: 1803
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Texture alignment on pillars.

Post by Barbie » Tue May 26, 2020 1:37 pm

Some more dreaming: select a surface, choose "Align to..." and click to the surface where the first selected surface should be aligned to - including rotation, scaling, mirroring, flipping.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Post Reply