Buzzy's 3dsMax DirectX Shaders
Latest Update 5/01/09
New Shader, codenamed 'Bleach' (for reasons I'll explain in a moment):
- Improved Vertex Color and Alpha support
- Tweaked the glow system to reduce blown-out glowing
- Added Light Attenuation (not yet linked to the lights' actual attenuation settings, but very good for moody lighting)
- Added Fresnel Highlights
- Added some simple subsurface scattering (nice alliteration, eh?)
- Added 'glowthru' subsurface scattering
- Half-Lambert is now tied to the alpha channel of the SSS map for added control
- Added a "Bleach Bypass" filter. Hence the shaders name. This is by no
means the marquee feature, its just a nifty little addition.
This shader is still a bit raw I feel, so I wanted to get it into your hands and see if you folks can exploit it to the point of breaking. So test the heck out of this and give me some feedback. With DomWar going on, I'm sure you all have nearly-complete characters to use as guinea pigs. ;)
Important Info Concerning All Shaders
Any of the reflective shaders require DDS format cube maps for the environment. Since alot of folks don't know what a cube map or DDS is (or how to make them), here are a few samples that you can use:
Blurred version of Desert Scene (Good for brushed metal look)
I would like to encourage any of you to post images of work you've created with these shaders. Particularly when I start posting some of my more advanced shaders, I'd be very interested to see how you can get the most out of them. Hope you enjoy them!
Each shader has a 'No-Shadows' counterpart. Versions of Max prior to 2008 don't support shadows, so you'll need the no shadow version if you have Max9 or something.
NEW! COMPLETE SHADER - (requires Pixel Shader 3.0)
LAST UPDATED 4/13/09 - Version 1.1 Improved glow and added Vertex Color support
LAST UPDATED 1/30/09 - 4 lights and proper opacity support.
GLOW SHADER - (requires Pixel Shader 3.0 support for now)
LAST UPDATED 1/30/09 - 4 lights and proper opacity support.
Note: Still has one odd little bug, but I've not been able to fix it yet. Most people will never notice it anyway.
ENVIRONMENT SHADER - (requires Pixel Shader 3.0)
LAST UPDATED 1/30/09 - 4 lights and proper opacity support plus Fresnel reflectivity.
SKIN SHADER - (requires Pixel Shader 3.0)
LAST UPDATED 12/5/08 - first pass at skin.
Note: The skin shader has a lot of advanced features. For an explanation of them go HERE.
GLASS SHADER - (requires Pixel Shader 3.0)
LAST UPDATED 12/14/08 - first pass at glass.
TOON SHADER - (requires Pixel Shader 3.0)
LAST UPDATED 11/30/08 - first pass at toon shading.
Note: The outline part of the code is a bit shaky right now so the 'Line Thickness' setting is currently inactive.[/url]
Here's a quick explanation of the basic features available in all of my shaders. First, for those of you that have no idea how to even get a shader onto a model, here's a quick tut:
Bring up your Material Editor. Choose a material that you would like to be a DX Shader. Now in the top right there is a button that probably says "Standard" (circled in red here). Click that and you'll be presented with the menu pictured on the left. Choose "DirectX Shader" from that menu.
Voila, your material is now a shader. Now, to make it a specific shader (like the one you just downloaded from this thread) click on the big button at the top, circled here in red.
This is a path to an .fx file. So, find the one you like and select it. There are actually a bunch that ship with Max, but they are mostly for demonstraion and not all that useful.
So, once you've loaded my shader, your Material Editor will turn into this:
Now, let me explain what all of this means (most of it is pretty self-explanatory)
First, lets actually start at the bottom. The Material slot can pretty much be ignored. But, if you have an insatiable thirst for knowledge, this is a separate material that Max will use to display your model if you disable DirectX or if you try to render the scene (DirectX shaders don't render, but they really don't need to)
More importantly, at the bottom is also an option for "Technique." You have 2 options here, SingleLight and DualLight. This will tell the shader how many lights to use to light your model.
Now, back at the top, you'll see there are slots where you can specify lights and shadow casters. These, obviously, are where you specify what lights to use. If you have the Technique set to Single Light, then only "Light Position 1" and "shadowCaster1" will matter. Generally you will want the Light Position to match its cooresponding shadowCaster.
Below the lights, there is a slew of map options. First are the Diffuse Map options. This will set the color of the model. There is a "Diffuse Map" and a "Diffuse Color." If you check the box that says "Enable Diff Map" then the shader will use the Map you have selected in the Diffuse Map slot. If you uncheck "Enable Diff Map" then the shader will just use the color that you've selected in the Diffuse Color slot.
The same applies for the Specular Map. The spec map however, also has a few extra options for Glossiness. This shader is set up so that the alpha channel of the Spec Map can be used to control glossiness. If you do not want that option, you can just uncheck the box and use the spinner to control glossiness.
Next is the Normal Map. The only tricky thing here is the "Invert Green Channel" option. Basically, Max uses a somewhat oddball coordinate system. Because of this, your normal map's Green Channel needs to be inverted depending on how you generated your normal maps. So, if you select a normal map and it looks a little weird, try using this option.
You can also turn on "Half-Lambert" lighting. This is a little trick developed by Valve a long time ago. It basically softens the lighting, giving a more appealing but less-accurate look.
I forgot to mention something important. This shader doesn't create its own shadows, it uses Max's internal shadow calculations. Therefore, you must have shadows enabled in the viewport for the lights you want to use.
Another point I should make : This shader has only been tested on Max2008. I can't say whether it works with any other version. This probably only pertains to the shadow casting, because everything else is just HLSL code and has nothing to do with Max.
On that note, this shader uses Pixel and Vertex Shader 3.0. If your video card does not support either of these, then this shader won't work.
I'm not sure that the shader really NEEDS to be 3.0.....it doesn't use any crazy advanced stuff so I can probably get away with 2.0. I'll look into that post an update later.
Ok, ignore the previous comments about Pixel Shader 3.0. I have just updated the file so it uses Pixel Shader 2.0. Now, if your video card does not support Pixel Shader 2.0...then....well....you need a new video card.
I've had a quick fiddle with this - very nice.
that shadow code looks very much like the code I put into another shader that made my work machine crash - I've got new graphics hardware now though so it's all good for me :)
had any joy with Alpha channel support on the diffuse?
Yeah, honestly Max seems to have issues with alpha...particularly when sorting. I haven't really worked on the alpha much with this shader, so I'm not sure how well it works in the current version.
The biggest source of sorting issues in Max is how it structures the scene. Objects are sorted internally based on the order in which they were created (not by name or heirarchy). And Max's directX engine doesn't render the things based on distance like a game engine would, it renders each object seperately. And it draws them in the order they are sorted in the scene - i.e. the order they were created. So, if you have an object that was created earlier and it is in front of an object that was created later, the alpha won't work correctly.
Alpha is admittedly a major drawback in this shader. I'm still working on it though. Hopefully I can improve it.
That'll go a long way to explaining why the hair on my witch went funny during that last comp.
I'm guessing here cos I'm not up on HLSL at all but can you turn off the alpha blending and fall back to a simple alpha test?
I've not seen anyone get sorting right on alpha blended geometry without shattering objects into individual tris yet - assassins creed, farcry 2 etc all use simple alpha tests for their foliage and it looks fine til you get right up close.
Wow, neat, you are the dude. I've been meaning to get into shaders and this looks like a perfect place to start. Thanks dude... now you would be the dude meister if you were to put up a tut for the rig you did on your awesome warrior hint hint.
Edit:Pant's, I just tried your ace looking shader but can't seem to get it working in 3dsmax 9 (not 09) I noticed you did mention that this is for 2008 and probably above. Looks like its upgrade time or am I just plain stupid and can't get it to work? Doesn't matter though. Thanks for the shader, I'm sure I'll get it working sooner or later :)
you need the viewport shadows for it to cast shadows so you need max 2008.
There's no shortage of non-shadow casting .fx materials floating around. Ben cloward has released one that works in lots of max versions.
Cheers poopipe. Downloaded them all now, will give them a bash. Really want to get a skin shader working. Just in case anyone else wants a go, here's the link: http://www.bencloward.com/resources_shaders.shtml
Hey Chung, I'll spend a few minutes today and make a version of this shader with the shadows disabled for people with pre-2008 versions of Max.
And I'll see if I can get my skin shader to an acceptable state and post it too. It has alot of experimental tech in it and I'd love to get it out to the public and see what people can come up with.
Ok, here's a version with all of the shadow code removed. Should work on Max9 but no guarantees. I don't have max9 on my computer anymore so I can't test it myself. Let me know if it works Chung
Sweet, thanks buzzy. I'll let you know later on tonight.
Edit: Nice, it worked, I couldn't get it looking as nice as your warrior though, could seem to get the fuzzy see-through like texture to happen, any idea's why? I like the shader a lot, just seems that I'm missing something and not making the most out of it. But anyway, here's what came out...
I hacked a version with Ambient and Glow maps in today
I'd upload it but it's a dirty hack and requires SM3 to support all the calculations - they're just simple adds (I multiplied the ambient value by 0.3)
I'm having difficulties on 2009 with the alpha not working - any clues?
here's my dom war entry looking all shadowy and glowy
I think that looks pretty awesome Chung.
And nice glowiness poopipe.
I think I'm going to spend some quality time today working on the alpha and blending code....see if I can't come up with anything better. Hopefully I can address the issues you two have. I also spent some time yesterday going over my skin shader and I should be able to post that soon....hopefully tonight if I'm feeling super motivated.
Yes please! I love this shader and looking forwards to more exellent shaders from you. Just so I know what I'm doing, am I right in saying that these are real-time and what you see on screen is what you get? Therefore if I need a shot, I just make a screen grab and not a render? Sorry for the silly questions. Btw, I have a piece of finished work and have credited you. Thanks a bunch!
|All times are GMT. The time now is 02:31 PM.|
Powered by vBulletin®
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
all images displayed on this site are copyright the original artists and may not be reproduced, copied or published elsewhere without their express permission