Home Technical Talk

Free Maya/max cgfx/fx Shader

245

Replies

  • pior
    Offline / Send Message
    pior godlike master sticky
    Looking fantastic Ruz!
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    awesome Ruz smile.gif
    Chris I'll have a look at your files once my hangover is gone ^^
  • Joseph Silverman
    Offline / Send Message
    Joseph Silverman polycounter lvl 15
    That looks awesome, Ruz.
  • Ruz
    Offline / Send Message
    Ruz sublime tool
    cheers pior/brice.
    I am still not too keen on the rim shader stuff. needs to be a bit more erm 'velvety' if that makes sense. max seems a bit weird with rim shaders anyway.

    BTW,could we have real time shadows purleeeease smile.gif
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 16
    there is two ways to do rim, either by the "rimlight" values (whose result is added on top of all shading), or with the BRDF texture's x axis. the latter gives you full control, however it is multiplied with the texture color.
    I guess you want a second BRDF texture for that is "added" on top, one could mix that texture with SSS texture, would that make sense ?

    the shader would have basically 2 brdf stages
    (diffusetexture * (brdfresult0 + ambient)) + (ssstexture * brdfresult1) + (light spec) + (env)

    basically the second brdf stage would replace the automatic SSS handling, and give you control via that ramp texture.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    well atm the rim is added on top of everything, like a regular "linear dodge" blending mode. I could use a lerp instead, so that you can use any colour including darker shades, but the effect is not that convincing with bright colours. Plus you can fake most of this using the lookup texture as CB said.
    If you have an exemple (nvida has a massive free shader library)....
    I don't know about shadows in max, but I think there's no way to do this in maya, since you have no access to a render-to-texture technique. Same limitation applies to bloom, sub-surface etc
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 16
    shadows would be limited to single object (as workaround you would need to merge a groundplane or so) in 3dsmax, as the scene effects system in max is extremely buggy

    ruz, if you could describe how you want rim to be customizeable, it would help wink.gif maybe also do a regular max shader that the behavior can be derived from.

    edit: I think I wait for max08 for adding shadows, its just too much of a hack for previous max versions.
  • Ruz
  • katzeimsack
    Offline / Send Message
    katzeimsack polycounter lvl 13
    yeah, shadows would be great! Could you just use a lightcolor map (with a second uv channel) instead of a single lightcolor? This map could be used as a shadow/light map smile.gif

    An other question, is it possible to seperate the reflektion from the specularmap? A reflektivity value or better a reflektivity map would be awesome!

    Never the less, it's a great shader, I really like it!


    btw: RUZ: could you please post your brdf image? Looks great laugh.gif
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    ola smile.gif
    why would you want a reflectivity map? specular is a reflection, so spec map drives reflection...
    so there is a reflectivity value: SpecFactor

    A lightmap is doable, I might do that as an option, such as the hemi-ambient smile.gif I'm working on a fur/grass shader atm, so it might take some time
  • Jeremy Lindstrom
    Offline / Send Message
    Jeremy Lindstrom polycounter lvl 14
    Is there like a 'how to for dummies' on this for maya? laugh.gif It's all greek to me laugh.gif
  • Joseph Silverman
    Offline / Send Message
    Joseph Silverman polycounter lvl 15
    [ QUOTE ]

    specular is a reflection, so spec map drives reflection...

    [/ QUOTE ]

    But a lot of surfaces (like some metals, and glossy wooden surfaces) are going to be a lot easier to make look realistic in a game engine if you have seperate env/spec masks.
  • katzeimsack
    Offline / Send Message
    katzeimsack polycounter lvl 13
    dito! A Blur Reflektion mask would propably be the most realistic way, but a env mask will do the job wink.gif
  • funshark
    Offline / Send Message
    funshark polycounter lvl 14
    i've tested the .cgfx in maya 8.5 just now and i have some weird "effects".
    I'm joining a screencap
    By the way, i have a 8600gt and last drivers.

    weirdshader.jpg
  • pior
    Offline / Send Message
    pior godlike master sticky
    Chiming in again. Im trying to use the shader again , this time on a vista64 machine with a 8800GT inside - I am getting the same kind of black artefacts. I must be missing something...
  • funshark
    Offline / Send Message
    funshark polycounter lvl 14
    pior> is it on maya or max ? I'm just asking myself if it may be another openGL/maya/nvidia drivers issue... ?
  • pior
    Offline / Send Message
    pior godlike master sticky
    Oh yeah I forgot to mention - the problem occurred in Maya2008 for me. Didn't test it again in Max yet.

    Also would it possible to have vertex color blending in the Maya version ? That'd be rad :P
  • dom
    Offline / Send Message
    dom polycounter lvl 15
    you sound american already.
  • funshark
    Offline / Send Message
    funshark polycounter lvl 14
    Ok, in fx composer 2, both cgfx and fx don't work. :/
    cgfx can't compile, and fx shows nothing ( i mean something invisible ).
    I think Geforce 8xxx are really crap ( drivers ) =3=
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 16
    fx composer has different semantics as 3dsmax/maya. it doesnt work this way of just "loading".

    nvidia has the best opengl drivers around, I am on 8xxx myself and developed quite shader-heavy things last half year, and it works...
  • funshark
    Offline / Send Message
    funshark polycounter lvl 14
    If nvidia had the best openGL drivers around, why there is so much issues in maya (openGL) with nvidia serie 8 cards? ( and some others )
    I had no problems with my old geforce 5700 and now: freezes, slow down with my 8600 gt
    smile.gif

    And i'm not the only one.
    I have no issues ( it seems ) in fx composer, but in maya it sux.


    Ok for the semantics. I've forgotten.
    The .fx don't shows anything on 3dsmax 8 too, with directX 9 profile ( = the same result as in fxcomposer )
  • Wahlgren
    Offline / Send Message
    Wahlgren polycounter lvl 10
    Hmm. I seem to be having slight problems and I think they relate to my inadequate amount of IQ.

    Anyway, I load up the .fx in a direct x shader material in Max and i put the diffuse, normal, ambient and specular in and the whole mesh turns black but the normal shows up.

    What am i missing? Am i supposed to use the BRDF slots? (And what is BRDF?)

    Anyway. Thanks for the help (If i get any wink.gif). Im new to max so I'm quite interested in learning more about it and it´s shaders.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 16
    the 3dsmax version was superceded with its own thread
    http://boards.polycount.net/showflat.php?Cat=0&Board=3&Number=245467

    if you visit Brice's webpage (and also linked in this thread) there is a nice giant image which explains all texturemaps.

    and yes you need the BRDF one, as the whole point of the shader is "manual control over lighting"
  • Wahlgren
    Offline / Send Message
    Wahlgren polycounter lvl 10
    Thanks man. I just didnt know what the BRDF one was for since i never used anything like that. Added one and its working alot better now.

    So yeah, It's all starting to unfold and I'm currently playing around with the shader. Once more. Thanks!
  • Eric Chadwick
    Most technique I saw use an exponent in the alpha of the cube, this might be tricky, I think it doesn't filter alpha. You might be able to combine everything into photoshop, but I never tried to load a cube in PS with its mipmaps. I'd like to hear about your experimentations

    Found this thread again in a search for something else.

    Nvidia introduced some bugs when they updated their DDS plugin, so now DDS cubes don't load mips properly. Reported it, and it sounds like it will be awhile before they fix it.

    Good news is I have an old version that loads mips correctly.
    http://www.ericchadwick.com/examples/files/2005.10.14_DDSformat_and_NormalMapFilter.zip

    Also, Cubemapgen does filter alpha properly, and mips the alpha properly too. So it's a helluva lot easier to make diffusely convolved (fake-GI) cubes that are simply stored in the lower mips of your reflection/backdrop cube.

    I wrote up some tips...
    http://www.ericchadwick.com/examples/images/Cubemapgen_Tips.jpg
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    Thanks Eric :)
    for some reason I actually never notice this - very useful as usual - last post, and it's too bad since I ran into the same problem recently :p
    thx a lot

    I haven't been updating all this for a while, I should clean it up a little :)
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    hi guys :) I now have a 8800 so I was able to mess around with a lot of stuff and clean this mess a little

    you can get a temporary version here: http://mentalwarp.com/~brice/download/GenericBRDF_2_BETA.cgfx

    I'd like to hear about your thoughts, any bug you might be experience etc. You should download the previous archive ( http://mentalwarp.com/~brice/download/GenericBRDF_1-1.zip ) to have proper brdf maps and filtered cube maps.
    The goal of this shader had always been beauty rendering and creation and was never meant to be efficient, so I guess most programmers around here would scream of so much conditional branching and all hehe.

    The changes are :
    - I (temp?) removed the rim effect, since it was kinda double-use with the ability to do non-additive rim into the brdf lookup. The artistic impact wasn't very relevant anyway.
    - I added a ton of checkboxes to allow you to use brdf lookup or not, blend brdf, normal map, spec map, diffuse etc
    - you can now display a procedural checker (set the checker value to your map size to see one square=one pixel)
    - you can now toggle hemispheric ambient with a checkbox
    - you can now use relief mapping by storing an inverted height map in the alpha channel of the normal map (you can download sample maps on fabio policarpo - the original author - page : http://fabio.policarpo.nom.br/downloads.htm#Relief)
    - you can now use self shadowing in relief mapping.
    -I added a simple technique to display vertex color since maya 2008 seems overrides the viewport settings every time you run the bake to vertices

    This last two features are still buggy and inefficient tough. I should switch to interval mapping soon to avoid going trough that many binary steps. I'm all ears concerning a better method for self shadowing. I just quickly hacked this one based on the relief mapping technique using just the linear search function. You'll notice it completely goes wrong at grazing angles and that there is no soft terminator nor any kind of AA. If I had access to a render target I guess I could do some kind of screen space blur to attenuate this but eh, it's maya... :)

    I should one day or another add another lamp since this is a common and legitimate request..

    For those of you not used to cgfx use I encourage you to browse trough the thread since most common issues have already been solved here (don't whine about your card not suporting ps3 please :) ).

    There you go, feedback now please happy polycounters :P
  • MoP
    Offline / Send Message
    MoP polycounter lvl 16
    Nice one, I will try it at work tomorrow, been looking for a good viewport shader for Maya2008 and while I tried your old one, seems Maya really didn't like it... good timing :)
  • pior
    Offline / Send Message
    pior godlike master sticky
    booo-ooo for the dead rim light effect! Used it all the time :(
    Can't wait to try the self shadowing tho!!!
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    I'll put it back just for you my dear <3 I thought you were the one telling me it was kinda useless, misunderstanding I guess.

    Beware that self shadowing only works for small scale details, the ones stored into the height map use in relief mapping. You won't be able to have an arm shadowing the torso, but a normal mapped pattern will project micro scale shadows on itself.
  • pior
    Offline / Send Message
    pior godlike master sticky
    Well usually I put a bit of a rim in the brdf texture, and then strengthen it using the two sliders you have at the very bottom... I know it's double use but it makes things easy for me :P
  • funshark
    Offline / Send Message
    funshark polycounter lvl 14
    nice!
    i'll test this asap!
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    relief_shadows.jpg

    [edit] I just noticed I used a wrong normal map on these screens but I'm too lazy to do them again, so here's another one (using an old brdf sampler pior did back in november i think)

    relief_shadows2.jpg
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    Hi guys :) Pior asked for object space normal map so here's a new version
    http://mentalwarp.com/~brice/download/GenericBRDF_2_BETA2.cgfx
    I might create a separate technique for this in the end since I could skip a lot of vertex code. People are less likely to want to switch from OS to TS on the fly with a checkbox.

    The problem with world space normal map is that the rotation is fixed. So the easiest solution is to connect the transform of the object with the shader so that it computes properly the object orientation. So far I didn't found a convenient way of doing in maya. The easiest so far is to open the connection editor and do the following connection between you mesh and the shader:

    connection.gif

    The problem is it starts to get wrong if you translate the object, and none of the provided matrix seems to work properly in all case. A simple workaround is to freeze the translate transform, just remember never to touch the rotation transform. You can of course skip that part and leave "Use object transform" unchecked: you won't be able to rotate the object but you can translate it.

    Also remember that object space normal map will produce more banding artifacts, since it has around half the precision.

    I'm all ears if anyone has a better solution. My guess is that I will use the rotate transform rather than a pre-combined matrix and manually create rotation matrices and convert degree to radians, even if that's pretty (very) ugly.

    I also improved the efficiency of the shadow algorithm. I'm looking now at the POM solution to achieve soft shadows.

    In the future I guess I'll split this in several shaders: regular one, full and one for more environment related stuff (shadow maps, radiosity normal map).
  • pior
    Offline / Send Message
    pior godlike master sticky
    Yessssssss
    Clean normals here I come!
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    http://mentalwarp.com/~brice/download/GenericBRDF_2_BETA3.cgfx

    object space normal map now works with both mesh translation and rotation (not scaling). You still need to connect the matrix with the shader, it is likely that there's no workaround. yatta yatta
  • butt_sahib
    Offline / Send Message
    butt_sahib polycounter lvl 11
    man i envy you maya guys, hear hear for brice! :D
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    diablotinOS.jpg

    I had no mechanical models for testing so I just baked an old face I had on my harddrive as an example (I never did object space normal map before actually, it's working pretty well :) )

    thx for your support sahib, you know it's not that hard to use maya, especially if it's just to mess around with shaders :P
  • Negative_Z
    // cgfxShader "cgfxShader6" loaded effect "/Users/rev19/Odds/bonus!/CgfX/GenericBRDF_2_BETA3.cgfx" //
    // Warning: (1270) cgfxShader node "cgfxShader6" has invalid attribute "objectMat" - ignored //
    // Warning: (2513) cgfxShader node "cgfxShader6": unable to initialize attribute "objectMat" //
    // Error: //

    what's up with that? it's all pink'n stuff. BrDF 1-1 works, is it my vid card? I'm on a mac with a ATI,RadeonHD2600, maya 2008 ext2.

    Thanks!
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    yeah I got that 'error' as well but it's just a warning, the shader runs fine, the problem might be somewhere else. objectMat is used for object space normal map only so it shouldn't be an issue in most case.
    Have you put a vertex color and linked it? I should put a checkbox for this as well
    Sorry I know nothing about ati hardware, even less about apple's :)
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    hi there
    I'm not getting the feedback expected so I'm removing the direct links to the beta until I update the shader page on my website with the final version. Thanks to those you participate.
  • pior
    Offline / Send Message
    pior godlike master sticky
    All I can say is that the ones not trying this out are really missing on a great tool!
    As far as more feedback and suggestions ... I know I would love to see some sort of support for dynamic viewport castshadows casted from the geometry on itself (on top of what you already have and from the 'faked' surface on itself).

    Also, a way to modulate the rimlight strength according to normals up/down orientation.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    like this?

    rim.jpg
    http://mentalwarp.com/~brice/download/GenericBRDF_3_BETA.cgfx

    parameters should be reorganized somehow...
    sorry there's no way atm to have shadows. There might be a way to sample the shadow maps from the highquality rendering mode, but I don't know how yet.
  • rooster
    Offline / Send Message
    rooster mod
    i'd like to just say i'm very interested in the shader but I've had an unsuccessful history in getting cgfx shaders to work in maya, (the few that I've tried, but on two seperate machines), and generally the ones I have used have said 'heres this great shader!' but neglected to mention how the deuce you use it if youve never touched cgfx shaders before. (or I follow the steps but it's knackerd and theres no trouble shooting solutions)

    ok so I probably sound like a bit of a dunce from that but there's my own reason for not having a go yet..
  • pior
    Offline / Send Message
    pior godlike master sticky
    Awesome!!! Will try asap. Too bad about the shadows...

    Rooster, it's quite easy really. Just create a CGFX material, and load the file. You might want to have a few bogus maps ready to fill in unused slots : Basically one black, one white, one grey, and one normalblue tga. Other than that it's dead easy!
  • MM
    Offline / Send Message
    MM polycounter lvl 14
    this looks very nice but i havent been able to get it working(proper normal map,color etc) in any version of maya.

    what version of Maya are you using Brice ? and i see that you said u have 8800 now, so is that where u taking these screenshots ?

    i am been testing on Maya 2008 and Maya 7 with 8800 cards on win xp64 and vista64 with no luck.

    i will post some screenshots later. this looks really useful i do really appreciate you developing this and sharing this, thanks.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 16
    rooster, cg being made by nvidia, and many people using only the "nvidia proprietary" compile formats, means typically that many shaders wont work with non-nvidia hardware. (which applies to this shader as well)
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 15
    hi MM I'll wait for your screenshots. I'm using both a xp32/Geforce6800/maya8 and and xp32/8800GT/maya2008 and I had no problem (tough relief mapping is not really recommended on earlier hardware). Anyway, the way you mention it, it seems like you have a result but that it's not what you expect so that might just be a configuration issue.
    Don't forget to post your parameters AND vertex inputs :)

    @CB: so far rooster doesn't have any problem, except not trying because he previously had bad experience, something I can't really do anything about ^^
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    yeah, im getting maybe same problem as MM with this shader too, im using 8800gts and x64 maya 2008
  • MM
    Offline / Send Message
    MM polycounter lvl 14
    hi Brice, i actually got it working at home computer now on maya 2008 in xp64.
    are there ways to add multiple light sources and intensity to each ?

    earlier i was trying both maya 7 and 2008 on vista64 at work and got really solid black shadow like a toon shader.
    i used default settings mostly. i will post these tomorrow.

    btw, what are vertex inputs ?
245
Sign In or Register to comment.