Clarification, May 31st 2017: User Firewill kindly provided an answer for the first version of the problem I stated, but I think I was after a more broadly applicable solution, so I'm re-stating my problem here in the hope that it helps solicit that.

As far as I can tell when using cycles freestyle to draw lines, those lines are placed on top of the rendered scene, so none of the objects in the scene get to interact with them in any way.

Take for example the scene below. The glass cube refracts light and effects the way we see the other items: enter image description here

To emphasize the effect it has, let's overlay an image on the plane so we can see how the glass cube distorts and reflects a grid: enter image description here

Super. Now let's see if we can draw that same grid with freestyle and see how it looks. First, take the plane, select its edges, and use "Mark Freestyle Edge": enter image description here

Now render the scene. Oh dear, that's not at all what we were after. No distortion of the grid, no reflection of the grid, no hiding or coloring of the grid. enter image description here

So, my question is, could I use compositor to render the plane and its freestyle grid together, then "re-insert" it into the render flow so that it can interact with everything else? Giving us a result like this, but with all the benefits of freestyle:

enter image description here

If it helps, here's the blend file for that scene:

Thanks very much for any help you can offer.

Original question: I have a mesh terrain, and a cube that intersects it to form the surface of a lake.

Here you can see how I've roughly thrown that together, with the cube placed underneath the mesh, poking through it to form the lake surface: enter image description here enter image description here

Here's what that looks like when it's rendered: enter image description here

I'm then using freestyle to draw lines along the terrain's visible edges. Unfortunately the lines aren't drawn beneath the surface of the lake water, because freestyle thinks they aren't visible. enter image description here

To correct this I initially tried using the QI Range setting in freestyle to additionally render the lines below the water, however that came with two problems: firstly other unwanted hidden lines in the scene were also rendered (those hidden behind the hills); and secondly the lake bottom lines were drawn on top of the water, and so didn't appear to be "hidden in the depths".

Here I've rendered only those hidden lines, to illustrate the problem: enter image description here

Since I couldn't solve my problem with QI Range my next thought was to render the terrain and freestyle lines as one image, the water as another, and then combine them in the compositor.

However, while I've done some simple experimenting with the compositor, I can't for the life of me think how to achieve the effect I want with it. Does anyone have any advice? Or am I trying to solve this in a silly way?

Here's a blend file where you can more clearly see what I'm working with:

Update, May 30th 2017: I've done some more fiddling and broken out the land, water, and freestyle lines into their own layers. I'm rendering then combining the land and freestyle lines (which works great), and then trying to add in the water afterwards. However that step doesn't really work out as I just end up with a cube of water plonked on top of the land, and the lake floor in that part doesn't include the freestyle lines (I'm not sure how to get them in there).

enter image description here enter image description here

Here's the file that produced all that:

I'm sure I'm missing a pretty obvious bit of knowledge about how compositing works. Could anyone with more savvy in this area explain what I should do to get all of this combined?

Thanks for any advice you can offer.

  • $\begingroup$ It looks like you're trying to make freestyle lines being refracted by Glass (or whatever you have on the cube) shader. That's impossible afaik as Freestyle is another render engine which doesn't interact with Cycles or alike. Maybe it could be possible to set refracted object to separate ObjectID, render usual refractions and trace them (like with vector graphics) to make lines into additional image which to process with freestyle or something. $\endgroup$
    – Mr Zak
    Jun 2, 2017 at 13:08
  • $\begingroup$ I agree with @MrZak - the Freestyle lines are added post-processing after the render is complete so cannot interact with the refraction in any way - in fact, the freestyle lines can even 'bleed' out over the edge of the rendered geometry and so is not even necessarily relating to a face in the rendered image (consider setting the line width to something like 20 pixels - half the freestyle line would overhand the actual face) so you couldn't even bake it to a texture to feed back into a second render. An alternative would be to use procedural texture to draw the lines rather than freestyle. $\endgroup$ Jun 8, 2017 at 9:15
  • $\begingroup$ That's good to know. Thanks very much to both of you. $\endgroup$
    – Dunstan
    Jun 8, 2017 at 19:09

1 Answer 1


So I broke up the scene into 3 render layers:

A freestyle render layer which just renders the lines A land+water which renders the land and the water without lines And a land layer which is used for depth

Then mix like this: we use land + water as a base, outputting a material index so we can mask the water area.

material index:

material index

Then using the alpha channel of the freestyle layer we mix the original output and the colors we want for both above water and below, using a material to output the depth of the land enabling us to interpolate between surface colors and depth color on the water covered surfaces.

depth land material:

depth material

these are the compositor nodes:

comp nodes

and this is the result:

final render

of course you can tweak the colours of the lines and make it look non-terrible :P

Hope this clears up your doubts!

(if you want the file I can give it to you, but I probably broke any kind of settings or order that you had)

  • $\begingroup$ Firewill, thank you so much for your answer – I really appreciate you taking the time to help me out! I realize that while your answer solves the narrow problem I stated, it doesn't solve the larger problem I was trying to ask about. I've changed my title and examples to better reflect the larger question I have. $\endgroup$
    – Dunstan
    May 31, 2017 at 21:58
  • $\begingroup$ I did find your answer to be super useful though, and I'll be using that technique for other things, I'm sure :) I'm just sorry that I didn't realize that my question was probably too specific was until I saw your clever solution. $\endgroup$
    – Dunstan
    May 31, 2017 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .