Wednesday, October 19, 2005

Back to HLSL Shaders

After taking a break for a few months to learn some MaxScripting, I've jumped back into shader writing. So far I've mainly been focusing my efforts on figuring out the best and least expensive way to do normal mapping in shaders written to work in the viewport of Max 8.

Up until now I've been using the vertex shader to put all the vectors in tangent space. Doing all of the lighting calculation in tangent space worked pretty well for Max 7, but when I was beta testing Max 8 I found that the tangent space lighting was causing some very strange lighting artifacts to show up around UV borders. After seeing this, I went back to Max 7 and realised that the same artifacts were there in 7 as well - just not as prominent. I have no idea what was causing these artifacts, but I posted them as a bug. I don't know if the issue was fixed since I haven't gotten my copy of the final version of Max 8 yet.

Anyway, to get around the problem, I'm now converting all of my normal map shaders so that they do their lighting in world space. This seems to be working very well. Putting vectors in world space is much cheaper for the vertex shader, and the lighting annomalies that I saw with my previous tangent space lighting are gone. Of course, the offset mapping shader has to stay the way that it was since offset mapping requires that the view vector be in tangent space.

I was excited to see that the problem I posted before with the normal map seams at UV borders is fixed in Max 8. Nice! They've also solved the UV mirroring problem, so now you can have mirrored UVs and the normals all work correctly. Max 8 will be very nice to work with because of these fixes.

I plan on posting the newer versions of my normal mapping shaders soon as well as some additional shaders that I've been working on.

Since I'm back on the topic of shaders, I really need to mention that Joel Styles has posted a really sweet skin shader on his site. If you're looking for a nice HLSL skin shader that works in Max, this is it! Nice job, Joel.


Anonymous Anonymous said...

haha thanks ben! :D

Good stuff on your findings with the normal mapping vector problems too.

October 25, 2005 9:29 PM  
Blogger Vassago said...

I haven't checked your blog in some time, so I missed this post. I had started a thread at Polycount yesterday, concerning this same thing.

The end resolution was the same as you have come up with. Here's the link, if interested:

Good work Ben, can't wait for those updated FX files :D

October 27, 2005 12:42 PM  
Anonymous Anonymous said...


thanks for sharing your textures. they are really outstanding.

October 29, 2005 2:09 PM  
Anonymous Anonymous said...

I stumbled upon your textures just now, some of them are really good, but i didnt find any of them to have a large enough resolution, it would be nice to see some larger images

October 30, 2005 5:33 AM  
Blogger Ben Cloward said...

Wow, Nick. You must need some pretty high res textures. Those usually don't come for free. I've got all of the original images of my textures. They start out at 6.2 mega-pixel, but I scale them down so the file size isn't as high. If there's a specific one that you'd like at a high res, just email me and tell me which one you want and I'll send you the original.

October 31, 2005 8:16 PM  

Post a Comment

<< Home