modify normal map intensity in maya

I have never been a big fan of normal maps. It’s difficult to manipulate them, it’s hard to guess how they might influence your shading and – probably the worst part – it’s not possible to modify their strength in maya. This is why I avoided them most of the time in favour of bump maps even though normal maps can look a lot better.

Luckily, I found this thread where NextDesign posted a solution to enable normal map strength editing right inside of maya. It’s a bit tricky and it would be quite a pain, to wire everything together, everytime you want to use a normal map. This is why I decided to write a script for that. You just need to select your file node, run the script and you are ready to go. Now you can use the bump depth slider on your bump2d node to modify your normal map contribution – just as with your old school bump map. Isn’t that awesome?

It seems it is even possible to invert your normal map when you dial in negative values. And of course it works with every renderer that uses the standard maya bump2d & file node.

Happy shading!

#select your file node that is connected to your bump2d node and run the script

from pymel.core import *
def normalStrength():
    myNormal = ls (sl=True)
    myBump=listConnections( myNormal[0].outAlpha, d=True )
    myBump[0].bumpDepth >> myNormal[0].colorGainR
    myBump[0].bumpDepth >> myNormal[0].colorGainG
    myBump[0].bumpDepth >> myNormal[0].colorGainB
    
    expression(ae=False, n=myNormal[0] + '_normalMapExpression' ,o=myNormal[0], s='colorOffsetR = (1 - colorGainR) * 0.5; \ncolorOffsetG = (1 - colorGainG) * 0.5; \ncolorOffsetB = (1 - colorGainB) * 1.0;' )
    
normalStrength()

Posted

in

by

Tags:

Comments

10 responses to “modify normal map intensity in maya”

  1. tehWever Avatar
    tehWever

    You are not entirely clear how to use it. Do you select your bump2d node and execute it? It returns
    # Error: line 1: AttributeError: file c:\binded_pkg\maya\2014.0\platform-windows\arch-AMD64\ext\Python\lib\site-packages\pymel\core\nodetypes.py line 332: nt.Bump2d(u’bump2d1′) has no attribute or method named ‘outAlpha’

    I’d like some clarification on this smile

  2. stefan Avatar
    stefan

    Hey! smile
    You need to select the file node (that is connected to your bump2d). I edited the script above to make that more clear. Thank you for pointing this out. Let me know if it works for you then! smile

  3. Paul S Avatar
    Paul S

    Hello ! i am not a pro in Maya and when i run the script (after select my file node of course) maya told me :

    normalStrength()
    # Error: NameError: file line 2: global name ‘ls’ is not defined #

    Any Suggestion please ? :s

    Paul S.

    1. stefan Avatar
      stefan

      Hey Paul,

      Make sure to run
      from pymel.core import *
      at first! Pymel is a special python flavour in maya and you need to import it everytime you launch a new maya session.

  4. Paul S Avatar
    Paul S

    Hello Stefan ! Sorry, didn’t see your response ! BUUUT, it’s work PERFECTLY now !
    Thanks x1000 ! surprised

    1. stefan Avatar
      stefan

      Awesome smile Great to hear!

  5. Garry C Avatar
    Garry C

    You my friend are an absolute master! Thank you for this script smile

  6. k3b3 Avatar
    k3b3

    Thank you from Russia. Very useful script

  7. Tom Cowlishaw Avatar
    Tom Cowlishaw

    Hey thanks for this! it connects up all fine but it seems to just make the result appear black. Any ideas why this is?

  8. Carl Avatar
    Carl

    Im getting the same.

Leave a Reply

Your email address will not be published. Required fields are marked *