Specular, diffuse and ambient lighting per light

 

Well, that time, for once I won't say like I use to (sorry for that) that I found a new way to better illuminate your pretty models.

In my last light tip, I was claiming that I did find a shading network that kinda 'dim' the highlights of low intensities highlights. In french in the text, it means that if you use a skyDome base lighting for 'GI', you can (partially) get rid of those little annoying specular smudges topping your shiny shaders.

This method works pretty well if your shader is not too shiny. So if you have a shader which has a strong and sharp specular highlight, heeehaaa, well done Emmanuel, once again, you really took us for fools... You still have your naughty small specular smudges.

Not this time my friends.

 

I wasn't thinking of using that attribute, because all my tests I've done about it were unsuccessful. But the solution is in it. It's written in the doc, we can see it when we open the connection editor, but I always failed when I wanted to use this (actually these) attributes as they are!

What am I talking about? Maybe some of you are still unaware of some Maya 4 light features. I'm actually talking about diffuse and specular lighting.
In Maya 4, you can specify which component you will affect, specular, diffuse, or both of them. It's really useful when you want to get a particular lighting effect or when you want to do hyper-realism.

In my method, it's a bit more complicated, you need to create more shaders, and it's consequently longer to render (not that much anyway), but it's worth it until Maya 4's official release.

Ok, 3d people, if you don't know it, on each light you work with, you have a particular attribute named lightData. And on each shader you work with, you also have a lightData attribute.

The thing is that if you connect the lightData attr. of a light into the lightData of a shader, this shader will only be affected / lit by the light you previously connected, no matter how many or what intensities are the other lights. And this is just one thing.
The other thing is that under lightData, you find some very interesting attr.: ambient, diffuse, specular, and the now famous and rich Mr lightShadowFraction among others.

Now, I imagine that I can set the lightData.diffuse of my shader to 0*, I'll only have a specular highlight??!! The same for specular if I set the lightData.specular to 0*, would I only have a diffuse lighting??!!!! Too easy to be true, isn't it?? ;)
And I bet you it also works with the lightData.ambient! That's really a thing!!

*: Actually the command setAttr shader.lightDataArray.diffuse or .specular or .ambient doesn't work (message: // Error: No objects matches name: blinn1.lighDataArray.specular 0 //)

So, you need to create a ramp (without 2d placement), remove 2 colors, and set the third one to black or white (0, or 1) and connect the outAlpha to the lightData.specular or whatever attr. to force the shader no to be affected by a light's component.

The fake is to create a shader for the specular lighting (and fortunately, you do use as many lights for specular as for diffuse), and one for the diffuse lighting.
Preferably, a blinn (or any shiny material) for the spec, and a simple lambert for diffuse ;-) You need then to create a layerShader, and add the blinn first then the lambert shader to the layerShader.

Assign the layerShader to your object, and you'll have a perfect diffuse lighting plus a (so alone) specular highlight. If you need to add more specular highlights, just repeat the operation for your others 'specular lights' (remember, one shiny shader per spec. light), and add the newly created shaders to your layerShader.

 

Additions (April 7th 2001):

Here is an example:
In this scene, I just have a simple nurbsSphere, mapped with a blinn material. I have 3 area lights (3 rectangular specular shapes), and 3 directional lights.
This image illustrates what we all have 'by default'.

This is really nice, but you can notice that I have some cool spec shapes (area lights) but what if I don't want the dir lights's specular highlights?

 

To get rid of the specular highlights you don't want, do what I explain above, create as many 'shiny' shaders as you have 'specular lights', and connect each lightData of those lights into the lightData of the shaders. Create a layerShader (like I said) and add all your 'shiny' shaders to it (set their transparency to 1) and just change the first (original) blinn material to lambert and add it (last shader layer). Assign the layerShader to your object, and render hot.

Here is (for 3 area lights) the shading network you have with those connections (the presence of the 3d placement node is explained at the end of this tip)

Now, with your brand new shading network, this is what you can get (with your maya 3 version!!)

The specular highlights of all the directional lights are removed because only the lambert shader is affected by all the lights (including area ones), but as a lambert material, there is no specularity.
The other blinn materials are only affected by the lightData.specular of each area light.lightData connected to them, and I repeat again, but you need as many blinn (or whatever shiny materials) shaders as you have specular lights.

And one main advantage regarding Maya4 light's features is that with the same light, you can affect then the specularity of one shader (i.e. no specularity) and let another material be shiny. In Maya4, you'll have to duplicate the non-specular light, and uncheck specular (and check diffuse lighting) to have the same effect. (but you'll just need one shader) ;-)

This is it folks!! You can download this example scene here...

 

Emmanuel

 

 

In the image shown above, the area lights's specular highlights are slightly better than usual (less curved).
Here is the basic normal render, and as you can see, the difference is really noticeable (and the position of the lights are the same for both images)


To avoid that disaster (and by the way to be fired from your company), here is the little trick I found (for still images only)
Create a simple 3d texture placement, and scale it wild (xyz= 10000), then connect the matrix of the 3d placement to the matrixWorldToEye attr. of the light.

Your lighting will differ then, so re-adjust it to get the cooler effect you can. Sorry you have to re-make your lighting, but the result is really really worth it. You specular shapes follow almost exactly the curvature of the object, and are less distorted like default area lights.

 

 

One last trick I've just found (and I hardly think this is normal) but as the effect is funny, let me share this with you.

Here is what you can get with area lights only. Enter '-' (minus) in the value of scaleZ (i.e.: if scaleZ = 1, modify as follow: scaleZ = -1), and you'll have that perfect smooth border of specularity (The border depth vary depending the eccentricity of your blinn material)

 

Now this is really over.

Have fun and wish me good night!!

 

Emmanuel Campin - (c) May 2001