PDA

View Full Version : Luminous shadow? Multiply shadow? how?



Exception
12-20-2008, 10:04 AM
We used to be able to do this with the luminous shadow darkening tool of G2, but I don't have G2 and I was hoping it could be done easily in native LW.

You have a polygon with a front image mapped texture set at 100% luminosity, and want the shadow of an object to fall onto it. How do you do this easily and effectively without having to mess with a balance between lum and diffuse of the surface?

I heard somewhere some of DP's nodes could do this?

gerardstrada
12-20-2008, 06:11 PM
Yes, DP Shadows node can help here. A way could be to input our image map (Image or ColorLayer nodes) into BGColor of a Gradient node, and Regular output of DP Shadows node into the input parameter of the Gradient node.

In the gradient we can choose the shadow color and control it's opacity with the alpha parameter. Choose Multiply for Blending. Then we connect the Gradient Color output into Diffuse Shading input in the Surface Root.

There are other ways with Mixer tool but the good thing about Gradient with DPShadows node is that we can texture our shadows in a similar way than ShadowDesigner. Do enable the Show Output Key to simulate Caustics and other interesting effects.



Gerardo

Exception
12-21-2008, 08:10 AM
Thanks Gerardo, for helping out.

I follow your train of thought and it seems like a very good solution. However I'm not very much a node-person and I tried to set it up but it doesn't work. I've attached a screenshot of the setup, perhaps you can see where it fails?
The problem is that there is no shadow. The surface is set to 100% luminous, 0% diffuse.

Axis3d
12-21-2008, 10:36 AM
Here's a method that I've used before:

1. Make a clone of your ground polygon or terrain.

2. Make the surface color black with 0 diffuse and 0 luminosity, no spec, etc. Pitch black. Then in the Advanced Tab for that surface, next to Alpha Channel, set that to Shadow Density. This tells that surface to only make an alpha channel in the shape of the shadow falling onto it.

3. For all the other objects in the scene that are casting shadows, I check "unseen by Camera" in the Objects Properties panel.

4. Next, I render a frame out (it should render black) and save this image (in a format that saves a 32 bit alpha, like PNG32). The alpha channel for this image should just look like your shadows.

5. Next, delete the black ground object from the scene and tell your objects to be seen again.

6. Load the PNG32 image into the Image Editor. While there, click on the Clone dropdown and select "Instance". Select the instance in the list in the left and under Alpha Channel, select "Alpha Only". press ctrl+F7 to open the Compositing Tab.

7. Under Foreground Image, select the first image that you loaded (it should be black). Under Foreground Alpha, select the instance (it should be just the alpha). You can use the Foreground Dissolve to lessen the intensity of the shadows if you want.

8. Render your frame.

Hope this helps.

gerardstrada
12-21-2008, 02:00 PM
Thanks Gerardo, for helping out.

I follow your train of thought and it seems like a very good solution. However I'm not very much a node-person and I tried to set it up but it doesn't work. I've attached a screenshot of the setup, perhaps you can see where it fails?
The problem is that there is no shadow. The surface is set to 100% luminous, 0% diffuse.

Sorry, forgot to mention:

First Gradient parameter defines shadow color (alpha controls its opacity)
Second Gradient parameter should be white.

Diffuse Shading overrides diffuse and luminosity channels.

Everything else in your setup is perfect.



Gerardo

Exception
12-22-2008, 10:54 AM
First Gradient parameter defines shadow color (alpha controls its opacity)
Second Gradient parameter should be white.


Ok, I am trying this but now the entire polygon ends up being pitch black.
I attached a screen shot of its current setup.

gerardstrada
12-22-2008, 05:12 PM
Weird, it always had worked out here. The same setup works also for a Luminous Shading Darkening (shades from indirect illumination provided by radiosity), by subtracting from a diffuse model with radiosity enabled, same model with radiosity disabled - instead of DP Shadows). If there's a problem, it should be due to an external factor to the Surface Node Editor.

l If you don't find a solution, you might attach your scene (a simple one) and I'll try to take a look barely I can.



Gerardo

adk
12-22-2008, 10:23 PM
Heya Tom ;)

Works here ... the trick seems to be with the gradient alpha. I can't get it to work with area lights yet ? - then again I have only mucked about for 5 mins. Thanks for the tip Gerardo :thumbsup:

Exception
12-23-2008, 04:43 AM
I think the problem here is that I am actually not using lights, but an HDRI to light the scene. So everything is in shade according to the node, perhaps.

faulknermano
12-24-2008, 03:47 AM
i just wrote this simple LSD lscript shader. it won't solve the HDR lighting problem, because it can only calculate direct light rays / shadows. but if any one wants a non-G2 LSD, this script could fill in. (not rigourously tested)



@warnings 0
@version 2.3
@script shader

mylight;
mylightint;
mytime;
maxval;
ready;
OKtoRun;
create
{
app = runningUnder();
if(app == MODELER)
OKtoRun = false;
else
OKtoRun = true;
setdesc("Luminous Shadow Darkening");
mytime = Scene().currenttime;
}

