With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
For all you mappers out there!

Moderators: Joe Kari, Pardner, TheDoctor, Breli

Rotate texture via shader script?

Postby Pardner » Mon Jun 14, 2010 7:06 pm

Does anybody know if it is possible to rotate a texture within a shader? I would like to match my texture blending with my non texture blending. Here is a screen of what I mean:
[thumb=http://forum.smokin-guns.org/userpix/357_shot0022_1.jpg][timg]357_shot0022_1.jpg[/timg][/thumb]

Red box:
  • separate func_group
  • texture rotated to 0deg using the surface editor in GTK

Green box:
  • separate func_group
  • texture rotated to 90deg using the surface editor in GTK

As you can see, rotating the texture in the editor has no effect in game. My next idea was to rotate the texture in the shader script, but to my dismay there was no such function.

Then I thought I could use tcMod rotate with 0 deg/sec with an initial phase.... but tcMod does not have an initial phase option.

I did look into tMod transform but I did not find much information:
Code: Select all
Transform is a function generally reserved for use by programmers who suggest that designers leave it alone.

tcMod <transform> <m00> <m01> <m10> <m11> <t0> <t1>
Transforms each texture coordinate as follows:

S' = s * m00 + t * m10 + t0
T' = t * m01 + s * m11 + t1

This is for use by programmers.


Anybody have any ideas? :|
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby ReD NeCKersoN » Mon Jun 14, 2010 9:55 pm

Does anybody know if it is possible to rotate a texture within a shader?

Sounds like maybe you're having a brain fart? :lol:
The texture rotation of your ground is controlled by your texture blend shader, right?
Example:
q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
*Think of that as ( x y z ) (x y z)

Rotating the textures in Radiant won't work because the blend shader overrides this. If your entire ground surface is assigned to a single shader, then the alignment of the texture will be the same throughout the level. You could try copy/paste the blend shader, rename it appropriately, change the rotation in the q3map_tcGen ivector, and apply this 2nd shader where needed. But my guess is that you'll notice something that looks like a seam in game where the 2 ground blends meet.

I know what you want to achieve because I've run into this exact scenario. The only thing I can think of to do is:
Plant bushes/grass, build structures, or place objects to hide what it is you don't like. If you try the 2 shader idea, maybe you could have it so that the seam isn't a straight line? Might look less obvious that you're trying to hide something... I dunno. Let us know what you come up with please.
Image
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby Pardner » Mon Jun 14, 2010 11:01 pm

Brain fats imply that I would need to have at least air in my head first. I knew there was a way, just didn't remember/realize that is what q3map_tcGen ivector was for.

Before and after (quick test)


[thumb=http://forum.smokin-guns.org/userpix/357_shot0022_1.jpg][timg]357_shot0022_1.jpg[/timg][/thumb][thumb=http://forum.smokin-guns.org/userpix/357_shot0018_2.jpg] [timg]357_shot0018_2.jpg[/timg][/thumb]

It is an improvement, but I do have hard lines. I don't think I will be able to get rid of the hard lines. The ground was made in EG but I hand made and hand textured the rock walls.

I also found this:
Code: Select all
tcGen vector (<sx> <sy> <sz>) (<tx> <ty> <tz>)
New texcoord generation by world projection. This allows you to project a
texture onto a surface in a fixed way, regardless of its orientation.

S coordinates correspond to the "x" coordinates on the texture itself.
T coordinates correspond to the "y" coordinates on the texture itself.

The measurements are in game units.

Example: tcGen vector (0.01 0 0) (0 0.01 0)
This would project a texture with a repeat every 100 units across the X/Y plane.


This sounds identical to q3map_tcGen ivector, but it can be applied to individual stages in the shader. This would be nice so I could fix the sand as seen in the screenshots, but rotate the red rock texture 90deg.

Unfortunately, initial tests proved disastrous. Will keep testing
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby ReD NeCKersoN » Mon Jun 14, 2010 11:18 pm

Of course, the easiest thing to do is just pick a different texture for the cliff walls. One that doesn't have horizontal or vertical patterns.
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby Pardner » Mon Jun 14, 2010 11:19 pm

true true.... always a good option. Maybe I could get a texture that matches one of those spiffy new skyboxes.
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby Pardner » Mon Jun 14, 2010 11:29 pm

AAaahaa I think I got it (still not pretty)
Code: Select all
tcGen vector (<sx> <sy> <sz>) (<tx> <ty> <tz>)
New texcoord generation by world projection. This allows you to project a
texture onto a surface in a fixed way, regardless of its orientation.

S coordinates correspond to the "x" coordinates on the texture itself.
T coordinates correspond to the "y" coordinates on the texture itself.

The measurements are in game units.

Example: tcGen vector (0.01 0 0) (0 0.01 0)
This would project a texture with a repeat every 100 units across the X/Y plane.


Code: Select all
q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 ) will project the texture every 256  units in x, and every 256  units in y, along the z-axis. Ivector means inverse vector, and this means you don't have to do the divide with windows calc. :)

ivector ( 256 0 0 ) ( 0 256 0 ) == vector ( 1/256 0 0 ) ( 0 1/256 0 )

inverse = 1.0 / n, unless the value is 0. If the value is 0, then the matrix value is set to 0. A bit of dodgy math, but it works.


q3map_tcGen ivector inverts the values while tcGen vector does not. I should have read more carefully...
ivector ( 256 0 0 ) ( 0 256 0 ) == vector ( 1/256 0 0 ) ( 0 1/256 0 )

so here is the shader with q3map_tcGen ivector:
[thumb=http://forum.smokin-guns.org/userpix/357_shot0018_2.jpg] [timg]357_shot0018_2.jpg[/timg][/thumb]

and here it is with tcGen vector:

[thumb=http://forum.smokin-guns.org/userpix/357_shot0019_1.jpg][timg]357_shot0019_1.jpg[/timg][/thumb]


Progress....
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA




Return to Level Editing

Show Sidebar
Show Sidebar

User Control Panel

cron