Everything one might need to understand the shader is available in the file. Please go ahead and try it!
Currently confirmed working for 3DS Max and Maya 2009+
Hey guys! I went ahead and worked with Ace-Angel, and I rewrote the shader from scratch. That being said, we're going to call this version 2.0+ since it's a complete overhaul.
Features:
-Half-Lambert Diffuse Term with controllable Falloff!
-Additive Rimlighting for make your models pop!
-Phong Specular, non-of-that-Blinn-nonsense!
-Fresnel Ranges from heaven to sea!
-Specular Warp
-Mask support, AS SEEN ON DOTA2!
-All them fancy effects Valve uses!
Changes in Version 2.3
-Changes: Specular and diffuse calculation combined
-Changes: Removed "Custom Fresnel Ranges" for specular and rim terms
-Changes: Reworked "Fresnel Color Warp"
-Changes: Alpha test culling
-Bug: Fixed sRGB read on diffuse/albedo texture and output final lighting in linear color space
-Bug: Fixed some issues with diffuse warp, and other warps. UVW Adresses were not set to "CLAMP" causing artifacts to show ( 3DS Max )
-Added: "Fresnel Warp" texture sampler. This is also known in the .vmt as $fresnelwarp ** NOT to be confused with $freselcolowarp **
-Added: Specular warp
-Added: Option to toggle on Mask 1 and Mask 2, with ideal default values
-Known Issues: Weird issue with diffuse warp( Maya ), strange lines on the model when using IBL cubemap( Maya )
Replies
Did you try it out? I can't confirm which versions of Maya it will work for, but the code *should* work for Maya and Max from 2008+
If it's throwing an error or anything, screenshot it, and I'll see what I can do.
EDIT: In the mean-time, I compiled a new version for Maya, if you or anyone else could test it out: http://www.mediafire.com/?0ckd4vlvjtgupe7
Will try it out now, always wanted that world peace setting, takes it up a notch
https://dl.dropbox.com/u/8510078/DOTA2_Hero_Shader.rar
http://drewwatts.net/shaders/DOTA2_Hero_Shader.rar
When I made the glow map slightly brighter so nothing was completely black, then it worked which makes sense of course.
Hope you can shine some light on what I might be doing wrong, using 3ds max 2011 x64 btw.
also is there a reason for specular strength to go into "-" since it does not seem to make a difference.
Cheers Drew, will update the first post ASAP!
Ah yes, due some complications with the compiler (I'm using a program called ShaderFX), the user it forced to have at least 1 light source in their scene.
You'll notice that there is also a lack of Ambient slot :P
If you want I can try and find a way to make it work if you need to, in the meantime, simply pop in at least one light source, set it above the character and voila, it should work.
As for the - numbers, I have no idea what happened there, I clamped them between 0 and upwards, I'll fix that ASAP and upload a new version as soon as someone can test the Maya version (if not, I will test them MUCH later on).
Took a look at your code really interesting, trying to learn some stuff myself
Did you guys enable disable Nitrous or Gamma LUT, anything like that?
Did you guys fillout all the slots, including the Ramp map with the TF2 texture that is provided?
Mind posting an image with the material next to the model?
I know that Sven has some problems (EI: The model is too dark), but in general you guys shouldn't be having all these issues, or at least 'see' something and don't need to fill out all the slots.
Try there, there compiled differently, and I made some very tiny changes:
https://www.dropbox.com/s/sznmo2e33o8otoj48b/Standard.fx
https://www.dropbox.com/s/uygm3fiflcl4e6tot5/CG.cgfx
I'm sorry for all the trouble peeps!
What does this mean?
Many people who try and replicate Valve-like-shaders, end up using Blinn instead, which makes a huge difference in the look of it.
Don't worry, I wasn't saying Blinn is inferior, they both have a place and time to be used
EDIT: For those interested, I made an update, check it out.
Feature wise it looks awesome, but would you mind uploading a reference asset with textures and maybe a screenshot of all the corresponding values ? I have been trying the Max .fx in Max2009 here and even tho things seem to be happening (I can tell that my textures are loading properly, and so on) I couldn't quite tweak the values to get something satisfactory.
Also on a side note : Maya2008 doesn't load the CGFX. Not that this is a problem at all - but I thought I'd mention it!
Thanks!
Might be helpful?
Also, to avoid these uninitialized value problems, it's best to have switches/booleans that make sure there's a proper default value.
I'll upload a separate folder with examples in it, download that and check it out (I hope Valve is OK with that, I'll use one of the more 'older' models like Sven).
And thanks! I'll add the info in the Readme about Maya 2008!
Aaaah frack it, I guess I'll put in Enable/Disable option then, cheers!
Yep, that's heavy code alright, in DOTA2 they did abit differently, as in you either Fresnel Warp a texture (can't confirm if it's an add/lerp or multi), or default to a single color like a traditional rim-light for lower end systems.
The keyword here is lower-end systems, since they're trying to pop out as much detail as possible without using fancy more then needed outside of basic math (so they keep the specular head-on for many characters, especially pronounced if you enable Specular Bloom).
I wish I could use a pure Schlick-with-Blinn honestly, pity
I was thinking of doing that, but Lumonix recently 'closed' down (they moved with Autodesk), so I can't say if I'm allowed to share the SFX files or not (don't want to get in any trouble), especially since I don't own the licensed version.
I sent them an email, hopefully, they will get back to me about that!
I think I'm honestly going to do that (Bools), since it would solve alot of issues, but at the same time, almost all of the models in DOTA2 use maps for everything (EI: Ramps, Masks must be 32 with Alpha, etc) so I'm kinda worried about giving people the 'wrong looks' of the model that will looks considerably different if they don't plug-them-in, or help wrong habits (EI: Flip Green channel, etc).
But you do have a point, it will only get more confusing for beginners, so yeah, I'll include the switch sets.
" allowed to share the SFX files"
Ofcourse you are allowed to release the SFX.
I haven't looked at the code but for readability it helps to properly name the nodes in the Shaderfx graph if you havent already.
And yeah, I did name the nodes, but I'm pretty terrible at them, most of the time you'll see a math node like this: FresnelxColorxStrenghtxPower
PS: Latest version is up peeps, with an example folder for you too Pior, check them out and see if I missed out on anything.
Also, for those wondering (few peeps that send me a message), I didn't include or make a Fresnel-Wrap term (meaning having a pure fresnel using a textures instead of a color) since I don't know what Valve used as their final math (you can see what I mean in the Readme), hopefully that should stop people from going crazy while taking a look at the documents.
Time to test this out.
Edit:
Works like a charm and then some, wow some amazing work right here, no more headaches.
Hope this helps!
Haha, yep, quite a few bumps on the road.
Glad your enjoy, cheers mate
Argh, you're right, I totally forgot about that and was keeping in mind Maya tangents (hopefully that ones works fine).
Cheers!
It's returning various compile errors, but I've seen a post or two in this thread saying that it worked fine on their install
Did you try the Maya version OR the Optional versions?
Also, screenshot please.
Here's what Im seeing for the maya version.
The optional version doesn't work either.
OK, so I downloaded Maya and did a test myself, seems like it isn't liking something with the If A=B statement or the textures themselves, OR the plugin could be compiling the code wrong maybe? So I have no idea what I can do about that, sorry, wish I knew.
BTW, if you use the HLSL-Shader in the Hypershade editor, instead of the CGFX for Maya, it will work (just enable it through your Plugins-Manager) problem is, it will look abit messy and not as good as the Max version, where instead of "..." between certain sections of the parameters, you will get something like "LightDivider", the shader itself and the look of the models remain unaffected, so there is joy in that.
But it still works, I just have no idea on why Maya's HLSL, CGFX or such are acting weird honestly, or why the CGFX shader is broken, hopefully someone can shed some light, in the meantime, use HLSL shader for Maya.
Cheers, will keep that in mind!
Yeah i've always had the impression that maya shader support was bad compared to max. I guess I could always ask to get a floating license to use Max at home
Thanks for your hard work Ace-Angel!
I don't even know how to try the shader lol
Its actually the other way around. The HLSL plugin usually causes more problems haha.
Here's what Im seeing using HLSL in maya..
/sighs. Sometimes I hate maya!
DeoLol:
Go into plug-in manager in Maya and load the cgfxshader.mll and hlslshader.mll.
In the hypershade, create either node ( apparently HLSL works and CgFX doesn't) and load the DOTA2 shader file into it and it should work.
Download!
https://dl.dropbox.com/u/8510078/Dota2/Dota2Hero_Shader_2.0.rar
Changes in Version 2.0
-Shader is now completely written from scratch!
-Support: Maya Support with some limitations due to the compiler profile. Diffuse warp, and Fresnel warp might not work, depending on your card. Working on resolving these issues...
-Features: Diffuse Warp, Fresnel Warp, Normals, Mask 1 & 2, Detail Texture, Specular Exponent and Scale, Rim light Color and Scale, Ambient IBL, Ambient Light
-Added: Fresnel Warp
-Added: Invert green channel for normals
-Added: Specular exponent and scale
-Added: Rim light scale
-Added: Ambient Light with Ambient IBL Cubemap support
https://dl.dropbox.com/u/8510078/Dota2/parameters.jpg
If anyone has any problems, just post here!
On a related note, if anyone takes awesome pictures with this shader, do post them here, would very much like to make a banner with them
i hope this helps if someone runs into the same problem
Cheers
Maya specific:
-Initially the model displayed with black diffuse but I found plugging in a point light to the light 1 position fixed this.
-Lights are treated as point lights (non-directional)
-When I duplicate a shading network maya unloads the cgfx file on the duplicate so you have to click the "reload" button
-the model display in the viewport gets wacky looking if I rotate the model so I keyframed the lightgroup rotating around the model.
Shader specific questions:
-Is the position/rotation of the rimlight adjustable?
-Should we use juggernaut_lightwarp.tga for all the shaders and both diffuse and fresnel warp slots?
-Any other settings I should edit? (or tips)
I'll probably play around with the settings some more to get a better likeness to the in-game but so far it seems good. The 3rd light slot is still open as well.
Screengrab of Maya viewport, player select and in-game:
Thanks!
Hey Ethohe, I can't really say per se about Maya and why these issues are coming to light (pun intended), but I'll try my best to answer them.
-This is a weird one indeed, hopefully Drew can fill you in, but I think we decided to go with a light-requirement (EI: You need at least 1 light to show your model properly) setup since DOTA2 always has one source of light ontop of the character, but having your model be outright black is weird, it could be a bug that needs squashing. I think it could be a Maya specific bug.
-Mind telling what is happening exactly in terms of looks? In most cases, point lights in Maya or Max should act like directional, respecting the location and direction they're emitting the light from, same with other light sources, unless you mean you're getting a lack of directional light shadows, in which case, we kinda decided to skimp on shadows since they're somewhat buggy.
-I'm not sure about this one, Maya shouldn't be unloading or reloading anything by-itself (unless they included some fancy new thing in the latest SP patches). Does this happen all the time, after a fresh scene, or sometimes?
-Thats a bug to which I experienced in newer versions of both Max and Maya, I'm not sure what is causing it, but if you could try this: Freeze transform > Rotate Model; If model gets wacky > Freeze transform (or equivalent of Reset XForm from Max). If this works, then it's an Autodesk issue, in worst cases, it could be a Valve/Import issue, since in my case, Importing the newer FBX versions of the model in an older importer like Max 2009 will also cause the same issues.
-No it isn't, and the reason for that is because Valve made it like that for optimization (we tried to keep it close to it as possible). However, if you want to the Rimlight to be on certain parts of your model vs. non-in others, then you need to create your own Mask in Mask-2 channel G. That's how Valve did it the "More Rim ontop, less on the bottom" look, I think they used an AO and Spec map together to make the mask.
-You can use it, although I would suggest not using anything in Ramp in the mean-time, since each model has it's own Lightwrap map which does really change the look of the model (EI: Sven has a very blue warp, in some characters even pink!). Juggernaut currently has the more complicated one, and it's missing a couple of texture maps for the body and the fur, so it can throw things off, especially on other models.
If you want, I can create a dump from DOTA2 of all the Ramp maps for the Heroes as well the Fresnel Warp, since each has their own, maybe include the VMT files which tell you stuff like color of the Rimlight, Specular exponent, etc.
Cheers and thanks for the feedback!
Next version will have this fix!
- Valve does use a interesting rim light... They square it ( rim * rim ), and I think they might mask it by the regular diffuse light ( dot(Normal, LightVector), I didn't do that. Now that I tested it out, It's looking closer to what you're showing from the game :V
Here is that shader edited! https://dl.dropbox.com/u/8510078/Dota2/Dota2Hero_Shader_2.0.rar
- As far as I know Valve just used a regular rim with no Fresnel, but I could be wrong! You can control it's intensity/scale there... Basically it's just a multiplier.
- Fresnel warp would use a 3D warp texture, such as hue_shift_90_degrees... You don't have to use the Fresnel warp, since it's only on a select handful of characters. Unfortunately I don't have access to the Fresnel warps from the game in proper "volume-texture" form, which is absolutely necessary. Would be neat if I did! * on a site note! * The diffuse and Fresnel warp effects are showing errors a inside Maya. Not sure why. I'm working on fixing that!
- You can use "juggernaut_lightwarp.tga" for the diffuse light warp only, since it's just a 2D thing, not 3D. Although, if you can extract some of the warps from the game you can use those
Here is a simple "identity" 3D Texture. This one won't change the color of the Fresnel.
Throw it on top of an image of screenshot of your character in Photoshop and apply as many adjustment layers on top!
Here are the settings for .DDS Export. It MUST be a volume texture! Can be any bits, the only problem is you start to lose accuracy, resulting in some color errors
Hope this explains the 3D Fresnel Color Warp tetxure to people!
Now that EtotheRic is able to achieve a great look with the updated shader I'm really excited to give it another go.
Thanks for the hard work.
What would be the best way to take renders with this shader in Maya? Is there a way to take high-res real time screenshots in Maya?
That'd make it directional (unless the light is directly infront or behind the camera, then it halos out like regular rim light), but also constant.