3
$\begingroup$

I've got an object that I'm rendering with freestyle edges:

enter image description here

I'd like this object to also be a smoke emitter:

enter image description here

Is there any way to draw the freestyle edges, to be partially visible through the smoke?

$\endgroup$
  • $\begingroup$ The Compositor. Render with and without smoke present. Since other attempts and restrictions were not specified I assume conditions are conducive. $\endgroup$ – atomicbezierslinger Sep 12 '17 at 17:21
2
$\begingroup$

In order to render freestyle lines that are obscured by smoke there are two main issues that need to be overcome :

  1. Freestyle only renders the edges of 'exposed' meshes - the smoke domain will effectively mask out the freestyle on anything behind (or within) it.
  2. Freestyle is an 'overlay' effect applied after the scene is rendered - it is not actually part of the 3D scene and so cannot directly interact with elements within the scene (such as volumetric smoke).

Rendering a simple test scene with freestyle enabled creates the following results :

bad freestyle

Note how the freestyle is masked by the smoke domain on the furthest Suzanne.

To overcome the masking issue we can use the compositor to combine multiple renders to 'filter out' the freestyle lines which would be obscured by the smoke and for this we'll need to render the scene three times - once for the 'full' render (without freestyle), once with just the freestyle lines (that we can mix into the 'full' render wherever they wouldn't be obscured) and, finally, how the freestyle is obstructed by other elements (including the smoke) in the scene.

Full render : full render

Freestyle : freestyle

Obstruction : obstruction

To allow the scene to be rendered without the volumetrics we can move the volumetric domain onto another layer by selecting it and pressing M to bring up the layers popup and selecting the destination layer (eg, layer 2). Render Layers can be set up to render the different scene layers to get the desired results.

For the 'full render' we need to create a Render Layer to render both layers (ie, the layer without the volumetrics and the layer with just the volumetrics) :

render layer just for layers 1 and 2

For the freestyle layer we want to render excluding the volumetrics and disable all other elements - so we just get the freestyle lines :

freestyle-only render layer

Ensure to set the Freestyle Line Color to pure White as we'll use this colour the freestyle lines in the compositor.

For the 'obstruction' render we need to render just the volumetrics layer and to 'darken' the image based on the 'depth' of smoke the ray passes through but with the rest of the scene pure white. We can achieve this by setting all objects and the background to a pure white Emission material with a strength of 1.0 and use a Volumetric Absorption for the smoke - adjust the density to adjust the 'thickness' of the smoke. Note that the Render Layer includes a 'material override' setting. This will override all materials in the layer and is useful for setting the objects to all render as pure white emission while the volumetrics are Volume Absorption. In this case I've used the Object ID to indicate the object type (emission = 0, volumetric = 1) using the following material :

Object ID material

In addition, I added a plane behind the scene to provide a background 'environment' of pure white (as for the other meshes). This was moved to another layer (3) so that it can be included only in the Obstruction render. This means that the 'Obstruction' layer needs to include all three layers to include the objects (1), volumetrics (2), and additional background (3), as well as the material override :

obstruction render layer

To produce the final result we need to combine the 'full' render with the freestyle overlay, using the obstruction mask to mix - so that the freestyle is only applied where the surface is not obscured by the smoke. This can be achieved with the following nodes :

compositor nodes

Here the Obstruction layer is used to determine which parts of the freestyle layer are overlayed onto the full render. The RGB node controls the freestyle line color while the Color Ramp can be used to adjust the apparent density of the smoke.

This can produce the following result :

final result

Blend file included

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.