View Full Version : controlling a shadows-only light HELP!!
masterlaws 10-31-2006, 11:57 PM I am using maya 7.0 and I understand that you can create a light that is set to cast shadows only (e.g. no light), by changing the color of the light to black, and giving it's shadow color a negative value. I believe that this is just a "hack" and isn't really considered a shadow by maya. This is problematic for me because when I want to make different passes (diffuse, shadow, specular, or occlusion)of my scene, maya doesn't interpret that "shadow" that I made as actually being a shadow, and is therfore excluded from my shadow pass. The funny thing is, I don't know what maya thinks it is, because every pass that I render out (dffuse, shadow, spec), maya excludes the the faked shadow from it. The only time I can ever see it is when I use the default Beauty pass.
I have tried rendering out in both mental ray and maya software in a simple environment including a sphere, a plane, and two lights. One light just lights the scene with no shadows. The other light, only emits shadows.
So I guess my primary question is, is there some way to take control of this faked shadow as it's own pass? Are there any work arounds? Am I missing some crucial settings?
Thanks a lot
-L
|
|
jeremybirn
11-01-2006, 12:57 AM
If you're rendering a shadow pass, then you can set the light back to normal (white color, black shadow color).
In a shadow pass, every light is a "shadows-only" light, so you wouldn't need those special settings or hacks at all.
-jeremy
masterlaws
11-01-2006, 01:55 AM
Wow, that was easy. Thanks Jeremy. I guess I should have thought about that a little bit more.
Also, a little thing that I noticed that was very aggravating (until I figured it out), about Maya's render layer Presets (like spec, shadow, diffuse, etc) is that once you assign a preset to a layer, you can't just go and assign the layer a different one if you feel like it. It won't work properly. You first have to tell it "Remove Render Setting Overides". THEN assign a new preset to it.
For example, with my ball and plane example (from above), if I select all of the elements in my scene and assign it to a new render layer, as usual, and then assign it the preset of Diffuse and render it out, it works perfectly. I get a diffuse pass. But if I then change the layer preset to Shadow, and render it out, it's just all black and the alpha is all white (no indication of a shadow present). But if I tell the render layer to "Remove Render Setting Overides", and THEN assign the shadow preset to it, I will get all black, but with the correct alpha, indicating the shadow. A weird thing about this though is that I can then go and assign the layer back to the diffuse preset (without removing the render setting overides), and have it render exactly like first time I did it in the example. So it seems like you can switch between SOME presets (without first having to remove the overides) fine, but not with all.
My guess is that this is a bug, but then again my experience in 3D and Maya is very limited, so what do I know.
I just thought I would mention this (if no one else has already) and hopefully relieve some of the aggravation that some users may be feeling when using these render layer presets.
Thanks again Jeremy
-L
faultymoose
11-01-2006, 02:43 AM
If you want a shadow-light rig that will cast shadows only, as well as generate shadows in a shadow pass, you can set up a control light linked to two separate lights - one with a positive intensity setting and shadows turned on, the other with the exact negative intensity and shadows turned off.
masterlaws
11-01-2006, 04:39 AM
Dan, that worked great for me. This way I don't have to keep switching my light's properties back and forth for the specific pass that I want to make; it just works all of the time.
I have a question though. I made the two lights, but I don't know how to make the control light that you were talking about to drive the other two lights. It's not that big of a deal because I probably won't change the lights that much, but just for the sake of knowing how I would be interested to figure this out. Forgive me; I have just started tinkering with lighting and rendering :) So when you talk about linking the control light to the other lights, how do I do this? I am only familiar with the relationship editor with linking lights to objects. But I have a feeling that this has nothing to do with what you are talking about.
Thanks a lot.
faultymoose
11-01-2006, 08:59 AM
Given three lights: One control light, one positive light with shadows, one negative light without shadows...
1. Turn off DIFFUSE and SPECULAR on the control light, and turn off specular on the posi and negi lights.
2. Using the connection editor, connect everything except the intensity with the control light as the output, to both the posi and negi lights.
3. Connect the intensity from the control light directly to the posi light, and through a multiplyDivide node set to multiply the value by -1, into the negi light.
That's kinda it, but it's not quite so easy. Many of the non-keyable attributes won't show in the connection editor, and the whole process is easier via a script (which I have written, but it's at work). I can post the script tomorrow - it will take any selected light (of any type) and generate a shadow casting light from it. The only problem with my script: you can't select the light and "look through selected". I think it's because my method is to group the posi and negi light underneath the control light, so maya doesn't know which shape node to use to "look through". I should change the script to use constraints instead...
faultymoose
11-01-2006, 11:27 PM
Here it is. It's not very elegant scripting, but then, I'm not a very elegant scripter :)
//===========================================================================================
// FMShadowLight // Generate Shadow Light from selected lights
//===========================================================================================
global proc FMShadowLight(){
// DECLARE VARIABLES
// --------------------------------------------------
string $lightTransforms[]; // Stores the light transform nodes selected for the script
string $attributes[]; // Stores the list of attributes per light
string $lights[]; // Selected light shape nodes
string $sel[]; // All selected objects
string $attrib; // Stores the currently selected attribute
string $originalSelected[]; // Stores the original selected list
string $posiLight; // Stores the name of the shadow spot rig's positive light
string $posiLightShape; // Stores the shape node of the positive light
string $antiLight; // Stores the name of the shadow spot rig's negative light
string $antiLightShape; // Stores the shape node of the negative light
string $shadowLight; // Stores the name of the shadow spot rig's control light
string $shadowLightShape; // Stores the shape node of the control light
string $testArray[]; // Variable to store test values
// POPULATE SELECTION LISTS
// --------------------------------------------------
$sel = `ls -sl`;
$lights = `listRelatives -ad -type light $sel`;
if (size($lights) == 0){ error "You need to select at least one light."; }
// CREATE SHADOWLIGHT RIG
// --------------------------------------------------
// Select light transforms
$lightTransforms = `listRelatives -parent $lights`;
for ($shadowLight in $lightTransforms){
// Create duplicates---------------------------------------------------------------------------------------------------------------------------------------------------
$posiLight = $shadowLight+"_FMPosi"; $antiLight = $shadowLight+"_FMAnti";
duplicate -name $posiLight $shadowLight; duplicate -name $antiLight $shadowLight;
parent $posiLight $shadowLight; parent $antiLight $shadowLight;
// Store shape nodes---------------------------------------------------------------------------------------------------------------------------------------------------
$testArray = `listRelatives -children $shadowLight`; $shadowLightShape = $testArray[0]; clear($testArray);
$testArray = `listRelatives -children $posiLight`; $posiLightShape = $testArray[0]; clear($testArray);
$testArray = `listRelatives -children $antiLight`; $antiLightShape = $testArray[0]; clear($testArray);
// Turn off all illumination on $shadowLight control light and specular on the child lights----------------------------------------------------------------------------
setAttr -lock on ($shadowLightShape+".emitDiffuse") 0; setAttr -lock on ($shadowLightShape+".emitSpecular") 0;
setAttr -lock on ($posiLightShape+".emitSpecular") 0; setAttr -lock on ($antiLightShape+".emitSpecular") 0;
// Lock transform attributes for child lights--------------------------------------------------------------------------------------------------------------------------
setAttr -lock on -keyable off -channelBox off ($posiLight+".translate"); setAttr -lock on -keyable off -channelBox off ($antiLight+".translate");
setAttr -lock on -keyable off -channelBox off ($posiLight+".rotate"); setAttr -lock on -keyable off -channelBox off ($antiLight+".rotate");
setAttr -lock on -keyable off -channelBox off ($posiLight+".scale"); setAttr -lock on -keyable off -channelBox off ($antiLight+".scale");
// Find connectable attributes on $shadowLightShape node and make connections to child lights--------------------------------------------------------------------------
$attributes = `listAttr -multi -unlocked -keyable -write -read -visible -connectable $shadowLightShape`;
print $attributes;
for ($attrib in $attributes){
connectAttr ($shadowLightShape+"."+$attrib) ($posiLightShape+"."+$attrib); connectAttr ($shadowLightShape+"."+$attrib) ($antiLightShape+"."+$attrib);
setAttr -lock on ($posiLightShape+"."+$attrib); setAttr -lock on ($antiLightShape+"."+$attrib);
}
// Connect shadow attributes on $shadowLightShape node to $posiLightShape----------------------------------------------------------------------------------------------
clear($attributes);
$attributes = {".dmapResolution", ".useMidDistDmap", ".useDmapAutoFocus", ".dmapFocus", ".dmapFilterSize", ".lightRadius", ".shadowRays", ".rayDepthLimit"};
for ($attrib in $attributes){
connectAttr ($shadowLightShape+$attrib) ($posiLightShape+$attrib);
setAttr -lock on ($posiLightShape+$attrib);
}
// Turn off shadows on the $antiLightShape, disconnect the connections (if they exist) and lock the attributes---------------------------------------------------------
clear($attributes);
$attributes = {".useDepthMapShadows", ".useRayTraceShadows"};
for ($attrib in $attributes){
setAttr -lock off ($antiLightShape+$attrib);
if ((`isConnected ($shadowLightShape+$attrib) ($antiLightShape+$attrib)`)){ disconnectAttr ($shadowLightShape+$attrib) ($antiLightShape+$attrib); }
setAttr -lock on ($antiLightShape+$attrib) 0;
}
// Create reverse node and connections
createNode multiplyDivide -n ($shadowLight+"_antiIntensity");
connectAttr ($shadowLightShape+".intensity") ($shadowLight+"_antiIntensity.input1X");
setAttr ($shadowLight+"_antiIntensity.input2X") -1;
setAttr -lock off ($antiLightShape+".intensity");
if ((`isConnected ($shadowLightShape+".intensity") ($antiLightShape+".intensity")`)){ disconnectAttr ($shadowLightShape+".intensity") ($antiLightShape+".intensity"); }
connectAttr ($shadowLight+"_antiIntensity.outputX") ($antiLightShape+".intensity");
// Turn on depth map shadows for control light
setAttr ($shadowLight+".useDepthMapShadows") 1;
}
}
CGTalk Moderation
11-01-2006, 11:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.