"KoddeShader", a Maya CGFX shader

13
polycounter lvl 14
Offline / Send Message
kodde polycounter lvl 14
Hey gang,

I've been working on my own multipurpose CGFX shader for Maya for a while now. Figure I'd let the PC community give it a go. I created this shader using Mental Mill and a bit of notepad editing for UI tweaks. The purpose of this shader is to produce a "game like" look in Maya's viewport.

I haven't been arsed to write any documentation for this yet, so just ask away. Please let me know if you find any bugs or have any suggestions for improvements.

You can get the shader here (bottom of page).

Video Tutorial on how to use it here.

koddeshadershowcaseexam.jpg

Replies

  • rollin
    Offline / Send Message
    rollin polycounter lvl 15
    I'm not using maya but this looks quite solid!! cool stuff
  • hijak
    glad to see you found mental mill useful, i sure did. This looks great btw, but im curious if you could maybe detail the edits you did to achieve emmisive, i had messed with this for a while then scraped it for other project but id be very interested in that. also i notice no example of transparency, transparency out of mental mill is sort of a workaround, so if that was an issue i explain how it would be done. I think next on the list would be adding vertex color support as you can use that for many things. Great work.

    ps after looking in to it more i think you need to add tiling controls to make this more useful, as the maya nodes wont work with it last time i checked, i can also detail how to do this proper in mental mill but im sure you've already figured it out, but would be great to tile the diff, spec, nrm and also i think it could have support for detail nrm maps. oh and props for the second uv set support, that could have been easily overlooked.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    rollin> thanks.

    hijak> Mental Mill is loads of fun, but still lacks a few things. The emissive is just additive? The "glowish" fade is in the emissive bitmap, not generated by the shader. So it's nothing really fancy.

    You know how to get transparency working? I'm quite limited to what Mental Mill lets you do since I don't know how to write a shader in a textbased editor, and I don't think MM gets you transparency. Also no shadows yet and no vertex color support.

    Please do share how to get transparency working.
  • hijak
    scroll down to post number 6, you just setup your network like shown then add the lines at the end of the code. Also you should look up possible blendmodes, or whatever and include those in there, when i made an alpha shader i ended up having as many of the alpha modes as i could find as each situation required something different.
    http://forum.mentalimages.com/showthread.php?t=160&highlight=transparency

    id just hook it up with a conditional as well like you've done in these others.

    also good to know is down there at the bottom is where you can control support for various features of these shaders, so experiment with that, its also very useful for changing what shader model is used.
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    Oh, wish i could have Mental Mill too, that thing looks so great, but I just cant export if I dont have the pro version. :(
  • chronic
    Offline / Send Message
    chronic polycounter lvl 9
    loaded up your shader and it looks great, alot of nice feature support.

    unfortunately maya's hlsl and cgfx runtimes dont handle transparency very well or consistently, its just the nature of the beast.
    even more disheartening, unlike max, maya wont let you do cool multipass shaders either so shadows are out. hopefully we will get more comprehensive support for this stuff from Autodesk since its becoming so useful in production. but I think hell will freeze over before Autodesk listens to the community.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    chronic wrote: »
    loaded up your shader and it looks great, alot of nice feature support.

    unfortunately maya's hlsl and cgfx runtimes dont handle transparency very well or consistently, its just the nature of the beast.
    even more disheartening, unlike max, maya wont let you do cool multipass shaders either so shadows are out. hopefully we will get more comprehensive support for this stuff from Autodesk since its becoming so useful in production. but I think hell will freeze over before Autodesk listens to the community.

    Thanks!
    Getting transparency and shadow to work are my two top features on my wish list, but both have seem hopeless. I'm going to try hijak's tip tomorrow evening, see if I can get that transparency workaround to work.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 12
    very nice :) thx for the reference too !
  • JohnnyRaptor
    Offline / Send Message
    JohnnyRaptor polycounter lvl 11
    woot, nice one kodde, i will give this a go durrin lunchbreak
  • fantasymaster
    Offline / Send Message
    fantasymaster polycounter lvl 12
    Nice one! Thank's for that.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Thanks guys,

    I messed around with trying to get alpha to work yesterday with that workaround but with no success. I had some funky transparency going on, but I couldn't get it to work correctly. I also found some other forum posts regarding this with people who said they had got it to work, but I couldn't get their solutions to work either :(

    Starting to think it might be dependent on what version of Maya you use, or possibly even your graphics card and driver.
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 11
    Oh nice work mate! I just started playing around with maya and testing out its real time materials, so I will definitely have a look at these!

    Thanks for sharing them with us :3
  • Gilgamesh
    Offline / Send Message
    Gilgamesh polycounter lvl 10
    Dunno if im doing some thing wrong here but it really doesn't work in maya 2010 as far as I can see, when I load it up (without actually doing anything) it gives a ton of errors about linked lights, and doesn't actually show any textures that are assigned (even if lights are linked).

    Probably a newbie error (and yes I watched the video from cgbootcamp and that shader doesn't work for me either).
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Gilgamesh wrote: »
    Dunno if im doing some thing wrong here but it really doesn't work in maya 2010 as far as I can see, when I load it up (without actually doing anything) it gives a ton of errors about linked lights, and doesn't actually show any textures that are assigned (even if lights are linked).

    Probably a newbie error (and yes I watched the video from cgbootcamp and that shader doesn't work for me either).

    I'm used to ignoring the pink/purple error message about internal lights, I always get that when loading a project or when I reload my .cgfx file in the shader. It works anyhow.

    What sounds alarming in your case would be that you have tried a tutorial which also didn't work. Try updating your GFX drivers. Try on another computer if you have the possibility.

    I know for a fact that my shader works on several different computers with different hardware. Though there is probably some scenario of hardware and driver combination that won't work. I know that there was a a quite common issue with Brice's Generic BRDF shader and certain drivers which wouldn't work. Many users had that issue. At that time I had to rollback to older drivers to get it working, now it works with the latest nvidia drivers though.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    I have been trying to get parallax mapping to work before using Mental Mill's predefined nodes, but it's bugged. The effect doesn't match the cameras rotation, probably something easy to fix, but I haven't gotten a reply to this on their forums. Gives this result.

    [ame]

    Anyone know how to solve this? Would be cool to include parallax mapping in the shader.
  • hijak
    if your using the built in parallax node then you need to edit it so y is up i think it is set to z is up. Then you might need to use some of the space conversion nodes. Also ive noticed you have to use incredibly small settings on amount to get it to look semi normal.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    hijak wrote: »
    if your using the built in parallax node then you need to edit it so y is up i think it is set to z is up. Then you might need to use some of the space conversion nodes. Also ive noticed you have to use incredibly small settings on amount to get it to look semi normal.

    Yeah you are probably right with the space conversion suggestion, but I wouldn't know where to start. I have also noticed the issue with amount that you are mentioning, most certainly depends on the implementation. My colleague spoke of other methods of doing it which produces "faaar better results", but I'm not sure if these would come with a trade off or if there might be an other reason for it to act like this.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 12
    kodde wrote: »
    there was a a quite common issue with Brice's Generic BRDF shader and certain drivers which wouldn't work. Many users had that issue. At that time I had to rollback to older drivers to get it working, now it works with the latest nvidia drivers though.

    I found what it was tough: you need to force sampler states on everything, never assume the default states are used 'by default' (how ironic). In my case the 'clamp' flag supplanted the 'wrap' one on some textures where it was left blank.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    I found what it was tough: you need to force sampler states on everything, never assume the default states are used 'by default' (how ironic). In my case the 'clamp' flag supplanted the 'wrap' one on some textures where it was left blank.

    Aha... well there you go. Then maybe it isn't as common as one would think that the gfx drivers is to blame? ;)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    My "TintRamp" feature in this version is borked, has to be applied in the shading chain in a different manner. Got a small list with features I will improve in the next version.

    Also got a lot of help from hijak to get transparency working, yay! So will include this in next version.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    There's a new version up, v0.2.

    -Changed old "Color_Texture" variable to "Diffuse_Texture".
    -Transparency technique now available. Uses alpha channel of Diffuse Texture.
    -Rim Lighting added. This is the "Ext_rimlighting" Mental Mill nodes added, no modifications on my part.
    -Added 1 point light and 4 spot lights.
    -Reworked how the Tint Ramp was added to the shading branch, should work better now.
    -Ambient Color can now be set. Only works when not using a Cube Map for the ambient light.
    -A couple of various small UI and cosmetic changes.

    Go get the new version here. At bottom of page.

    Here's my new feature images to convince you artsy folk out there :)
    11_rimLighting.jpg
    12_transparency.jpg
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    looking great Kostas!
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 11
    I'm going to have a longer play with this new shader. Opacity! Yessss! you are my hero! May the internet lay down rose petals at your feet, evermore.

    EDIT: I had a play and its really good! Thanks mate! :D

    just a question, How do I hook up lights to it?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Thanks guys,

    Anuxinamoon> After all the texture slots, at the bottom of all the parameters you will have a long list with all the light attributes and slots like "Directional1 Direction", etc. You need to have an object in your scene to define direction and/or position for the lights.

    For example, try creating a new directional light in your Maya scene, then go to the shader and find the "Directional1 Direction" slot, right click in the empty slot and select your new directional light. Now you should be able to rotate the directional light in your scene and the light should update on the object. You can of course tweak parameters such as intensity, color, etc for each corresponding light. All light settings are stored in the shader. By the way, don't scale the lights in Maya.
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 11
    Cheers mate!

    I thought I was doomed to have bad real time shaders for the rest of my maya existence before your shader came along. Its really helped me out. So a big THANK YOU from me :D
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Anuxinamoon> Good to hear.

    Please do share any cool results you might achieve :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Updated my site with new showcase example.

    koddeshadershowcaseexam.jpg
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 11
    does this only work with maya 2010?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    It works with Maya 2009 32-bit for certain, that's what I usually use. My guess would be that it works with 2008 as well since I have used CGFX shader with 2008 as well. Are you unable to load/use it?
  • InProgress
    Offline / Send Message
    InProgress polycounter lvl 11
    Loaded it up in Maya 2008, but even though I added the diffuse, spec and normal, I get still get the texture not found color. Maybe I'm doing it wrong.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    InProgress wrote: »
    Loaded it up in Maya 2008, but even though I added the diffuse, spec and normal, I get still get the texture not found color. Maybe I'm doing it wrong.

    Which is the "texture not found color"? Did you switch to hardware shading (6-key)?
  • InProgress
    Offline / Send Message
    InProgress polycounter lvl 11
    Sorry to fill your thread with useless images, but here's the result I get, with hardware shading turned on. texture_not_found1.jpg
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Doh... yeah that's the color I get when I've applied a empty CGFX shader on an object. Well, then it might just be that it doesn't work with 2008. I'm sure I've tried other CGFX shaders in 2008 though.

    Did you ever get any other CGFX-shader working in 2008? Did you try opening the ones bundled with Maya? In the presets folder.
  • InProgress
    Offline / Send Message
    InProgress polycounter lvl 11
    Just tried some other CGFX-shaders. Guess the problem is on my end, then.
  • hijak
    sometimes you can force it to work by enabling this maya env variable. Just add it to your maya env file in your user settings.

    MAYA_ENABLE_HWR_CG_PROGRAMS = 1

    that may help, ive had to use that before think some older versions of maya have this problem where it would not detect your hardware as compatible, only seemed to happen when you where using consumer level hardware, as appose to workstation cards, but newer version of maya seem to not have this problem.
    also make sure your using textured mode, the shader will show up green in shading mode and in textured mode it will be pink if there are no maps applied.
  • chronic
    Offline / Send Message
    chronic polycounter lvl 9
    as long as they where specifically written for maya all these cgfx and hlsl shaders will work in versions of maya all the way back to 8.5.
    problems only occur with issues outside of maya's influence. Either the graphics card - your card must usually support shader model 3 (SM3) for these more complex shaders, or unfortunately user error.
    You must be in 'Textured' Mode and NOT in 'High Quality Shading' Mode. Also lights must be linked into the shader - often times shaders are written to expect Texture Maps and must have some basic ones inserted. In general its a complicated process for a first timer.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    New version out, 0.3

    **Changes in v0.3 since v0.2**
    -Rimlight now uses Normal Map
    -Half-Lambert now uses Normal Map
    -Set diffuse color, affects even when a diffuse texture is loaded.
    -Reflections Gain
    -New Rim Lighting instead of old one which was more of a Back light.


    You can get the shader here (bottom of page).
  • claydough
    Offline / Send Message
    claydough polycounter lvl 10
    oops wrong thread
  • ivars
    Offline / Send Message
    ivars polycounter lvl 12
    Hey Kostas. Awsome shader!

    Tried it on this power drill I'm making.
    Still working on the textures, and I'm using the same texture for spec, gloss and reflectivity right now.

    Added the bloom in PS :P

    Powertool_02.jpg

    Update:

    Powertool_03.jpg
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Thanks!
    Looking good Ivars. So rewarding for me to see people using it :)
    Don't hesitate to ask if there's any uncertainties or questions regarding the shader.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    New version out, v0.4!

    **Changes in v0.4 since v0.3**
    -Parallax Mapping!

    -Choice to include specularity and reflections on transparent surfaces.

    -All lights have a "Enabled" checkbox now to easily enable/disable them without having to alter their intensity attributes.

    -Minor cosmetic change in order attributes are listed. The ambient lighting oriented attributes and slots are now further down, where the other light attributes are found.



    You can get the shader here (bottom of page).
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    I made a video earlier today to showcase the parallax mapping feature.

    [ame]
  • praxedes
    wow...

    that parallax is awesome. I can't wait to play with this shader- I've often felt like the unloved ginger freckled child as a maya user for realtime stuff, but this will help maya feel a little loved again!

    ~P~
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Praxedes> Haha :) Glad you like it. You can go far with Maya as well.
  • Nistrum
    Offline / Send Message
    Nistrum polycounter lvl 9
    i tryed your shader but it did something kinda nuts to me. for any planar surface it kinda set the lighting all the way to 100% making any surface at 90* to the light source 100% white.. which sucked :P if you want i can post a ss or am i just forgetting something really simple?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Nistrum> Sure post a screenshot. Did you assign any diffuse texture? If not the default diffuse color is white, you can change the diffuse color. It's at the top of the shader attributes. If you also have it facing directly towards then it's no wonder it's white :)

    Also try assigning a direction/position to your light and move it around, see if it works the way you expect it to.

    Remember that if you do change the default diffuse color and later assign a diffuse texture your results will be diffuse texture color * diffuse color. In this case you probably want to set the diffuse color back to white.
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    great update kodde
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Bugo> Thanks :)

    New version out, v0.5. Quite boring update, but still necessary.

    **Changes in v0.5 since v0.4**
    -Fixed Diffuse Color and Light Colors working correctly with Warp Diffuse Ramp.


    You can get the shader here (bottom of page).
  • kodde
    Offline / Send Message
    kodde polycounter lvl 14
    Yay for doublepost, new polycount feature? ;)
  • Mongrelman
    Offline / Send Message
    Mongrelman polycounter lvl 13
    Looks great, I'd like to try this, but does it need an Nvidia card to use it? I think I read somewhere you need one for cgfx shaders.
13
Sign In or Register to comment.