init
{
mylight = Light(1);
mylightcolor = mylight.color(mytime);
maxval = findColorValue(mylightcolor);
}

flags
{
return(LUMINOUS,DIFFUSE); // we will modify the color of the texture
}
cleanup
{
mylight = nil;
}
newtime: frame, time
{
mytime = time;
}

findColorValue: color
{
mc = max(color.x,color.y);
fin = max(mc,color.z);
return(fin);
}
process: sa
{
if (!OKtoRun) return;
wpos = <0,0,0>;
wpos.x = sa.wPos[1];
wpos.y = sa.wPos[2];
wpos.z = sa.wPos[3];
if(sa)
{
(illum,vec,color) = illuminate(mylight,wpos);

colorval = number(findColorValue(color));
sa.luminous = colorval / maxval;

sa.diffuse = 0.0;
}

}






edit: you may experience crashes when removing the shader... dunno why.

Exception
12-24-2008, 05:55 AM
Ok, I got it... quite simple node setup, but it works... can probably be combined with the earlier node setup to account for both lights and HDR lighting.

gerardstrada
12-24-2008, 11:55 PM
That's a viable solution. But you might want to have a bit more control. i.e.:in order the image texture doesn't get tinted with the HDRI lighting we'd need to set up 0% for diffuse channel. But in that case we'd lose the colored shading too.

Before the nodal system, we needed to render separate passes and compose them by using the differential rendering technique (http://www.free3dtutorials.com/lighting/lightwave/how-to-compose-shadows.php). Today, with DP Filter Node Editors, we can solve all this in a single rendering pass.

However, if you are looking for a way to solve this in Surface Node Editor (supposing we have already separated shadows from radiosity shading with the setup mentioned before), we could connect a diffuse model (with the front image mapped texture) in the BGColor of a Mixer tool, and this same plain texture (Image or ColorLayer nodes) in the FGColor.

To adjust the way they should be mixed according to the GI shading, we can use other diffuse shading model with no texture (just a plain white color) connected to a Length node, and this result to a BoxStep node. The Length node converts the color output from the diffuse model into a scalar value by setting its extreme contrast value. The BoxStep node works like a levels filter in a compositing package (to set up the white and black points). This output can be connected then to Alpha input of the Mixer tool to define the way the colored shading is mixed with the 100% luminous image texture.


Lernie, it's impressive how flexible lscripts can be in good hands.



Gerardo

gerardstrada
12-25-2008, 12:49 AM
...can probably be combined with the earlier node setup to account for both lights and HDR lighting.

Btw, if you like the simplicity of the earlier node setup (DP Shadows and a Gradient), you can replace the Mixer, Length and BoxStep nodes of this previous configuration, with a Gradient node.

The diffuse model with no texture can be connected directly into input in Gradient node. The diffuse model with the image texture mapped on it, can be connected into the first color Key, and the plain image texture into the second color Key. White and black points can be adjusted by sliding the Keys position. Though it's a different implementation, it's basically the same concept.



Gerardo

EDIT: Merry Christmas to everyone by the way :)

Exception
12-26-2008, 04:28 AM
That's a viable solution. But you might want to have a bit more control. i.e.:in order the image texture doesn't get tinted with the HDRI lighting we'd need to set up 0% for diffuse channel. But in that case we'd lose the colored shading too.

That's not entirely necessary.
My node setup plugs the lambert node into the Luminosity channel, not the color channel, seeing the Luminosity channel is always monochromatic, it doesn't carry over any color tinting from the HDRI lighting...
I first had a setup with a mixer node, but that indeed tinted... so I thought up this solution, and the clamp ensures it won't go over a brightness of 1.0.
In PS after rendering the color values match those of the original backplate 100%. It might not work for all situations, but for all means and purposes, this works out pretty well, and is easy enough to implement quickly without having to remember a complex node setup... which is good for me as I tend to forget these kinds of things really fast.

Cheers, and merry christmas to you too!

gerardstrada
12-26-2008, 10:56 AM
Yes, not color channel. I'm referring to if diffuse channel is 100%, surface catches color shading from HDRI illumination too. In order this don't happen, we need to set up diffuse channel at 0%. Then, we have a monochromatic shading because luminosity in the only player in the setup.

Grayscale shading is also useful in several cases, since we can treat it as an AO pass in post later (as it seems, you are doing whithin PS).

Btw, perhaps you may be interested into try DP Filters Node Editors too. Once we have set up the proper nodal configuration, it's a one-button solution. The setup is more complex the first time surely, but we can save presets and re-use them any time we need, we can adjust also color and shading strength within LW or save, in a single pass, the shading from indirect illumination (greyscale or colored).



Gerardo

Exception
12-26-2008, 11:09 AM
Sounds interesting, do you have an example or a link to how one would use DP's Filters node editor in this fashion?

