Home Technical Talk

Maya shader question

polycounter lvl 19
Offline / Send Message
kodde polycounter lvl 19
Hey guys,

I'm trying to set up a shader in Maya that will let me choose between two different texture files depending on which side of the surface is facing the render camera. The catch is that I would like it to work in the Viewport/Maya Hardware.

I know there's a useful samplerInfo node that has a flippedNormal attribute that does exactly what I'm looking for, but I only get it to work with Maya Software and not Hardware. The normalCamera attribute also won't work with hardware for me.

What am I trying to accomplish? Simulating backlighting on translucent surfaces such as leaves and paper.

Any ideas?

Thanks.

Replies

  • Ark
    Offline / Send Message
    Ark polycounter lvl 11
    I know XSI as a shader called 'Front/Back' that does this, only i don't know if it's a MR shader, so it may not be in Maya.

    Have you tried the technique listed in the Polycount wiki about inverting normal maps?

    http://wiki.polycount.net/Normal_Map Scroll 3/4 of the way down, its under the heading 'Backlighting'
  • hijak
    As far as i know you cant do this in real-time with mayas stock shaders. Your best bet if your goal is in view port renders is to create a cgfx shader that does what you like. If your most comfortable with using a node based shader creation method i reccomend using Mental Mill to create your shader and export in cgfx format for use in maya. The shader may require tweaking in an app like nvidia FX composer but its a simple 1 line change to enable front/back checking. If an option like this sounds good lemme know i can offer soem hlep in how to achieve that result.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Hey thanks for the replies guys.

    Ark> Yes that's one of the effects I'm trying to achieve. I have tried inverting the normal map and the method works fine. What I'm after now is a shader that will switch textures automatically.

    hijack> That sounds really interesting. I will try to find some time tomorrow to give Mental Mill a try. I will ask for your advice here when I get started. Thanks for your offer.
  • glib
    It is completely possible to do in maya with stock shaders, I did it about a year ago. Unfortunately I've been max-centric for almost a year now and I've forgotten nearly everything maya-related.

    Don't give up on it, keep looking around. I'll try to do some digging around tonight after work if I remember.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Glib> Hmm... you sure you had it working in the Viewport? Cause I figured how to do it with the Software Renderer.

    I had a second look in the Hypershade stock nodes and I cannot figure out any method besides comparing the normals of the sampled surface and the rendered camera in order to determine if the surface is facing towards or away from the camera. The only node I can come up with at the moment for this is samplerInfo.
  • hijak
    well you could always just duplicate the faces and reverse the normals. Then you have 2 sides you can use diff materials on.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    That's actually what I did when testing on a single plane for a leaf. But I would also have to offset it's position slightly to avoid any flickering right? That's what I did anyway.

    But I wouldn't mind finding a prettier solution if you know what I mean.
  • glib
    Oh sorry, yeah I only ever had it working in the render. I didn't read your first post carefully enough.

    hljak is right that you're going to have to look at cgfx shaders to get stuff like that in viewport.
  • bugo
    Offline / Send Message
    bugo polycounter lvl 17
    doesnt transluscense from blinn or phong make the effect you want? I'm pretty sure it does, try testing it out. It doesnt do rim lighting, only transluscent effect. And it works on hardware render.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Bugo> Yes that is pretty much the effect I'm after. Thanks. But I'm still curious on how you would solve switching texture file depending on which side is facing the camera. I think this could come in handy for a few other areas. :)

    BTW. Mental Mill Artist Edition only has support for 3DSMax exporting? I would have to purchase the Standard edition to try this out with Maya I suppose. https://www.mentalimages.com/products/mental-mill/artist-edition.html
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Well I downloaded Mental Mill and started toying around a bit with it, seems really neat. Although not being able to export/save anything that I can use is a major turn off.
  • hijak
    why cant you save or export. It exports to GLSL HLSL CGFX and even has specific settings for max maya and softimage. I guarantee you can export into maya.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    I thought the Artist Edition was the free download one? And it does not allow you to export to the formats you mention. You need the Standard Edition for that.

    http://www.mentalimages.com/products/mental-mill/artist-edition.html

    So my conclusion if I'm not mistaking, I have to cough up 500$ to get the shaders in Maya. :(

    Oh btw, I spent a while long in Mental Mill Artist Edition this afternoon and I'm really liking it so far even though I haven't comprehended everything yet.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    hijack> Either way, do you know how to achieve the effect I'm after in Mental Mill? Could you explain? Thank you.
  • hijak
    just to clarify do you want which of the following.

    front/back based from orientation to camera.

    Front/back based from surface normal.

    front/back based from lighting direction.

    I think lighting direction is prob most accurate if your trying to simulate back lighting on translucent objects.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Light dependent would be probably work best yes.
  • Brice Vandemoortele
  • hijak
    And hand written shader like the one Brice shows would be the most elegant way to dot his, mots efficient too. I figured hed pop on here at some point and give us a quick example.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Yeah that's what I was looking for. I suppose your created this manually with FX Composer or similar?

    Thanks for sharing the shader Brice, not sure I can really read what it actually does. Care to break it down in laymans terms? :)


    hijak> Yeah, Brice is a synonym to CGFX. Been praising his Fake BRDF shader since long now.
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    hi guys :) i was expected uh? :D
    i made this one using the usual notepad++. It blends two texture together depending on how much the surface is facing the light. 'Blend' controls the amount: when set to 1 the only points where textures don't blend are the ones where the normal face perfectly the lamp. increase above 1 and the transition gets tighter.
    You can actually have a better blend by replacing 'lerp' by 'smoothstep' in the sourcecode. give it a try you just need to dl the link below the image. (LightColor actually does nothing, i just forgot to remove it)

    cheers
Sign In or Register to comment.