Hey guys,
Been curious about this for a while, maybe someone here will know :
Over at Ubisoft, we have a Photoshop plug-in that does a few things with normal maps, I think it dates back to before Nvidia's plug-in. Anyway at home i often miss a particular feature this tool has. You could have it rotate a normal map at any custom angle, and it would somehow adjust all the channels for you so lighting wouldn't react wrong. This is an internal application and we can't transfer it out of the building.
The closest i can manage finding on the internet is actions that rotate at 90degree intervals. Anyone know of a custom rotation plug-in for normal maps in photoshop?
ps: I dream of one day being able to "free transform" any normal map element and have it automatically adjust the channels for you. *drool*.
Replies
Not sure about any kind of normal map rotation stuff, I'm also interested now.
Just tested it - Swapping the Red and Green Channels and inverting the new red channel appears to do the trick when rotating 90 degrees (CCW). It's easier said then done (and might vary based on the type of normal map), and it's a long way off from what you're suggesting, but it's a starting point.
All theory aside, if it were easy there would be a tutorial out there.
But where do normal maps come from? A hieght-to-normal black and white image or a bake from 3d geometry. Both methods are easily rotated making this not too terribly important, though i do agree it would be really nice to easily rotated normals in photoshop for speed's sake.
edit, ps this would be a pretty awesome tool tho :poly142:
I guess we could do that with javascript in photoshop, with a popup asking for the angle. It will probably be more complicated to have a visual feedback while editing (like it would with the transform tool).
In the meantime i wrote something you can use in maya. It has the advantage of taking the tangent space of your object into account, but using maya for this is really not the fastest.
I've seen that photoshop now support some sort of gpu accelerated filters, maybe there's something there
edit: Neox you've been faster there
I'd just re-bake at the correct rotation, if it's from 3D source.
Or as someone else said, if it's from heightmap data, rotate the heightmap then just run NVidia filter on it.
I don't know why you'd ever want to rotate existing normal data to arbitrary angles... if you're doing that then it sounds like something is wrong with your workflow?
Agreed, on character stuff it makes not much sense and can only cause a mess (would only work with Brice's tool, since it also updates the UVs...)
It's guaranteed to lose quality if you rotate normalmaps to arbitrary angles because of the resampling involved. Re-baking from source geometry ensures highest quality.
Rotating the heightmap will lose a bit of quality from the resampling too, but probably not as much as actually rotating the end-result normal map. It's an extra step but it doesn't require any plugins or scripts...
*hopes for someone to call me stupid and post a link to it since it might just aswell have been done already*
save every pixel in to a 2D Array with it's current R and G (and Value (B will not change).
R and G convert to a vector of 3 dimensions (while only 2 have a value, which is x for red and y for green and z is defined as following) with angle in dependence of theyr greyscale value that is alpha = (Greyscalevalue(of R or G)-128)*(90/128).
So your pixel array now saves two vectors for R and G there one points left and up and one points towards the top (of the image boundaries) and up.
These two vectors define a plane from which you extract the normal vector.
Now you turn the image by a given angle. All Normalvectors created as previous described shall be turned around the absolute Z-Axis and you do the steps described above backwards (create a plane, extract two directional vectors one on the horizontal line and one on the vertical line which now differ from the image boundaries and reconvert the steepnes with tangens to an angle which will then be converted to a greyscale value). Just let your application of choice create the image out of the now modified array (use pushMatrix and rotate or equivalent of your coding language) and you have a turned tangent space normal map.
going to code something like this but i'm in my exams phase at university for the next two weeks. if someone knows how to implent a processing written program (java) into photoshop this is an easy addon.
I think one lingering obstacle is you'd have to know what pixels of the rotated and bilinear interpolated version correspond to the original pixels of the layer - unless you handle it within the code - as well as the issue of speed for photoshop scripting. But it seems like the people who know the photoshop sdk are few and far between :poly124:
I'm curious though, since it's already been done by ubisoft. Three cheers for anyone who does it
I agree with Brice and MoP though, probably for now the best option is to go the rtt approach. if you apply your normal map into a normal map bump slot you can transfer recalculated normals onto another object's uvs pretty quickly
www.crazybump.com/NormalsTransformer.zip
Illustrative Screenshot:
may i ask what has been your approach on this?
too bad im using max =(. totally slipped my mind that you can transfer maps with rtt, so thanks for reminding me .
would have been sweet though to just check a box in the UV editor that attaches the different maps to the isles and moves them with the UV isles. well, gotta do it the "long" way then .
Sure!
I first used windows GDI+ to rotate the image.
Then, for every pixel:
newX = x * Cos(angle) - y * Sin(angle);
newY = x * Sin(angle) + y * Cos(angle);
normalize to length 127.5
translate components +127.5
www.crazybump.com/NormalsTransformer.zip
Edit: NEVERMIND, lol
Please make a photoshop plugin version of CB with this but linked directly somehow to the transform tool...i could die a happy man then :P
As for people questioning the usefulness of this, hard to describe examples in text... All i can say is not having that kind of option has caused me to NOT do things that could have added to a piece. Having it available at work has saved my butt a couple times. It's not every day workflow use but it has its occasions.
I'll keep an eye here for more progress on the photoshop integration!
Some cool programmer out there still trying for a solution inside PS?
Scripting wise I think it would go down something like working out the maximum angle before the Red and green fully swap or invert (I'm guessing 90 degrees), then taking the users chosen rotation and blending/inverting the channels by a percentage based on the percentage the rotation angle is of the maximum. If the required angle is past the maximum (90 degrees), and onto the next swap/invert blend (180 degrees) then it ets a little more complicated, but I think it could be done.
If I ever get time I'll look into it more, but don't hold your breath, it'll b a while if it can be done at all. A Plugin using similar code to Ryans would be the better option, but I don't do grown up code
A few weeks ago we introduced a new Normal image mode in PixaFlux, and fixed almost all nodes to understand the concept of normals:
The Transform node rotates the normals of the normal images.
This tutorial shows how to use this new feature in PixaFlux:
https://youtu.be/_iRX2g5YgrM
Please let me know if you have any suggestions about normal images.
Thank you
Normal map rotation tool (online)