Jump to content
The Dark Mod Forums

Skewing texture coords


LDAsh

Recommended Posts

I know this is possible and I vaguely even remember a "hidden" dialogue in the editor which was like a matrix of texcoord values to screw around with, and we were able to skew textures (precisely) instead of simply rotate them, but this was many years ago. I can't remember if it was the built-in editor for Doom or even GtkRadiant.

It can be done by editing the .map file in a text editor, like so:-

{
( 0 0 1 0 ) ( ( 0.125 0 0 ) ( 0 0.125 14 ) ) "caulk"
( 0 1 0 -512 ) ( ( 0.125 0 50 ) ( 0 0.125 40 ) ) "caulk"
( 1 0 0 -536 ) ( ( 0.125 0 1 ) ( 0 0.125 0 ) ) "caulk"
( 0 0 -1 -192 ) ( ( 0.125 0 0 ) ( 0 0.125 50 ) ) "caulk"
( 0 -1 0 -512 ) ( ( 0.125 0 14 ) ( 0 0.125 56 ) ) "caulk"
( -1 0 0 528 ) ( ( 0.001953125 0.0025 0 ) ( 0 0.001953125 0 ) ) "texture"
}
This last line, the 6th value, I changed to from 0 to 0.0025 and it skews the texture vertically but not horizontally. I can't figure out how to get a precise angle like 45' or 22.5' and to keep the proportions and texel-scale of the texture, which is really important.

There's a lot of reasons to do this, like to avoid the "sawtooth" artifacts on things like hazard-stripe, etc, or to help avoid tiling on some organic materials, or to make sure all texels are used on a large texture that won't fit completely onto the brush.




Link to comment
Share on other sites

You can use the Texture Tool to do this on patches, but not on regular brushes. Trying to move just 1 vertex will move the entire quad, so skewing the texture is impossible.

 

Turns out this "matrix dialogue" I was dreaming about was actually in Q3A Shader Editor, the "tcMod transform", which could skew textures via the shader script. Stupid faulty brain and its phantom memories. I could swear something similar was in a Radiant somewhere...

 

After some more experimenting, I can get the angles correct by rotating the texture, saving, and then text-editing the map file and removing one of 2 values the rotation is stored as.

_______________________________________________________________________________

 

original:-

( -1 0 0 528 ) ( ( 0.001953125 0 0 ) ( 0 0.001953125 0 ) ) "texture"

 

rotated:-

( -1 0 0 528 ) ( ( 0.0013810679 0.0013810679 0 ) ( -0.0013810679 0.0013810679 0 ) ) "texture"

 

skewed:-

( -1 0 0 528 ) ( ( 0.0013810679 0 0 ) ( -0.0013810679 0.0013810679 0 ) ) "textures"

_______________________________________________________________________________

 

So the vertical angle is now exactly 45' but the texel-scale is not correct. Trying to adjust it in Radiant with the surface inspector breaks the skewing and it becomes rotated again, and trying to make sense of these numbers with text-editing is mind-bending, although I'm sure there'd be a way to do it.

 

Could this be an interesting enough technique to warrant a feature request for upcoming DarkRadiants?

Edited by LDAsh
  • Like 1
Link to comment
Share on other sites

You can shear the textures in the material definitions iirc.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Now that I've ruminated on this, I think the typical workflow is:

 

1) Create your brushwork and texture

2) Create a patch with the desired geometry and skew the textures

3) Paste from 2 to 1

 

I can see that it would be cool to avoid these additional steps. I would add this to the wish list thread:

 

http://forums.thedarkmod.com/topic/3499-wishlist-for-darkradiant/

 

or 2.0.4 dev thread:

 

http://forums.thedarkmod.com/topic/19073-darkradiant-240-pre-release-testing/

 

