Join layers in Compositor

Hi,
I have a problem I can’t figure out. I’m testing it out and trying to figure out how to join layers. I have rendered a layer with my ‘model’ and a ‘reflection layer’. Then I want to join these with a background picture in the compositor.

I can join the reflection and the model layer with a “screen”-node and that looks good. Then I add an Image-node pointing to my background image. I have tried joing that ‘Image node’ with the output from the ‘sceen node’ in different ways but at best it looks faded and I can can see the background image through the object and reflection.
I’ve tried ‘add’, ‘multiply’ and all the others I think.
How do I add them together and make it look good?


Alpha Over node ?
Though you’d have to get rid of that black plane on the reflection render layer.

What are you trying to achieve ? I see no blend file in your post to review !

Yes, the secret will be “Alpha.” Combine the object and the reflection to produce an image (no black plane …) which has Alpha for both the object and the reflection (not the plane). Everything else has Alpha=0. You may need to use a curves-node as a low-pass filter in the alpha output to force non-zero Alpha values to quickly shift to “Alpha=1.0” i.e. opaque, so that you do not “see through” the reflection (or at least to allow you absolute control over how much you do see). The combined image is then AlphaOver’d onto the background. You do want to use gamma so that the edges of the overlaid image blend smoothly into the background.

Here is a blend file. What I’m acctualy going to do is to put a submarine in that background picture and try to make it look as real as I can with a reflection in the water and all. But I thought I would just put a ball there to start with, just to figure out how to get the different layers right before I do it with a heavy model. :slight_smile:
But as you can see below the object along with the reflection is very pale and transparent. Haven’t added a shadow-layer yet either.
Still trying to understand how the ‘alfa’ stuff works. :confused:


Attachments

layer_test_2.blend (3.08 MB)

Hi,
Thank you both for trying to help! :slight_smile: But I feel a bit lost. I don’t get how to get rid of the black area.
Do you think you could describe it a bit more in detail? Or is there a good guide somewhere?
I’ve found info about adding a shadow-layer but not to much about how to use a reflection-layer in order to add it to a background image.
/Bjorn

Okay, here’s what I did…

I deleted one of the two planes you had. A single plane can be used for both reflection and shadows. Just select those in the Passes section of the Render Layer properties. This also resulted in the elimination of the Shadow render layer.

You were trying to light the scene with a JPEG image. You need a HDR image if you want to get proper lighting. An HDR image has more information packed into it. I added a sun light to the scene to generate a shadow.

Also, I put the camera and sun on the first layer, the sphere on the second layer, and the plane on the third layer. Look at the Render Layer properties to see how I set up those up.


Note that I added a Scale node to the original image so that it wouldn’t take so long to render.

On the Shadow pass I was getting a dark fringe around the plane so I added a Dilate/Erode node (set to -1) to the Alpha channel.

To control the darkness of the shadow, I Mixed it with a white RGB node. Adjust the Fac value to get the shade you want. You could also include an AO pass. You would use a Mix:Multiply node like the shadow pass used.

layer_test.blend (3.09 MB)

Steve S

yeah, reflections are a bit of a challenge! because what you need is a reflective surface to catch the reflection, however, you also need a mask to separate the reflection from the plane that it is sitting on. i did a tutorial not long back about reflections, but it ran into the same issues that you;re having here, that is to say the screen optoin is not an ideal solution, you need something a bit more solid! i will have a look into this problem again and see what alternatives i can find

ok almost got it figured out! (by almost read “it currently looks like crap”) the answer is in the render passes, but i am getting some issues with the alpha blending for the different layers. so the reflection is looking a bit pasted in, its probably just something really simple and stupid, but its late and i dont have time to work on it anymore tonight so i’ll see if i can get it in the morning!


ok yeah i was being stupid, heres how to get good reflections.take the render layer with the reflection plane and activate the glossy indirect pass. your plane should have only a pure white glossy material. you can use your image as a normal map texture if you want, that will give you accurate reflections in the ripples, just dont connect the image texture into the glossy node or anything silly like that!
now, we get to do crazy stuff in the compositor.

