I've got an object that I'm rendering with freestyle edges:
I'd like this object to also be a smoke emitter:
Is there any way to draw the freestyle edges, to be partially visible through the smoke?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityI've got an object that I'm rendering with freestyle edges:
I'd like this object to also be a smoke emitter:
Is there any way to draw the freestyle edges, to be partially visible through the smoke?
In order to render freestyle lines that are obscured by smoke there are two main issues that need to be overcome :
Rendering a simple test scene with freestyle enabled creates the following results :
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.
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) :
For the freestyle layer we want to render excluding the volumetrics and disable all other elements - so we just get the freestyle lines :
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 :
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 :
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 :
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 :