Hey to all,
I have been trying to make a material in which I have a texture that Pan's, however, I wasn't too happy with the Pan's direction, so I decided to rotate the direction in which it Pan's.
However, for some reason, it seems like I have forgotten how the blighted function works in me telling the material in which direction to Pan, anyone could tell me how it's done?
I recall it had something to do with adding.
Cheers and ciao.
Replies
feed the output into your textures UV's
Rate is uv units per second. Positive U is right to left, positive V is up to down.
You can also rotate it in the shader. Use a rotator node, plug that into the uv input for the texpanner. Leave the center at 0.5, and rate to 3.141592, then plug a constant into time. every 0.5 value of the constant = 90 degrees rotation.
Thanks alot guys, worked like a charm.
EDIT: Hmm, I was wondering if it can be used for the Normal Map also this function? I just tried it, and for a lack of better terms, my normals information get's flipped when I spin it 180.
Is there anything I can do to avoid this issue?
If you need to you can add 1 to your normal map, multiply it by -1 then add 1 again to invert it. (since its from the range of -1 to +1)
And yes if you put the panner before the rotate it will first move the UV's THEN rotate them. This is evaluated for every frame, so you'll get some really funky behaviour.
Cheers and sorry for double post.
To do this I'd set up a manual panner. A panner is just UV's added to time. This way you can insert all kinds of parameters into the shader.
Awesome, and I was able to keep it Scalar and not Parametric since prior it's faster.
However, I'm still unable to get rotate correctly. I created a Radian to Degree workaround with the which is essentially ((# * Pi) / 180), but I think it's causing me some issues. What's the best way to create a manual rotate originally so I can control the XY Centers?
Some basic concepts you'll find handy.
Vectors and scalars play nicely. Any basic aritmetic operation between a vector and scalar applies the operation to each element of the vector.
Vector vs vector operations require the same number of elements, as their elements are matched up for the operation.
an off center rotation of a texture is a combination of a movement (translation) of where you want the center to be to the origin, rotating it by how much you want to rotate, then moving it back.
So for a totally custom rotation setup you'll need to get into some matix multiplication, which, while a fun way to kill time (if you like number crunching), is a bit tedious to set up as unreal nodes.
From what I can gather that you are trying to do is have a texture you can rotate to some angle, at some arbitrary centerpoint, then pan it in an arbitrary direction.
(I'd make you a digram but I have no UDK here. Work blows. ) So here's a text solution.
Custom Rotation Block
{
UV coords node & 2 vector [centerpoint] -> add node -> rotator (center at 0,0 rate at 1), Scalar[rotation angle] with degree to radian conversion nodes into rotator time
[centerpoint] * -1 and Rotator_out -> Add }
Pan section
{
TIME, 2vector {Pan Rates) -> Multiply -> Add to, custom Rotation Block output
}
-> texture UV's
Also Ace, you're definitely inspiring me to make a set of video tutorials on shader mathematical concepts, not just you though, but it's a helpful reminder that not everyone who digs into making shaders and effects has dug into linear algebra and vector mathematics.
Also, thank you for all the help, really good stuff, and much appreciated mate.
You're pretty much spot on the issue, however, I'm essentially trying to make a Switch between two modes of rotating.
One is a time controlled, essentially it rotating normally, around the axis. Another is, as you said, Rotate by n degree and Pan.
I was able to tame the Pan parameters, so as Sprung said, I can do anything I want to do with it now, but Rotator is a no go since everytime I try something, it end up with a new issue, even having some kind of sine movement in my rotate on the UV scales.
Just to post an image of what I mean since I got dizzy from all the spinning, gonna be a while before I go back and try out your solution.
OH also of note: The order of operations with rotation and panning matters A LOT.
Lets say you have tank treads textured on a ball, (or some such) and you want them to rotate to face the direction of movement, then pan along that direction, you will need to have your panning before your rotating.
If you want to have say.. a chainsaw made of buzz saws, then you'll want your rotate before your pan. and yes you may get some funky effects if the rotation center isn't in the center of the UV layout (usually .5 .5).
Edit: ... and now I want to go make a spherical tank with chain-buzzsaw arms...
An example of what I mean is the TexCoords works fine with the Append in place and are much faster then a 2 Vector, but in my Pan (the manual one Sprung mentioned), without the Masks, only the R works under append.
So basically, anything I make under 'manual' and not a ready made function, including my custom Fresnel, needs to have the mask components if I need to control specific channels under scalar, or else they don't work for single scalars, and I'm trying to only use scalar since it's much faster, don't know why, but my UDK scene lags whenever I try accessing the 3 scalars.
Also, I'm not sure, but UDK was compressing my normal maps really badly (EI: I couldn't work with them since they showed really bad artifacts) so I used an Uncompressed settings when I imported them, and so far, it looks like even if I flip my normal maps 180 in my rotation, they still do read out correctly, and I was hoping if anyone could tell me if this is normal (pun intended).
One last thing, is there a recommended way to hard mask the fresnel in UDK without any kind of map? Here is my current fresnel:
PS: +1 to Rasmus on said...also, tuts would be nice ;P
HLSL wise the component mask is equivalent to the swizzle operator (.) so a green mask is just variable.g
a float value, a scalar, doesn't HAVE a g channel by definition.. so it has to be cast to a float3 or float4 then operated on by the swizzle, then modified into the new vector via the append. I immagine the UDK compiler can compress the overall set of nodes that are irrelevant.
Float3's SHOULD be faster than a collection of floats, as your GPU has dedicated vector units, and allocates memory better for vectors than scalars (if I recall).
And I get what is going on in your manual fresnel term there.. but not really the why. The blue constant you have in there will give really wierd results when used as a tangent space normal, and without the inversion from the cam vs normal dot product its not really a fresnel like effect.
As far as the normal maps go.. you'll want to use normalmap_noAlpha compession usually. it shouldn't artifact badly.
If you don't do that, then make sure to check out the texture properties and change the unpacking minimum to -1 on all channels, otherwise your normal data will be off. Though it would likely account for its insensativity to rotation.
A normal map is essentialy a set of offsets for the surface normals at a given pixel. The data range is from -1 to +1, but that has to be specified, either at the engine or shader level. If you don't do either your range is only from 0-1 and your vector length may be more than 1 (hence you normalizing your normal map for good results).
Also, what do you mean "hard mask the fresnel" ?
I'll see about tossing some together in the next couple days. I had a couple dry runs put together a while back, but they didn't flow at all, so I'll need to script things a bit better and do some show-prep.
edit: Removed random iphone typo
And again, I'm not sure why, but single channel Scalar's are faster for me for some odd reason. I will try updating UDK and see if anything changes, but even my Instance Material lags for a couple seconds when changing while scalars fly off the bat right away. Pretty sure something funky on my end. Will check and see.
The Fresnel is indeed funky, I did the entire invert thing to fake the sun shining on my mesh, and the blue number I input was just me being silly and testing out what effect values which aren't rounded have.
As for the hard mask, well, I don't know how to call it, it's essentially a hardened rim light which is controlled by the Z normals, but I think images will serve better.
Been trying to achieve this effect for a while, but couldn't reach it.
Its one thing I'm definitely covering in those video tuts.