first we need to make a mask from the reflection, so drop in a colour ramp to the glossy indirect pass, blur it by a couple of pixels then connect it to a dilate erode. from here we can go straight into a set alpha node and overlay it onto our image. i like to displace the image a bit more though, so connect another colour ramp this time to the image, get it nice and contrasty then add a soften filter.
you’ll need two displace nodes, one for the alpha and one for the colour, drop them both into the compositor and add a value node, connect the value to the X/Y values on both displace nodes connect the soften into both vectors on the displace nodes, now take the output from the dilate erode and plug it into the image socket of the first displace, then plug the glossy indirect from the renderlayer node and plug it into the image of the second displace, change tha value node to maybe 5 or 6, it doesn’t need to be too high as you already made the material distorted using the bump map remember :wink: ok now plug the first displace into the alpha of your set alpha node, then plug the second displace into the image of the set alpha and now simply connect the set alpha and the image together with an alpha over and lower the factor to the required opacity for your scene.


You can simply continue on with compositing in your objects and shadows in the normal manner once you have comleted that section.


Attachments


and the blend file to poke around in.
reflections.blend (1.08 MB)

Thank’s for the tips Steve S!
The object is solid but the shadow still looks a bit pale compared to the real refelections on the other side of the bay and the building to the left. But maybe that can be adjusted. The scaling node will come in handy since I have a pretty slow computer to work with. :slight_smile:

Thanks Troll!
That second image with the grey ball really looks good. You even got the water ripples on the reflection! I gotta study your blend there and try to figure out how it all connects. But it looks like you got it right!

Strange that there seems to be quite a few tutorials about how to add shadows, but almost nothing about the reflections. But maybe it’s because of what you said, that reflections are a bit of a challenge. I’m gonna study it and try to post some kinda of result when I get it right. :smiley: Thanks again!

Yeah, Troll’s method looks better. If you want to study his Blend file, those large nodes labeled Render Passes are groups of nodes. Select the node and hit the Tab key to look inside. Hit Tab again to get out.

Steve S

yeah sorry, the big nodes are for recombining the render passes so you can work on the individual direct/indirect/color passes and connect them back together without having to remember the math for each pass to get the correct combined pass!

you can see the benefits of using the separate passes by checking the blue cube. it is only blue in post and you can see the shadow is the default grey, this allows you to make creative changes without having to re render the image. also a point to note the badly composited image earlier in the thread is also the same image i just tweaked the individual glossy and reflection passes to change the ball to something more metallic. though in that image i was a bit tired and didn’t quite get the effects i was looking for!

There are a lot of nodes to figure out there so it will take while. But a big thanks for providing the Blend-file to study!
I just made some small adjustment to make it look ok with my background, model and stuff.

I just think it was a fun idea because there was an article a week ago in the local newspaper about strange signs of under water acctivity in the region. :slight_smile:
(ps. I got the Uboat model from Blendswap, made by user Splatypi.)


yeah this is looking great! good work. only concern i have with this technique is that the waterline is completely flat, perhaps, there is a way to sue a displacement on the shadow layer to make the ripples in the water break up that flat transition line to match the waves in the water but without breaking the ripples in the refelction.

something to think about!

That looks great.

Steve S

Didn’t think that much about the waterline. But I noticed some areas by the waterline against the sub that seems to have no reflection?
But I was still so satisfied with the result, and the hard drive on the laptop I was using started to make strange noices like it was about to give up. :slight_smile:
So I kind of thought of the picture as finished. But afterwards you of course start to see the flaws. The lighting on the “tower” looks a bit wrong, and the whole boat should have been bigger than it is. Think it’s a bit small compared to the cars. And it would be cool if I could make the surface of the sub look a bit more wet.
Maybe I’ll get a new fresh hard drive and try to improve it a bit more.