Sign in to follow this  
kgy

self shadowing normal maps

Recommended Posts

I was looking for examples of self shadowing normal maps using bent normals computed from a height map. I came accross this old post on the topic I think he was somewhat mis-understood because he mentioned ao, but actually was just doing direct lighting using bent normals. Anyway, his code relied on some libraries, and didn't actually make new files, so I wrote something similar that just loads a heightmap and normalmap and outputs a new normalmap (and ao map too) This is also basically the same thing that valve did here: Efficient Self Shadowed Radiosity NormalMapping However, I wanted to do it with regular tangent space normal maps rather than ones in the valve basis. All this program does is modify the normal map, then when used with any kind of regular lighting, it appears to be self shadowed. (also notice, there is a bit of a light anti-shadow artifact on the non shadowed side of bumps as well) Here are a couple screens and the source code. It was written on a mac, but it should compile on anything. run it like: bender normal.tga height.tga 30 60 10 TGAs must be uncompressed. 3 numbers are raycast count, raycast length in pixels, and strength (0-100). For count/length, 30/60 gets good quality for me, but takes a minute or two, 10/20 is fast enough for iterating to select a good strength but doesn't look as good. It outputs the modified normals to bentnormals.tga (also outputs an ao.tga ambient occlusion map as a bonus, but that is not used in the screens shown here) code: bender.cpp screenshots: before: after:

Share this post


Link to post
Share on other sites
Interesting little project. I was actually looking for something like this, since I found that Valve's SS Bump maps don't play nice with DXTC. From my initial tests, I have determined that normals maps produced by this program don't exhibit any noticeable compression artifacts when using DXT5. They also work just as well when I convert them to partial derivative normal maps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this