for further feedback.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Copy and paste the "shader" from a patch won't work because it would be the UVs that are causing the skew, not the surface properties. Making a separate material for every skewed variation doesn't sound like the optimal approach, either. I will just keep trying to figure out how this number "0.0013810679" possibly relates to 45'. :P If it would be made into a DarkRadiant feature, I guess the same mathematical formula would need to be worked out, anyway.

Link to comment
Share on other sites

 

I will just keep trying to figure out how this number "0.0013810679" possibly relates to 45'. :P

 

 

Well, that is simple. The brush definition (google helps ;) ) looks like this:

// plane equation x-coordinate of transformation y-coordinate of transformation texture
( -1 0 0 528 ) ( ( 0.0013810679 0 0 ) ( -0.0013810679 0.0013810679 0 ) ) "textures"

So (-1 0 0 528) is the plane equation defining the surface.

-1*x + 0*y + 0*z = 528

This is the normal form of a plane equation. There are other ways to specify planes, but this method has the advantage that the coefficients equal the surface normal (if normalized). So from the equation I can tell that the surface is facing towards the west (left side in top view in DR).

( ( 0.0013810679 0 0 ) ( -0.0013810679 0.0013810679 0 ) ) describes the transformation of the uv coordinates.

post-11230-0-08831900-1505891399_thumb.jpg

The matrix is a product of two matrices of which one handles the size change of the texture (stretching and shearing) and the second one handles the rotation and mirroring. That you have a 45° angle can be seen by the fact that the absolute values of your matrix entrees are all the same.

 

More info on the math can be found here for example: https://en.wikipedia.org/wiki/Transformation_matrix

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Okay, I already understand that rotation is achieved by skewing both axes of the UV and that's originally why I started toying with those values, and it's a very impressive-looking post, but didn't actually provide any useful practical information about how to translate the values between texel-scale and rotation. I should have been more specific, the rotation is not really the issue by itself - it's rotation that matches the texel scale of other textures, that's the important thing.

 

Using slow tweaking methods, I have some numbers that seem pretty precise and do what I want:-

( -1 0 0 256 ) ( ( 0.001953125 0 0 ) ( -0.000977 0.001953125 -0.125 ) ) "texture"

"-0.000977" to skew and "-0.125" to readjust it vertically to match its neighbouring brush.

 

This is using a scale of 0.125 and will vertically skew the texture 22.5' (actually it's 26.5' because we're dealing with 8s and not 10s, best I can explain it) so that for every repetition of the surface, the skew is aligning the texture half-way, so it won't perfectly align again after double that width. So what that means is, if you have a 2048x2048 texture and the surface is only half that height, showing only 1024 rows of texels, you can show the entire texture along double the horizontal scale by skewing it vertically, and the texels will align and match up again after what would take 4096 columns of texels, and you could say you have 1 unique texture that is actually double the width and it's also not wasting anything.

 

The numbers are tweaky guess-work and 0.000977 is not going to be precise over vast-distances, there's obviously a few more decimal points needed there, but lines up pretty well for what I need. Seams will not be noticeable unless doing it over vast distances.

 

Ultimately, the best solution would be to just use the "patch mesh over flush caulked brush" trick, or just use an external modelling program and import a mesh, then you'll have easy precision without text-editing the map file, if that wouldn't cause any issues.

 

http://www.violae.net/temp/skewy_brushes.jpg

Link to comment
Share on other sites

Turns out this "matrix dialogue" I was dreaming about was actually in Q3A Shader Editor, the "tcMod transform", which could skew textures via the shader script. Stupid faulty brain and its phantom memories. I could swear something similar was in a Radiant somewhere...

 

 

 

Maybe I'm just really dumb but after looking that up I see that all tcmod does is rotate, scale, scroll, stretch and transform.

Most of those are done in the surface inspector, Scroll would be done in Material definition of a texture though.

 

post-529-0-67916500-1505911917_thumb.png

 

EDIT: oh you're trying to skew a texture. I see.

You can do it with patches just not brushes in the editor.

I always assumed I'd taste like boot leather.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
×
×
  • Create New...