Texture alignment on pillars.

Tutorials and discussions about Mapping - Introduce your own ones!
Post Reply
Higor
Godlike
Posts: 1792
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 327 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: 9631
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: 392
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: 392
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: 5194
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: 9631
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: 392
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: 1838
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

Myth
Inhuman
Posts: 975
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Texture alignment on pillars.

Post by Myth » Sun Jul 05, 2020 11:10 pm

Barbie wrote:
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.
I never knew I needed something so bad in my life...

I'll go and see if I can make it a reality.

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

Re: Texture alignment on pillars.

Post by Barbie » Sun Jul 05, 2020 11:50 pm

Take for example a threshold in front of a door entry. The two visible surfaces at the long side should be aligned properly, but they are too small to do that manually.
Other example is a complex brush where one surface consists of multiple triangles. What a senseless work and wasted time to align each of them.

The buttons "Align to..." didn't work proper for some reason in both examples.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Myth
Inhuman
Posts: 975
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Texture alignment on pillars.

Post by Myth » Mon Jul 06, 2020 5:07 pm

Yes!

Geometrically I think there are 2 cases:

- if the two surfaces are parallel, project the texture from source surface to target
- if they are not parallel, find intersection line and align the UV's to match on the intersection line

also, scaling should be transferred from source to target in every case.

So this should be fesable to implement, just have to work out the math.

User avatar
SteadZ
Novice
Posts: 17
Joined: Mon Mar 10, 2014 11:19 pm
Personal rank: A Person
Location: Scotland

Re: Texture alignment on pillars.

Post by SteadZ » Tue Jul 07, 2020 2:34 am

You guys might want to check this out: Cylinder Aligner tool by yrex
"The problem with dreams is... you never know when you're gonna wake up"

Image

Post Reply