View Full Version : 'Normalize' normal map after editing in PS
NoradNinja
2007.10.22, 01:03 PM
Ok, here is the deal, I am using the method shown here (http://www.cgtextures.com/content.php?action=tut_normalmap) (http://www.cgtextures.com/content.php?action=tut_normalmap) to recover large scale normal map data from photos with NormalMappr and CS3. The problem is, as noted after step 7, that the blue channel is more or less gone after all this editing, and the texture needs to be normalized to recover the blue channel (as said in the article, 'The reason for the normalize step is a bit complicated. In short, the normalmap is a texture which contains the 'normal vectors' of the surface. The direction of each vector is defined by the red, green and blue channel, the length of the vector is always equal to 1. Because we have been changing the colors, the values might no longer be correct. The normalize step solves this problem, it will make sure each vector has a proper length of 1.')...the problem is, they use the NVidia normal map PS plugin to do this. Now, I do own a Mac Pro and COULD install Windows, and PS, to do this ONE step, but I would much rather not, as it would be a real hassle to go thru all of that for something like this. Not to mention I don't want to repurchase CS3. Can anyone tell me of a reliable way to 'normalize' the normal map on the Mac side of things?
aarku
2007.10.22, 02:21 PM
Read you loud and clear. That is a nice technique, too! We just upgraded to CS3 and it looks like it supports JavaScript scripts... I'm going to look into writing a script to do this, that will just normalize the RGB values of each pixel as if they were a Vector3. Hopefully you can make JavaScript filters. (Obviously they'd be slow, but who cares..)
Does that sound right?
-Jon
ThemsAllTook
2007.10.22, 02:26 PM
It wouldn't take much effort at all to write a small utility program that reads a PNG, normalizes the color components in each pixel, and writes it back out... If you haven't found an easier way, I'll try whipping one up when I get home.
aarku
2007.10.22, 02:31 PM
Looks like there isn't a way to do a filter from a script. I'm out. :)
-Jon
Najdorf
2007.10.22, 04:36 PM
Sorry for the OT, but you say "Not to mention I don't want to repurchase CS3": I think you can install it also on windows without having to buy it again, after all it's on the same computer.
reubert
2007.10.22, 04:45 PM
Looks like there isn't a way to do a filter from a script. I'm out. :)
-Jon
You can run the script from the script menu, doesn't really need to be a filter does it?
aarku
2007.10.22, 05:03 PM
You can run the script from the script menu, doesn't really need to be a filter does it?
No indeed, but looking at the scripting reference I couldn't find a way to get at the actual pixels of a layer. I would sure like to be wrong about this. It looked like the scripting only let you do things similar to what Actions can do.
http://www.adobe.com/devnet/photoshop/pdfs/photoshop_cs3_javascript_ref.pdf
Cheers,
-Jon
NoradNinja
2007.10.22, 05:14 PM
Sorry for the OT, but you say "Not to mention I don't want to repurchase CS3": I think you can install it also on windows without having to buy it again, after all it's on the same computer.
My issue is more one of not wanting to have to fracking restart my machine just to perform this one step in the process. Also, I will want to be able to do this multiple times for each texture so that I can ensure the level of detail I recover from the photo is correct for the effect I am trying to achieve.
Read you loud and clear. That is a nice technique, too!
Yeah, its a fantastic method for doing this sort of thing, saves me all kinds of time from modeling detail I don't want to have to if I can avoid it. zBrush is great, but the less time I can spend in there, the more time I can spend developing content!
It wouldn't take much effort at all to write a small utility program that reads a PNG, normalizes the color components in each pixel, and writes it back out... If you haven't found an easier way, I'll try whipping one up when I get home.
This would be great, as I am not a programmer, but rather an asset artist, so anything I can do to shorten my workflow pipeline, the better!
ThemsAllTook
2007.10.22, 05:17 PM
Done!
Binary: http://www.sacredsoftware.net/temp/NormalizePNG.zip
Source: http://www.sacredsoftware.net/temp/NormalizePNG.c
Usage: ./NormalizePNG inputFile.png outputFile.png
Let me know if that does the trick.
NoradNinja
2007.10.22, 05:19 PM
Done!
Binary: http://www.sacredsoftware.net/temp/NormalizePNG.zip
Source: http://www.sacredsoftware.net/temp/NormalizePNG.c
Usage: ./NormalizePNG inputFile.png outputFile.png
Let me know if that does the trick.
You, my friend, are the MAN. I will let you know how it works out, would you mind if I hosted this on my webserver?
NoradNinja
2007.10.22, 05:47 PM
I believe the darks on the blue channel need to be darker...here are some flickr links to show what I mean. I will load both versions of the texture, one without correction and one after, into a normal map in Maya and let you know, ill post renders of both here.
After normalization script without correction:
http://farm3.static.flickr.com/2351/1695896199_dd16369a49.jpg?v=0
After normalization script with correction (Image>Adjust>Auto Levels on Blue channel):
http://farm3.static.flickr.com/2351/1695896215_ce01a740f5.jpg?v=0
ThemsAllTook
2007.10.22, 06:34 PM
Whoops, I definitely messed up. Wasn't thinking right when I wrote the normalization algorithm. Fixing...
NoradNinja
2007.10.22, 06:42 PM
Whoops, I definitely messed up. Wasn't thinking right when I wrote the normalization algorithm. Fixing...
I did a render test, left side is before correction, right side is after...altho the differences are nominal, they are there. Thanks for working on a fix.
http://farm3.static.flickr.com/2016/1696773347_bb099d0a32_o.png
ThemsAllTook
2007.10.22, 06:56 PM
New binary and source posted. Redownload from the same links as posted above. I'm not 100% sure the new version is accurate, but it's certainly closer than the old one... Let me know if it works.
NoradNinja
2007.10.22, 07:10 PM
New binary and source posted. Redownload from the same links as posted above. I'm not 100% sure the new version is accurate, but it's certainly closer than the old one... Let me know if it works.
Thank you so much, that works perfectly.
New comparison image, old algorithm on the left, new one on the right. Again, minor differences, mostly in the specular details, but the difference is there if you are looking for it.
http://farm3.static.flickr.com/2272/1698013704_ceadf5ae5b_o.png
NoradNinja
2007.10.22, 07:13 PM
Just curious, what would have to be done to make a simple interface for this (say, a well to drop the input image into and a button to do the conversion and save the image to a file?)
ThemsAllTook
2007.10.22, 07:27 PM
Just curious, what would have to be done to make a simple interface for this (say, a well to drop the input image into and a button to do the conversion and save the image to a file?)
Putting together a simple Cocoa front end wouldn't be particularly difficult, but it's a bit more than I'm up for at the moment. Maybe sometime later, or if anyone else wants to try, feel free.
Glad it works! It was a fun little diversion to write.
NoradNinja
2007.10.22, 08:45 PM
Putting together a simple Cocoa front end wouldn't be particularly difficult, but it's a bit more than I'm up for at the moment. Maybe sometime later, or if anyone else wants to try, feel free.
Glad it works! It was a fun little diversion to write.
Thanks for doing it, you have saved me a lot of hassle. :D
I may try putting a front end together, if I have any trouble, I will get back here to see what I need to do.
Skorche
2007.10.23, 04:12 AM
You could use Platypus to bundle it together with a script. I've done that before. Very simple.
NoradNinja
2007.10.23, 11:19 AM
You could use Platypus to bundle it together with a script. I've done that before. Very simple.
Ok, can you help me with this? I'm not sure quite what to do, I have added the command line app to the Resources in Platypus, but I guess I need an applescript to execute that calls the command line app...I'm not sure how to proceed from here (again, not a coder...)?
NoradNinja
2007.10.23, 03:39 PM
Also, i found a great Photoshop action here (right click, save as) (http://www.rodgreen.com/downloads/OffsetActions.atn) to combine fine detail normal maps generated with NormalMappr and the large scale detail maps made with this method to recover ALL the detail from the image, all you have to do is paste the fine scale map into a new layer in the large scale map and run the action, then disable the fine scale layer and flatten the image, it looks great and gives you the best of both methods! Once I am done, I will post a workflow method I have come up with for doing this as well as baking ambient occlusion data into the shader, it makes for super realistic surfaces with relatively simple (ambient, spec, normal) shaders that look great on a broad range of hardware.
NoradNinja
2007.10.23, 04:25 PM
A render of the rock surface with the large scale detail and the fine scale detail normal maps combined. Quite pleased with the appearance, what do you guys think?
Image link (http://www.flickr.com/photo_zoom.gne?id=1714162853&size=o)
PatrickA
2007.10.24, 08:26 AM
Thats pretty good, but it won't tile. Is it seamless?
TomorrowPlusX
2007.10.24, 09:18 AM
I'm a little late to the party, but I see references to "NormalMappr" -- and I'm wondering if you're referring to the app I posted here a few months back ( http://idevgames.com/forum/showthread.php?t=14114 ). I'm just curious if it's my app, since it would bring a little ray of happiness to my day...
Today's my last day in my 20's... I'm getting old.
NoradNinja
2007.10.24, 01:08 PM
I'm a little late to the party, but I see references to "NormalMappr" -- and I'm wondering if you're referring to the app I posted here a few months back ( http://idevgames.com/forum/showthread.php?t=14114 ). I'm just curious if it's my app, since it would bring a little ray of happiness to my day...
Today's my last day in my 20's... I'm getting old.
;)
Of course it is your app. I absolutely love it, btw. Between you and ThemsAllTook, you guys have saved me from having to either install Boot Camp/WindowsXP/Photoshop on my Mac Pro as well as making it so I can use my PPC TiBook to generate normal maps on the road. Seriously, thanks, I could really have used this stuff when I was in Uni and am very happy to have it now.
So, now that I have you here, if ThemsAllTook is cool, can you roll the functionality of his command line app into NormalMappr? I would basically need to be able to load an already generated map into the program and use say a checkbox to 'normalize only' the image (see the top post tutorial link for the reason and an example of how Nvidia does it in their PS filter).
Here is a sample of the work I do, couldn't have done it without your app.
Real time road sign (http://www.flickr.com/photo_zoom.gne?id=1729962745&size=o)
NoradNinja
2007.10.24, 01:12 PM
Thats pretty good, but it won't tile. Is it seamless?
Nah, I just used this as a test to get the method for editing the normal map in PS down. If I needed it to tile, I would have fixed the source image up before doing the normal map process.
Thanks for the comment...I went to Fullsail and got a degree in Computer Animation. They taught us some game stuff in GCSD (Game Scene and Character Design) about halfway thru the program, but all this stuff I have had to learn on my own after school.:ninja:
TomorrowPlusX
2007.10.24, 02:16 PM
;)
So, now that I have you here, if ThemsAllTook is cool, can you roll the functionality of his command line app into NormalMappr? I would basically need to be able to load an already generated map into the program and use say a checkbox to 'normalize only' the image (see the top post tutorial link for the reason and an example of how Nvidia does it in their PS filter).
I think I could do that. I'll have to consider how to gracefully integrate it into the GUI, however. I can see two options:
1) Open an already made normal map, and just have a button to normalize it. Easy enough.
2) Add a "normalize" button to the normal map generator gui, such that you can normalize it while creating it.
As a user of my app, how do those sound?
Here is a sample of the work I do, couldn't have done it without your app.
Real time road sign (http://www.flickr.com/photo_zoom.gne?id=1729962745&size=o)
That's the most ill-treated road sign I've ever seen. You making a silent hill game? :p
NoradNinja
2007.10.24, 02:23 PM
Option one would be the best, as I would be opening a normal map that had been edited in PS after generating it with NormalMappr. The issue is that the editing screws up the blue channel, and the normalize function is to correct for this. Option two would be moot, because NormalMappr already generates a normalized map, again, it is only after editing this map that the normalization needs to be corrected.
As for the sign...I don't want to give anything away, but the game is being designed with scaring the crap out of the player in mind;)
TomorrowPlusX
2007.10.24, 02:26 PM
Ah, that makes much more sense to me. Hell, I'll read the article more closely. Perhaps I can put the whole pipeline into NormalMappr...
( provided of course your initial image is tileable )
NoradNinja
2007.10.24, 02:33 PM
Ah, that makes much more sense to me. Hell, I'll read the article more closely. Perhaps I can put the whole pipeline into NormalMappr...
( provided of course your initial image is tileable )
That would be groovy, although because the amount of blurring you have to do to each layer varies depending on the source image as well as the number of layers, it may be difficult to create a 'one size fits all' solution...maybe if there were sliders to adjust the number of layers as well as the amount of progressive blur...
Also, it wouldn't really make a difference if the image was tileable or not, the method is the same either way:ninja:
BTW, you wouldn't have to put the whole pipeline in, but man, if you did that...you would be the MAN.
OT, the more we talk about this, the more I want to send you $5-10 as a donation for your work. Do you have a way I could do this? Not trying to bribe, but seriously, I appreciate your work and wouldn't mind giving a bit to encourage your further development.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.