gerardstrada
12-26-2008, 12:43 PM
In this thread (http://www.spinquad.com/forums/showthread.php?t=19309) I'm sharing several node setups for DP Node Editors from time to time. Here (http://www.spinquad.com/forums/showpost.php?p=212442&postcount=12), I shared a nodal config for exporting an illumination pass, and indirect illumination pass and a color bleed pass. Setup for LSD (GI shading) is more complex but it shares the same principle.

As far as I've heard, Kray already has a plugin for doing several things we see in that thread (even the one-button solution for linear workflow). I think NT could take DPont's idea further on and already implement a built-in system to make all these things automatically or customizable.



Gerardo

Exception
12-27-2008, 05:02 AM
Nice, I'll give that a try and see if I can figure out a way to do this with the image filter nodes... thanks.

gerardstrada
12-27-2008, 01:55 PM
Glad you find it interesting. Please, do let me know if you need some help.



Gerardo

Kevbarnes
01-10-2009, 11:47 AM
Hi 'Exception'

This may be what your looking for - Ive just recently Downloaded 'sIBL' environments and thought if only I had a Shadow Catcher plane I could comp in Layout to the HiRes Background Environments and have the advantage of Charactor animation and Limited camera Pans.

I came up with this - and then found this thread, I hav'nt been able to get any of them to work for me yet in the way that I wanted, so I posted my solution.

'gerardstrada' - you seem to have a pretty good grasp on nodes, can this be improved upon??

Included in the zip are the following:
Nodal Preset
Test Renders and Notes


Place Surface preset in your LW preset Library
Install DPLights and DPKit
Place Ground plane in scene and apply Preset


Notes
Adjust Shadow colour using Ground plane colour

Adjust Shadow density using Light Shadow colour

Node SmoothStep - 'End'. adjust this to suit lighting, Adjust this until
areas of plane not in shadow - disappear

Alternative Light for soft edges use 'DPInfinite'

See Test Renders

1.Render(sIBL)ShadowCatcher(Dist+Rad).jpg
With distant light and 100% 'Background' Radiosity.

2.Render(sIBL)ShadowCatcher(Rad).jpg
With 200% 'Background' Radiosity.

3.Render(sIBL)ShadowCatcher(Rad).jpg
With DPinfinite x 3Deg and 100% 'Background' Radiosity.

Kevbarnes
01-10-2009, 11:51 AM
Here is the zipped-up files complete with node Surface preset

gerardstrada
01-12-2009, 01:25 PM
Kevbarnes, can you upload a .srf file to take a look? your preset crashes here, but for what I can see from your attached images, it seems it works ok. Though don't understand why we need to adjust shadow color by using the ground plane color. Isn't it supposed we can get the original shadows color from the lights since we are using transparency? (diffuse shading still should work in the non-transparent parts). If we can't get for example colors from a dome light or indirect lighting from Radiosity, I'd still prefer the previous setups or solving it through Filter Node Editors. Though it can be useful for people whom don't care about shading/shadows colors, maybe your setup can be improved on that regard :)



Gerardo

Kevbarnes
01-13-2009, 12:02 PM
Kevbarnes, can you upload a .srf file to take a look?Gerardo

Hi Gerardo

Heres the attached Srf file - I'll have another play with the Nodes shown in the rest of the thread, but when I tried them first time they all just rendered the plane in the environment - you would have to render the view and then FrontMap it to the plane in the usual way.

Adjusting the Shadow Colour of the plane is just and option - not a requirement.

I think your right, my solution dosn't pick up of the radiosty diffuse shadows.

gerardstrada
12-09-2010, 01:40 PM
An idea: To get the shadow component without the falloff shading - and supposing you are solving this in Surface Node Editor - you could set up DP Shadows node in this way:

-Enable the Mix With Soft Shadows checkbox (this will enable the internal node solution for shadows)
-Set Light Radius to 0m (this will provide a sharp shadow - in case you don't need soft shadows)
-Use the Soft output (scalar) instead of the Regular output (scalar)

The above setup will give you the shadows you need, but render will be slower. Solving this in DP_Filter Node Editor is faster because you can use LW regular shadows - just use the Shadow buffer in Render Buffer node or export the Shadow buffer if you want to compose it in your compositing package instead of DP_FNE.



Gerardo

gerardstrada
12-09-2010, 01:51 PM
Ok. Other idea for sharp shadows is to use the Hard output (integer) of DP Shadows node (looks even faster than Regular output) :)



Gerardo

gerardstrada
12-09-2010, 03:02 PM
Yes, if you need just the LW regular shadows, the Shadow buffer would be your best option, it seems. You can just export it if someone else is going to take care of the compositing or you could use DP_FNE if you want to get the shadows already composed directly from LW.



Gerardo

gerardstrada
12-10-2010, 11:54 AM
In case you want to try by exporting a Beauty pass and a Shadow pass in a single render, maybe you might want to take a look to the node setups I shared in Issue #30 of HDRI3D magazine (check the Resources web page) :)



Gerardo