Grayscale>Normal Map Convertor?
Community Forums/Developer Stations/Grayscale>Normal Map Convertor?
| ||
Is anyone aware of any grayscale heightmap to normal map convertors apart from Nvidia's Photoshop plugin? It really messes up badly with Photoshop CS1 and CS2, and I don't want to go back to PS7 if I can help it. Preferably something which includes a scale, as Nvidia's plugin does, because I like being able to temper or ramp up the scale of bumpiness as suits the texture. |
| ||
hey check my sig :) |
| ||
Somebody is working on (from what I've seen of it so far) a pretty impressive tool regarding normal maps. I can't say any more about it because its not my place, but I'll give him a nudge about this thread. |
| ||
Nice broken links. I wrote this, just now. It produces slightly different results than NVidia's TGA2Dot3, but it's mathematically correct. file$="C:\Program Files\BlitzMax\samples\birdie\misc\lightImage\media\B-max.png" pixmap:TPixmap=LoadPixmap(file$) pixmap:TPixmap=CreateDOT3(pixmap,2.0) SavePixmapPNG(pixmap,StripAll(file)+"_DOT3.png",9) OpenURL StripAll(file)+"_DOT3.png" Function CreateDOT3:TPixmap(pixmap:TPixmap,contrast#=1.0) bumpmap:TPixmap=CreatePixmap(pixmap.width,pixmap.height,PF_RGB888) For x=0 To pixmap.width-1 For y=0 To pixmap.height-1 tl#=-1.0 tm#=-1.0 tr#=-1.0 ml#=-1.0 mm#=-1.0 mr#=-1.0 bl#=-1.0 bm#=-1.0 br#=-1.0 If x>0 And y>0 tl#=(pixmap.readpixel(x-1,y-1) & $000000FF) If y>0 tm#=(pixmap.readpixel(x,y-1) & $000000FF) If x<pixmap.width-1 And y>0 tr#=(pixmap.readpixel(x+1,y-1) & $000000FF) If x>0 ml#=(pixmap.readpixel(x-1,y) & $000000FF) mm#=(pixmap.readpixel(x,y) & $000000FF) If x<pixmap.width-1 mr#=(pixmap.readpixel(x+1,y) & $000000FF) If x>0 And y<pixmap.height-1 bl#=(pixmap.readpixel(x-1,y+1) & $000000FF) If y<pixmap.height-1 bm#=(pixmap.readpixel(x,y+1) & $000000FF) If x<pixmap.width-1 And y<pixmap.height-1 br#=(pixmap.readpixel(x+1,y+1) & $000000FF) If tl=-1.0 tl=mm If tm=-1.0 tm=mm If tr=-1.0 tr=mm If ml=-1.0 ml=mm If mr=-1.0 mr=mm If bl=-1.0 bl=mm If bm=-1.0 bm=mm If br=-1.0 br=mm vx#=0.0 vy#=0.0 vz#=1.0 isq2#=1.0/Sqr(2.0) sum#=1.0+isq2+isq2 al#=(tl*isq2+ml+bl*isq2)/sum ar#=(tr*isq2+mr+br*isq2)/sum at#=(tl*isq2+tm+tr*isq2)/sum ab#=(bl*isq2+bm+br*isq2)/sum vx#=(al-ar)/255.0*contrast vy#=(at-ab)/255.0*contrast Rem m#=Sqr(vx*vx+vy*vy+vz*vz) vx=(Sgn(vx)*vx)/m vy=(Sgn(vy)*vy)/m vz=vz/m EndRem r=vx*128.5+128.5 g=vy*128.5+128.5 b=vz*255.0 If r<0 r=0 If r>255 r=255 If g<0 g=0 If g>255 g=255 If b<0 b=0 If b>255 b=255 rgb=b+(g Shl 8)+(r Shl 16) WritePixel bumpmap,x,y,rgb Next Next Return bumpmap EndFunction |
| ||
[quote] It really messes up badly with Photoshop CS1 and CS2 [/quote}] ? We use it all the time here at work with our CS2. Works perfectly. |
| ||
Sorry for bringing this topic back up again. Apologies for the broken links. They are back up again :o) |
| ||
I usualy create greyscale to normal maps in 3dsmax using render to texture. Just stick the greyscale in the bump channel of a max material and it it does a pretty good job. I used the photoshop plugin too and the only problems I have had is that ATI and Nvidia invert the Green on Y from one another which can mess some shaders up. |
| ||
Sorry, forgot all about this thread. Thanks to everyone, and particularly Ross for the excellent timing because I just realized I needed this now, and I've just grabbed it. I can't believe it I never noticed it in your sig before. Thanks again. |
| ||
Actually, been having problems with your convertor, Ross. It leaves some strange artifacts which is ok, but it messed up my graphics drivers when it quits. My screen remains completely black and I can't get the desktop back without opening and closing task manager. So I gave Josh's BMax proggy a try and that works great. Thanks Josh! Mustang: Yeah, it works great for me too. Except that when I go back to do anything BUT convert to a normal map and the images are completely arsed up. Never used to happen on PS6 or 7 but has done with both CS1 and CS2. |
| ||
Hmmm, it shouldn't be doing that :S I'll need to double check i'm not Writepixel-ing fast into memory. Thanks for the heads up :o) |