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
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'
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.
Don't give up on it, keep looking around. I'll try to do some digging around tonight after work if I remember.
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.
But I wouldn't mind finding a prettier solution if you know what I mean.
hljak is right that you're going to have to look at cgfx shaders to get stuff like that in viewport.
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
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.
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.
http://www.mentalwarp.com/~moob/show/polycount/backFace.cgfx
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.
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