View Full Version : Ah ha! Work-around for 'useBackground' shader + FG shadows!
01-28-2004, 11:19 AM
As some of you may have discovered by now, the 'useBackground' shader doesn't collect Final Gathering shadows, which is annoying.
This afternoon I managed to find a fairly nice (in my opinion anyway) work-around for that. It effectively makes the 'useBackground' shader collect FG like shadows, like this:
Not exactly the best example, but when you render it without the image plane you get:
So it works fairly well. You only need to mess around with the floor shader, not the other objects. Here's what I did (it's slightly odd):
1. Apply a 'useBackground' shader to the floor.
2. Turn off the specularity and reflection of that shader (well,
unless you want it).
3. Open the Hypershade.
4. Connect the following nodes together:
Now to explain.
The Shadow Mask attribute of the 'useBackground' shader controls the transparency of the rendered shadow. The very handy Dirtmap shader basically creates FG shadowing wherever two surfaces are close to each other. If you don't know how to get the Dirtmap shader, you'll have to read around on this forum or wait 'til my next tutorial is out (in a few days).
By multiplying the result of the Dirtmap shader with the amount of shadow that the Shadow Mask is already receiving, you get FG and normal shadows for the 'useBackground' shader!
You need to add the Reverse node into the flow because otherwise the Dirtmap adds un-shadow (whiteness) instead of darkness.
As for attributes set on all these nodes:
1. Dirtmap shader has default values.
2. I've got 0.5 as the Input1.x value of the multiplyDivide node because 0.5 sets the normal shadows (cast by the light, not the Dirtmap) to half transparent. You only set to the Input1.x value and not the Y and Z because the shadowMask attribute only takes one value.
3. No attributes to set on the reverse node.
4. The only other thing you need to play with is the Matte Opacity attribute of the 'useBackground' shader. With it set to the default value of 1, the alpha channel has the Dirtmap shadows as invisible. So I set the Matte Opacity to like 100 which just makes the shadow alpha solid.
Here's my scene file for you also:
I know that's kinda a lot to do just to get the fake FG shadows, but at least I had semi-fun figuring it out, hehe.
01-28-2004, 12:01 PM
Nice discovery jozvez, I'm looking forward to playing with it, keep up the expedition of discovery:applause:
01-28-2004, 03:57 PM
you rock jozvex, I remember emailing you a few months ago asking about this.
can't wait to try it out.
as always, thanks for the tips
01-28-2004, 08:13 PM
That's cool ;)
01-29-2004, 11:01 AM
Thanks.. this is what i need!! Graet mind! :thumbsup:
01-31-2004, 10:43 AM
Thank you man, but........... Dirtmap1 is not recognize by Maya :[ what is the problem????? Thanks for replies ;)..
01-31-2004, 11:04 AM
So sorry, i'm stupid :P i have found how thanks for the tips man really great for my futur composition.......
08-12-2004, 01:39 AM
jozvex i tried this here couldn`t get it to work I also downloaded ure scene but that didn`t work either
what ver of dirtmap are u using and where can i download
can u make another example scene with no lights in it
thanxs by the way
08-12-2004, 03:32 AM
Not a bad solution, but the much easier and quicker way to get seprate GI/Dirtmap shadows is to simply create a pure white lambert shader with dirtmap connnected. Apply this to all objects in the scene and set the background color of the camera to be pure white as well. Then just turn off the primary visibility on the objects you want shadows from, and turn off trace reflections and refraction on the objecs you dont want to cast/receive shadows. What you are left with is a white image with only the dark GI_shadows. Take this into a compositing app, reverse it, and use it as an alpha for your shadow color.
08-12-2004, 03:57 AM
not a bad solution although a little cumbersome
08-12-2004, 09:02 AM
any "real" solution without dirtmap? no.:sad:
08-12-2004, 09:37 AM
Well...FG and use background is'nt supposed to work, since FG doesn't really cast any shadows.
Nice workaround though, but would it work with more complex background objects? Can you exclude the background object so that it is'nt affected by the AO rays (shut down visibly in reflections prehaps?)?
08-13-2004, 03:09 AM
I was surprised to see this thread surface again, I started it in January! Anyway, I haven't been ignoring your posts, I've come up with a new and much better way to do this now!! Of course Powell you are right about rendering seperate passes, but it would be kinda nice if we could do it straight from Maya as well.
My first new idea was to use the Raytype shader to isolate only the secondary FG rays.....but no matter what I tried I couldn't seem to get a shader to only collect FG rays and nothing else. :shrug: If some other smart person can figure that our we'll be way better off. Either that or if Pixero or Francesca could create us a whole new useBackground shader specifically for Mental Ray, that would be fantastic! *hint hint*
So anyway, onto my new workaround for this. It relies on the newly created mix8layer shader that Francesca created for us just recently. You can get that shader here:
It's fantastic! You also need the Dirtmap shader but I'm sure most people have that by now anyway. So, here's the network:
(it's big, 1200x930 or something)
And here are the results:
Now to explain. The Dirtmap shader is what's once again providing us with the fake FG shadows, the result of that (black where there's shadow, white where there's not) is being multiplied (via the Mix8layer shader) with the regular useBackground shader (which just provides the solid shadow from your lights). So we end up with an invisible shader that only shows us the solid shadows and the Dirtmap shadows, which is what we want. However, this alone isn't enough, we also need an alpha channel of course if we want to composite our CG over the footage in a compositing package. For some reason, I couldn't get the Mix8layer shader to give me a correct alpha channel....I tried playing with all the Alpha options on the shader, and I tried using the 'Pass surface color as alpha' option in the Render Globals, but no luck there either.
So that's where the Surface Shader and Reverse node come in. By sending all the info from the Mix8layer shader into the Surface Shader Out Color, we just end up with the same result as before, but now we have access to the Surface Shader's Matte Opacity channel. Obviously, we only want the shadows to appear in the alpha channel, and that's exactly what we get in the RGB channels, so we just pass along all the same info into the Surface Shader Matte Opacity. The only problem is that in alpha channels, black means invisible, and shadows are black, so we use the Reverse node to invert the colours.
And that's it!! It's actualy not very complicated so I hope everyone reading this gets the idea. I'll post my scene if you want, but you'll need to have the Dirtmap and Mix8layer shaders installed.
The one last thing to note is that you have to turn off the Image Plane (set it's Alpha Gain to 0) in order for the alpha channel to turn out right. It does this weird reflection thing if you leave the Image Plane turned on. :argh:
If anyone has better ideas you're welcome to share them of course!!
08-13-2004, 03:23 AM
Oops, I forgot to say:
1. To control the density/opacity of the solid shadow from lights, use the Shadow Mask attribute of the useBackground shader. In my example I have mine set to 0.5 so that you can easily see the Dirtmap shadows over the top of the regular ones. For some reason the useBackground shader doesn't seem to care what you have your Shadow Colour set to on your lights.
2. This method is much better than my original idea because first of all, it's just plain less dodgy, it's easier to tweak, and in my original approach the Dirtmap shadows could only exist within the bounds of the regular solid shadows, but now as you can see they can extend outwards like they should.
08-13-2004, 11:17 PM
Many thanks for that little gem :)
08-14-2004, 12:16 AM
YEAH - this one's IT. Thanks a lot for this solution.. It works like a charm - and here's a hint how to manage the image plane problem:
Create a poly plane and put it right in front of the image plane so that it covers it completely. Put the transparency to full and set Matte Opacity to "Black Hole"
For the Maya Renderer that's enough - but for MentalRay you also have to set the Alpha Gain of the Image Plane to 0.999. You still see the image completely, but it doesn't disturb the alpha.
08-14-2004, 03:31 AM
01-17-2006, 08:00 AM
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-2013, Jelsoft Enterprises Ltd.