Texture alignment on pillars.

Any kind of tutorial regarding U-Ed and mapping belongs here
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Texture alignment on pillars.

Post 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 2223 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
User avatar
papercoffee
Godlike
Posts: 10443
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 »

I made this thread sticky.
User avatar
Swanky
Adept
Posts: 462
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 »

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 »

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: 462
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 »

Something like that. Shouldn't make much of a difference on 256 pixels, though.
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Texture alignment on pillars.

Post by Feralidragon »

This should be translated to a new alignment option in the new UEd. :)
User avatar
papercoffee
Godlike
Posts: 10443
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 »

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: 462
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 »

Yeah, align to wall would be a dream.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Texture alignment on pillars.

Post 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.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Myth
Inhuman
Posts: 988
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Texture alignment on pillars.

Post 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.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Texture alignment on pillars.

Post 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.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Myth
Inhuman
Posts: 988
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Texture alignment on pillars.

Post 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.
User avatar
SteadZ
Average
Posts: 67
Joined: Mon Mar 10, 2014 11:19 pm
Personal rank: 1337
Location: Scotland
Contact:

Re: Texture alignment on pillars.

Post by SteadZ »

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
Bloeb
Experienced
Posts: 95
Joined: Tue Apr 06, 2010 11:07 am

Re: Texture alignment on pillars.

Post 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
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Texture alignment on pillars.

Post 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.
Post Reply