[Tutorial] Skewing textures in Hammer

Discussion in 'Tutorials & Resources' started by Crowbar, Jul 26, 2016.

  1. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,355
    Positive Ratings:
    1,023
    Imagine you have a slope in your corridor, with a piece of wall going up, like this:
    1.png
    What would you do for it to look prettier? Use a beam? Maybe. Use alt-right click feature to precisely rotate it and position it? Would rather work for beams, doesn't look as cool on the walls.
    But wait... there is actually a way to skew our textures! It has an extremely tricky workaround, but here's what we'll end up with today:
    2.png
    Flawless! Let me teach you how.

    We will need Camera tool. It's ignored most of the time, and it's really not much use during usual mapping, but here we're going to take full advantage of its ability to set camera and camera target point on-grid in 2d viewports.

    3.png
    This is how our 3d viewport's camera looks like in 2d viewport. We can drag both the camera itself (the blue circle), and its target point (the exact place that will be in 3d viewport center), keep it all on our current grid and manipulate it in all 3 2d viewports.
    Exactly what we need! Now, let's learn to position our camera properly.

    We start with the top-down view (assuming our wall is vertical):

    The orange brush is our skewed brush we work with;
    The green ones are the regular walls we don't really do anything with;
    The purple stuff is what I added to picture (line for measurement, a note that slope must be exactly 1:1):
    4.png

    Once we placed our camera this way by dragging the circle on one end of the red line and the other end of it, let's move to the viewport that lets us view our wall from right/left. In my case it's the Side viewport. From now we'll be moving these 2 camera conotrolling points only up and down, or otherwise we can mess up what we set up in the topdown viewport! Check afterwards that everything is right!
    5.png

    As you notice, the camera needs to be pointing at a steeper angle than our slope for this all to be working. This angle should be twice as steep as our original angle!

    Here I'll show you how to calculate our angle with ease.
    1. Make a triangle brush, the same slope as ours, like that: 5-1.png
    2. Resize it so it's exactly twice the height. The marker of the center of the side should be here: 5-2.png
    Now we can use the sloped part of the triangle to position the camera. Where the lower point of this side is will be where our camera is. Where the higher point is, will be its target point.
    After we have done it, the helper triangle brush can be deleted.

    We set the camera up! We still don't touch its position.
    Now where we need to go is the Texture application window, which we can bring up by Shift-A or this button: :faceedittool: in the tool window. Well, that's the very basics.

    Ever paid attention to this button?
    6.png
    This is the mode selection button. Rarely, if ever, used because the mode by default is what we need almost always. Not now though. Once the button is clicked, a list appears:
    6-1.png
    Let me explain what each mode is for.
    • Lift - once clicked on a face, its texture is shown in the small window at right.
    • Select - once clicked on a face, it is selected.
    • Lift + Select - combination of the above. Once clicked on a face, it is selected and its texture is shown. This mode is picked by default and is used the most.
    • Apply (texture only) - applies currently highlighted texture to clicked faces (values will be set default)
    • Apple (texture + values) - applies currently highlighted texture and selected values to clicked faces
    • Align to view - Aligns clicked face's texture to the camera of the viewport it's clicked in. This is what we'll use.
    Now, pick Align to view mode and click the face we're working with:
    7.png

    It's skewed perfectly now! We can from now move the camera and edit it so it actually fits. Some work still needs to be done.
    We'll need to find the number to scale the texture so the transition is flawless. Fortunately, Hammer is capable of that, thanks to Fit button. What do we do next:
    First we need to know the amount of units it takes to use 100% of our texture's height. For this, take its height in pixels and multiply the texture scale used on the straight, not skewed walls. Texture I am using is 1024x1024, and my scale is 0.25, so it will take 256 units to fully use the texture height. If your non-skewed wall are just as tall as needed, you can skip the next paragraph.

    My walls are 192 units tall (the straight ones) so we'll need to temporarily extend the skewed brush to fit it. Your wall might be taller than needed so you'll need to make it lower, it depends on texture and the scale.
    First let's make one of straight walls of needed height so we can use it as a reference:
    8.png
    Then use Vertex tool (selection tool will work improperly) ro rise/lower the top edge of the skewed brush:
    8-1.png

    And now that we're sure our wall fits needed height, we can Fit:
    9.png
    Hammer found us a perfect scale for the wall! Let's return walls back to the height they were. Copy the number from Y field to X field:
    9-1.png
    or you can leave 0.25 in X field for better alignment with straight walls.

    Now, the texture is upside down. Well it's actually just rotated by 180 degrees, so we can fix it by rotating it by another 180 degrees. Sometimes it may be actually flipped. I'm unsure that may happen, but if it's the case, add a minus (-) before Y value instead of rotating by 180 degrees:
    9-2.png
    Once we've done either of these operations, hit the button with the B letter on it to justify our texture to bottom (assuming straight ones are aligned to bottom and it's intended to be so. If you align your textures to top, click T.). That's somewhat how it should look after everything:
    10.png
    All we need to do now is align them by left-right which can be done by hands or you can use L and R buttons in certain cases.
    And we have a skewed wall with perfect transition. Happy mapping everyone!

    The guide is based on this one, but with few important additions and in a more popular place I guess.
     
    • Thanks Thanks x 10
    • Like Like x 2
    Last edited: Jul 27, 2016
  2. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,355
    Positive Ratings:
    1,023
    Suggestions are welcome. The guide isn't perfect obviously but I think followable.
     
  3. Blade x64

    aa Blade x64 Logical insanity

    Messages:
    197
    Positive Ratings:
    434
    • Thanks Thanks x 1
  4. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,355
    Positive Ratings:
    1,023
    You're right! Added the credit and warned about lightmaps.
     
  5. zahndah

    aa zahndah professional letter

    Messages:
    702
    Positive Ratings:
    584
    You would times it to get 256, not divide. Dividing by a number lower than 1 increases the value and multiplying by a number smaller than 1 decreases the value.
     
    • Thanks Thanks x 1
  6. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,355
    Positive Ratings:
    1,023
    What a misspell. 'course i meant multiply.
     
  7. Sergis

    aa Sergis L666: ])oo]v[

    Messages:
    1,866
    Positive Ratings:
    1,130
    what ive done a few times to skew textures is simply nodraw the face and put a flat non-skewed displacement over it, then displace the displacement so it fits exactly over the skew

    say my skewed brush is skewed by 64 units, i would make a power 2 displacement, then lift all it's edge vertices 64 hu to match the skewed brush, next row 48, middle row 32 and the next one 16 by using "raise to"

    also ive considered simply using overlays to the same effect but never actually tried to
     
    • Agree Agree x 2
    • Thanks Thanks x 1
  8. KubeKing

    aa KubeKing Daniel's Same Base

    Messages:
    1,157
    Positive Ratings:
    1,122
    I had no idea 'Raise To' was a thing. A lot more makes sense to me now.
     
    • Funny Funny x 1
  9. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,355
    Positive Ratings:
    1,023
    That works too and has been considered by me since, and is probably preferable. In somewhat defence of the way I have told about it's been invented in the days of GoldSrc and gets you a little more proud of the insane shit you could just pull off