Page 1 of 2

Texture alignment on pillars.

Posted: Sun May 24, 2020 3:02 am
by Higor
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 2271 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

Re: Texture alignment on pillars.

Posted: Sun May 24, 2020 3:23 am
by papercoffee
I made this thread sticky.

Re: Texture alignment on pillars.

Posted: Sun May 24, 2020 12:13 pm
by Swanky
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.

Re: Texture alignment on pillars.

Posted: Sun May 24, 2020 2:48 pm
by Quietus
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. :)

Re: Texture alignment on pillars.

Posted: Sun May 24, 2020 2:59 pm
by Swanky
Something like that. Shouldn't make much of a difference on 256 pixels, though.

Re: Texture alignment on pillars.

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

Re: Texture alignment on pillars.

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

Re: Texture alignment on pillars.

Posted: Mon May 25, 2020 9:47 pm
by Swanky
Yeah, align to wall would be a dream.

Re: Texture alignment on pillars.

Posted: Tue May 26, 2020 1:37 pm
by Barbie
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.

Re: Texture alignment on pillars.

Posted: Sun Jul 05, 2020 11:10 pm
by Myth
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.

Re: Texture alignment on pillars.

Posted: Sun Jul 05, 2020 11:50 pm
by Barbie
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.

Re: Texture alignment on pillars.

Posted: Mon Jul 06, 2020 5:07 pm
by Myth
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.

Re: Texture alignment on pillars.

Posted: Tue Jul 07, 2020 2:34 am
by SteadZ
You guys might want to check this out: Cylinder Aligner tool by yrex

Re: Texture alignment on pillars.

Posted: Mon Aug 31, 2020 1:56 am
by Bloeb
You could also use my texture alignment tool. Download the script here: https://pastebin.com/4h7xDK2r. Save the text as a HTML-file and open it in your browser.

You can now also use the tool directly from my github-page: https://bloeb.github.io/ued_tex_align/u ... align.html

Re: Texture alignment on pillars.

Posted: Fri May 14, 2021 12:15 am
by sektor2111
I think I'll copy first topic with calculations and... I'll write a builder calculator type...
It will be bCalcTexPillars or something like this.
I'll think about...

EDIT:
Perhaps this is the final stage...
TCalculus.PNG
Easy and handy without ClipMarkers. Length of the face is calculated automatically due to CylinderRadius data known by user from source builder.