Home Technical Talk

"KoddeShader", a Maya CGFX shader

2

Replies

  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Mongrelman> I really don't know to be honest. I have only ever worked with CGFX shaders on Nvidia machines. Let me know if you decide to try it out.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    chiniara wrote: »
    That's a good thing to know because i have an ATI card and really want to use this.

    But at the moment i don't have any models to test.


    You could try this on a box using windows sample textures ;)

    It might be that some things work and other don't though, won't know for sure until someone tries every feature.
  • chronic
    Offline / Send Message
    chronic polycounter lvl 10
    as long as the shader is using the arbfp1 and arbvp1 profiles they will work on both vendor's cards from around 2003 onwards. (actually there are some limitations on ATI cards but that should really only be on older cards)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Sweet.

    I'm using vp40 and fp40 in Mental Mill... whatever that means :)
  • chronic
    Offline / Send Message
    chronic polycounter lvl 10
    my info is all from the Cg 2.2 Docs available on Nvidia's Developer website.

    the fp40 and vp40 profiles are nice because they allow for more instructions in the shader

    they docs suggest those only work on Nvidia GPU's but I guess ATI could have included compatibility for those compilers - I dont have access to any ATI machines either, so can't confirm

    if you code a shader that runs under arbfp1/arbvp1 I dont think you get any benefit switching to vp40/fp40 unless it wont compile because you have too much math(coolness).
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Chiniara> I seems that way. At least for running mentall mill. This should however mean that any shader exported with MM ought to work. At least thats how I read it. I'm usually sceptical about these things until I see it working on my own machine with me behind the controls :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Hey guys,

    I wanted to ask you for ideas for future updates. Anything you feel is missing? Could be improved? Is incorrect?

    Here's what I have planned for 0.6

    --0.6 updates--
    Hemispherical Ambient Light Color option when not using a Cubemap for Ambient Light.
    B/W Z-Depth pass, near/far variables
    Normal Debug mode
    Gloss Factor still affects when using Gloss Texutre
    Pre-defined 3 point lighting as default light values
    User Guide/Video Tutorial


    Thanks.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Alright, new version folks!

    You can get the shader here.

    **Changes in v0.6 since v0.5**
    -Optional Hemispheric Ambient Light Coloring
    -Optional ZDepth Coloring. You have to set your near and far plane.
    -Optional World Normals Coloring. Use these to debug your normals.
    -Optional Camera Normals Coloring. Use these to debug your normals.
    -Gloss Factor attribute now affects your gloss results even when a Gloss Texture is loaded. This allows you to shift your gloss results after you have loaded your Gloss Texture.
    -Rim Lighting has been simplified with no impact (I think?) to end results. There are now two less attributes to set your Rim Lighting which were kind of useless to begin with.
    -A few cosmetic UI changes, such as the useless "(alpha)" sliders below color pickers are now gone!

    The Z-Depth feature is there for those who want to use this information for various kind of post processing tweaks.

    koddeshaderv06featureim.jpg
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Just realized the Ambient Cubemap was applied sideways (damn varying coordinate systems). Corrected this and updated the shader. Sorry.
  • beartraps
    Offline / Send Message
    beartraps polycounter lvl 8
    man, I just opened up the shader and it looks really great, only problem is when I turn on textures im just getting a flat black color on my model. I have textures assigned to my model and a light set up and its just not working. Im using a mac with a NVIDIA GeForce 8600M GT card, and Brice's shader worked just fine so i'm wondering what the problem could be. Only thing i can think of is that im using OSX?

    Im gonna run VMware now to see if this is indeed the problem

    EDIT: ok cool, its working fine in windows. im trying to use the cube mapping feature but I can seem to get any results. I've never made or applied a cube map before so im kind of a noob when it comes to this. Would you be able to do a brief write up on how to make and apply it in your shader, or perhaps point me in the right direction? thanks!
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Hey beartraps. Glad you're liking it. I'm actually working on a video tutorial as we speak. If you're lucky it might be up later today ;)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Here you go!

    55 minutes of listening to my lovely voice going on about my shader ;)

    http://www.vimeo.com/9802048

    Enjoy
  • beartraps
    Offline / Send Message
    beartraps polycounter lvl 8
    kodde, you rock!
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    beartraps wrote: »
    kodde, you rock!

    :)
    Thanks Beartraps.

    Do share your results. Always nice to see what people make of it.
  • beartraps
    Offline / Send Message
    beartraps polycounter lvl 8
    I love this shader! I just wish it worked for OSX so I dont have to use bootcamp all the time. Very similar results to Marmoset toolbag, awesome!

    WaltherKoddeShdr.jpg
  • willy-wilson
    Offline / Send Message
    willy-wilson polycounter lvl 8
    thank you so much for this shader. making things much easier. :) crappy example texture
    texturetest.png
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    New version out, just a minor but important update.

    **Changes in v0.7 since v0.6**
    -Newer Rim Light feature introduced in v0.6 was inferior to how it worked back in v0.5 so I decided to revert back to v0.5 implementation.


    You can get the shader here.


    Beartraps & Willy-Wilson> Thanks for sharing! Give the updated rim light a go, usually looks quite nice on guns imo.
  • beartraps
    Offline / Send Message
    beartraps polycounter lvl 8
    Sweet, i'll have to give that a go. Do mental mill shaders not work with mac? I'm just wondering because Brice's shader worked fine but I really like this one much better. Thanks again.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Beartraps> I really don't know. I'm working with a windows machine and you're the first one to tell me it doesn't work with a mac. :/

    Technical specifications for MM, http://www.mentalimages.com/products/mental-mill/features.html
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Beartraps> Did it not work to load the shader at all on a Mac, or where did it go wrong?

    Here's a guy on the official MM forum who has some troubles with his normal map on a Mac, he's tried it on 4 Macs with no success. Might not just be you having these troubles.
    http://forum.mentalimages.com/showthread.php?t=6269
  • hijak
    have not checked this in a while nice updates, glad to see you got parallax working properly, and glad you caught that problem with the ambient component, i had noticed when playing around and forgot to mention, thats always something to consider when working in mental mill, which makes previewing in mental mill sorta strange if your axis are not swaped so i think the shader would benefit from a axis switch button to change from z up to y up.
    Btw if you are now using the custom cgfx export option the shader will work in softimage as well as max, and in fact it works better in softimage as you get color pickers not numeric entry. Also if you where to save an xmsl from mental mill you can load it in max and not even have to link your lights.
    here is my suggestion and its something that really helped streamline my cgfx shaders.
    Right now all the mask have their own map which seems ideal at first but it can be sort of a pain to update each of those textures once things start getting complicated. So i think you should start storing the masks in the alpha channels of their respective maps. For example the heightmap for the parralax could be stored in the alpha of the nrm map. its just a suggestion but think it would improve workflow when using this shader. And i cant tell if you've added it yet but there is a way to link the object position so it stay relative to the cube-map and ambient map, that would further improve this shader.
    And finally what does the network for the z-depth consist of. Is it a combination of the ray distance state node and a gradient? i have something similar going on in one of my terrain shaders but im curious what method you used.
    great work cant wait to see more.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    hijak wrote: »
    have not checked this in a while nice updates, glad to see you got parallax working properly, and glad you caught that problem with the ambient component, i had noticed when playing around and forgot to mention, thats always something to consider when working in mental mill, which makes previewing in mental mill sorta strange if your axis are not swaped so i think the shader would benefit from a axis switch button to change from z up to y up.
    Btw if you are now using the custom cgfx export option the shader will work in softimage as well as max, and in fact it works better in softimage as you get color pickers not numeric entry. Also if you where to save an xmsl from mental mill you can load it in max and not even have to link your lights.
    here is my suggestion and its something that really helped streamline my cgfx shaders.
    Right now all the mask have their own map which seems ideal at first but it can be sort of a pain to update each of those textures once things start getting complicated. So i think you should start storing the masks in the alpha channels of their respective maps. For example the heightmap for the parralax could be stored in the alpha of the nrm map. its just a suggestion but think it would improve workflow when using this shader. And i cant tell if you've added it yet but there is a way to link the object position so it stay relative to the cube-map and ambient map, that would further improve this shader.
    And finally what does the network for the z-depth consist of. Is it a combination of the ray distance state node and a gradient? i have something similar going on in one of my terrain shaders but im curious what method you used.
    great work cant wait to see more.

    Hey Hijak, thanks for your feedback.

    Cool to know about the xmsl being able to load in Max. I had one user try loading the .cgfx in max but with no success. Was exported with Custom CGFX profile.

    Regarding reducing amount of maps by storing b/w mask in alphas. I have been thinking about this but I'm not convinced that this would make the workprocess easier? Then again, why would it make harder? Hmm... Say I wanna update my parallax map, I either open my normal map and change the data in the alpha channel or I open my standalone parallax texture and update the RGB channels. Why are either of these faster/slower? The way I reasoned was that it was more intuitive for newcomers to learn what maps do and to organize them if you keep them separated. Anyone else wanna give me their views on this? I can implement either, this is not an issue.

    Regarding position on cubemaps I have not implemented this yet, thanks for reminding me. Will definately look into this. How is this done? You add the state parameter "position" I'm guessing?

    My ZDepth is basically Near & Far attribute the user has to set. Then it's just math nodes to scale the far-near to the 1-0 range so that it appears to go from white-black.

    Not that I'm that great with math, but I think this should be it.
    (1 / (Far - Near)) * (Ray Length - Near) = Color
  • beartraps
    Offline / Send Message
    beartraps polycounter lvl 8
    kodde wrote: »
    Beartraps> Did it not work to load the shader at all on a Mac, or where did it go wrong?[/url]

    The shader loads fine and all the attributes are visible, but when applied to a mesh it appears as a flat black, like a black surface shader. I have lights set up and textures applied, so not sure where the problem is. Ill run some more mac tests at the computers at school to see if its for sure a mac thing or perhaps its only with mine. I would think it just doesn't work on mac since it works on my same machine in windows.
  • ArchNacho
    Kodde, this shader looks fantastic. I was recommended to it by a friend, and I am very excited to try it out. However, everything stays pink, even after loading in your shader. I've tried just about everything that came to mind, and spent a few hours on google trying to mull over a solution.

    I'm running Maya 2010, 64-bit. Has anyone else had success with this version? Any ideas? I'll try anything
  • ArchNacho
    Hello!

    I love your shader, it looks fantastic. I have watched your tutorial 3 times over in anticipation to using it. Sadly, I cannot get past the first step. Whenever I try to load the shader I get a huge string of error messages, an the shader stays the default pink.
    I thought it may have had to do with maya 2010 64 bit, but after downloading the 32 bit trial today, nothing changed.
    Any thoughts on how to fix this? I'd be very excited to get my hands on this beautiful shader!

    Here is the error message I get;
    // cgfxShader "cgfxShader1" loaded effect "C:/Users/Arch Nacho/My Work/dock_environment/renderData/shaders/KoddeShader_v0.7.cgfx"
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light0_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light0_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light1_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light1_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light2_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light2_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light3_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light3_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light4_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light4_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light5_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light5_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light6_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light6_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light7_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light7_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light8_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light8_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light9_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light9_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light10_transform_internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "msl_light10_transform_light_to_internal" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "__internal_to_light" - ignored //
    // Warning: (1243) cgfxShader node "cgfxShader1" has invalid attribute "__light_to_internal" - ignored //
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Thanks ArchNacho,

    Are you sure it's not working? Did you switch to hardware texture mode (6)? Although even if you hadn't tried hardware texture mode it should at least be green.

    I get the same warnings as well, not the very first time I load it. But if I press reload or manually reload a new .cgfx file in it's slot I get those messages as well. I'm not sure why you get those internal light messages, but they never actually did any damage sort of say.

    What version of Maya? What OS? What graphics card? Can you load other CGFX shaders for Maya?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Try Brice's shader for instance. Does it load and work correctly?

    http://boards.polycount.net/showthread.php?t=49920&page=7

    I think the BETA4 version is his latest itertaion, at the bottom of that page.
  • hijak
    ArchNacho do other cgfx shaders work for you. there is this problem with maya not letting them work on some hardware, not sure why but ive run into this a few times. what works for me is to add this to my maya env file,

    MAYA_ENABLE_HWR_CG_PROGRAMS = 1

    ive had to do this in many versions of maya on different machines to get cgfx shaders to show up properly. so it may or may not help but i hope it does.

    curious what type of graphics hardware you have.
  • haikai
    Offline / Send Message
    haikai polycounter lvl 8
    I'm having the same problem as ArchNacho (and same errors) using the following:

    Win7 x64, Maya 2010 x64, ati HD 5770 with 10.2 drivers (recent)

    I should add that I'm not having luck with any other .cgfx shaders either, but .fx shaders using the HLSL shader node seem to work. I've got the plug-ins loaded, I'm in the right display mode in the viewport, and I've added the line to the .env file as Hijak suggested, but the shader and the model remain the default pink. Reloading the shader also does not seem to do anything except list the same errors.

    Since it happens with other .cgfx shaders too, it must be something on my end. Does anyone have any other suggestions?
  • 3deified
    Offline / Send Message
    3deified polycounter lvl 9
    Wow this shader is exactly what I have been looking for. THANKS Kodde!!!

    I started using it with the basic diffuse, normal, disp, and spec maps with pure success. Using just these alone yields a 4x improvement to the maya viewport! Not having to leave maya and being able to author assets in less apps is always a plus.
    I'll never go back to hardware render for Previewing game assets in maya. What i see in maya is almost 90 percent what i can tune to in a game engine.

    The only fuctionality that i can't get running is the reflection maps. Both user Reflection_ENV_Cube and Ambient Env Texture.

    I tried both version 0.6 and 0.7 but neither showed any change in the viewport. I also updated to the latest nvidia drivers and still didn't work. I also tried multiple formats for the env cube..hdr..tga...dds..no luck.

    I know the capability is there because if i do a traditional shader with a reflection map and use hardware rendering I can get a real time preview of an environment map.


    Here is my setup.. I suspect it may be drivers or windows 7.

    OS:
    Windows 7 32bit (@work) and 64bit at home (Tried exact same maya setup on both kernels)

    Soft:
    Maya 2009 32 and 64bit (tried both)
    Maya 2009 SP1 32 and 64bit (tried both)

    cgfxShader.mll plugin info from dialog box in maya:
    cgfxShader v 4.4 for Maya 2009 (April 8 2009)
    for API 200906


    Video Driver:
    nvidia GTX285 using latest driver 197.13 WHQL.




    Anythoughts? Should i revert my driver version? Do you use a certain nvidia driver version or video card Kodde?

    -3Deified
  • Kryzys
    Offline / Send Message
    Kryzys polycounter lvl 8
    Hey Kodde.

    Is existing possibilty to use shpere map in reflection map channel ?
    Cube map is very usefull but on the internet and in my library exist too many files in spherical or cylindrical cooridinates.
  • shaderMonkey
    Great job!

    I'm having a blast with it. Only issue I've had so far is the same issue as 3deified regarding the Reflection_ENV_Cube attribute (nothing happens when i plug in a cube map.

    Keep up the great work! :thumbup:
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    How did I miss all these replies.

    Thanks guys.

    3defied> I am on Win7 64bit, Maya 2009, GTX260, driver v191.70. I know for certain that it also works on Vista 64bit with 9800 and 8800 cards. Try reverting to another driver. If you want I can create a simple test shader just to try and figure out the reflection issue.

    Kryzys> I think I will stick to cubemaps to be honest. You should check out ATI's CubeMapGen and also HDRShop. I use these myself, they have functionality to convert between different layouts and formats.

    shaderMonkey> What specs on your computer? Did you try with different drivers?
  • 3deified
    Offline / Send Message
    3deified polycounter lvl 9
    Ah turns out that ENV cube texture i was using was not in the proper format.

    After spending some time tracking down how to use HDRShop and the ATI CubeMapGen tool I made a properly formatted Cubemap DDS file.

    I'll post some images of my model when I've finished.

    Thanks again Kodde for this useful shader.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    3deified> Thanks. Looking forward to seeing your results :)
  • Zyphr
    Liked your shader a lot! But I am having problems with using the transparency in Maya 2011...I tried using it in Maya 2010 and it worked!...are you planning on creating a version for maya 2011?
  • swayforce
    Yea, It's a very cool shader. i appreciate the amount of freedom it give you with the satisfying work it's produces. However, like Shadermonkey, I'm having a problem get the reflection environment cube. I have a regular cubemap yardcubemap.jpg

    here's a screenshot of it in maya with the settings plugged in. The file is a tga file i don't if that would be a problem. I using maya 2010 so, I don't if that is a glitch for the shader. If any know how to solve this it would be helpful.

    problemhelp.jpg
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Hey swayforce, sorry I had missed your reply to this thread.

    You need to use a horizontal strip layout cubemap in DDS-format. You can read up on the topic here.

    ATI's CubeMapGen is also nice and easy for converting between cubemap formats and layouts.


    Zypher> I haven't had a chance to try it in Maya 2011 yet. Will be switching to Maya 2011 at work quite soon so I can give it a go then. I'm contemplating on redoing the whole shader with Mental Mill 1.1 once they work out a few kinks. I have a few planned improvements and feature additions for then. Such as...

    -Simplified cheap SSS fake
    -Hue shift depending on light (like Xolius's Max shader)
    -Remove a few lights (to hopefully speed up performance)
    -Detail Map
    -Anisotropic Specular
    -Reflection bias control
    -Matcap feature
  • JaySmitt
    Offline / Send Message
    JaySmitt polycounter lvl 13
    Noob here, whenever I create a cgfx shader it's just completely green. I've tried googling the problem but I can't find anything about it, I'm guessing it might have something to do with my graphics card I don't know. Anyone come across this before?
  • BeatKitano
    Offline / Send Message
    BeatKitano polycounter lvl 16
    Switch to high quality mode.
  • JaySmitt
    Offline / Send Message
    JaySmitt polycounter lvl 13
    BeatKitano wrote: »
    Switch to high quality mode.

    Already had that on, it's the swatch shader preview that shows up as green, the material on an object is simply grey. With a CGFX plugged in no change in appearance are made to the shader when I change the settings.
  • BeatKitano
    Offline / Send Message
    BeatKitano polycounter lvl 16
    Then i would go with the standard maya routine, reboot your computer (yeah, sometimes something doesn't work, and a simple reboot fixes everyting)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Just making sure here. You have Hardware Texturing (Hotkey "6") enabled?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    Still waiting on Mental Images to fix some issues with their 1.1 version. Then I will get cracking on reworking the entire shader.

    Played around a lot with Mental Mill 1.0 today and experimented with a few of the future features I want to implement. Got a solution for light based hue shift, a solution for matcap/litsphere support, a solution for the easier sss fake.

    Also learning about gamma correction lately. Got an implementation ready to be used.
  • JaySmitt
    Offline / Send Message
    JaySmitt polycounter lvl 13
    Hmm, strange I gave up last night on trying to get the shader to work. I thought I'd give another go while I'm at college and now it's working O_O. Very nice shaders too :).
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    for the first time i have problems with the kodde shader. I have used it on different models b4 and it worked fine.

    the problem is shown below. where theres very harsh shading even tho i added a diffuse texture nothing changed

    kodde_shader_problem_by_jujikabane.jpg

    kodde_shader_settings_by_jujikabane.jpg

    heres the model with just blinn shader

    smaw_col_by_jujikabane.jpg

    i was hoping if anyone could help me with this. cuz i have no idea wuts causing this
  • nullfed
    Offline / Send Message
    nullfed polycounter lvl 9
    is there any scaling on your light source or stand-in object? - actually looking at your settings, add a directional light in the Directional1_direction slot
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    thanks nullfed. I think its the scaling of the lights. i reimport it in a new scene again and it was fine.
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    is parallax mapping gone from kodde shader v2.0? cuz i cant find it at all.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 18
    onionhead_o> I'm afraid so. I didn't figure it was a common feature so I rationalized away a few features from the older version. It's still available in the 0.7 version, but not in the 2.0.
2
Sign In or Register to comment.