3
$\begingroup$

In some video games there is a feature where nametags of friends are shown through walls. I want to emulate that kind of style in the render, without using holdout and doing a composite on that generated alpha channel (I'm already using holdout for another object for compositing purposes and these holdouts would overlap). I could technically render a holdout on a blank background, render just the object I want in front, and render everything else, but I want to avoid 3 renders if possible.

Is there a feature like in the Object Properties - Viewport Display - In Front, but for renders? Maybe a button that's like "Render in front" or maybe a modification which can affect the z-pass in the render, effectively putting it in front during compositing. Even paid addons are worthy of a solution.

$\endgroup$
4
  • 2
    $\begingroup$ I'm afraid the only way to do that that I know of is to put your object in a new separate view layer and composite that layer on top of the render. $\endgroup$ Jul 18, 2023 at 4:21
  • $\begingroup$ This kind of thing is possible in Dillion Gu's Blender (Goo engine). Plz note that this is a custom blender build. $\endgroup$ Jul 18, 2023 at 4:55
  • 1
    $\begingroup$ Maybe a bit silly, here .. do it in geometry ? $\endgroup$
    – Robin Betts
    Jul 18, 2023 at 17:22
  • $\begingroup$ Thanks Robin for your comment. I think what you linked is possible, but I couldn't edit the existing animation for my project, and it had a few constraints already. I described a solution I found with a new Blender file below. $\endgroup$ Jul 18, 2023 at 22:48

1 Answer 1

0
$\begingroup$

DUPLICATE YOUR PROJECT TO CREATE A SAFE COPY. You don't want to ruin an original by accident.

TLDR at bottom

Depending on the qualities of the render, one may need two or three different viewlayers. Keep in mind when you create new view layers, render times take longer.

Start by creating a new collection and isolating the In-Front object(s) in said collection. Call this AlwaysOver(Alpha)Collection [also known as Collection 3].

For accurate lighting, you want to duplicate all light sources and place them inside the same layer as the In-Front object. In the In-Front collection, if a light source is an emission object, you want to go to Object Properties - Ray Visibility - uncheck Camera, if not done so already. This makes emission materials emit light but lets the camera pass through the emission object.

Now you want to duplicate your view layer once or twice:

One time if you don't want shadows or reflections of the In-Front object interfering with any other objects, and vise versa.

Two times if you want shadows and reflections to interfere (can create some trippy effects).

If you have two viewlayers, name them as such: BackgroundView AlwaysOverAlphaView

(OPTIONAL) With three viewlayers, name them as such: BackgroundView AlwaysOverView HoldoutView

You now want to create 4 total collections: Two for your AlwaysOver object(s) and two 'for' your backgrounds. Name Collection 1 "BackgroundCollection" and it should contain the entire scene except the AlwaysOver object.

Duplicate Collection 3, rename it AlwaysOver Shadows + Reflections. This is collection 2. It should contain ONLY your AlwaysOver object, no lights, so delete the lights in this collection. The AlwaysOver object in this collection needs a property change. Have unchecked the property 'Camera' in Object Properties - Ray Visibility - Camera. This makes camera rays pass through it, important later.

Collection 3, AKA AlwaysOver(Alpha)Collection [described above] should be similar to Collection 2. The property 'Camera' in Object Properties - Ray Visibility - Camera should be checked so it is visible during renders. Lights should not be deleted in this collection.

(OPTIONAL) To create Collection 4, Duplicate Collection 1, AKA BackgroundCollection. In Collection 4, which should be renamed BackgroundHoldoutCollection, you need to delete all lights, including emission lights. These emission lights will be visible in other layers. If you mess up any lights, some lights will be twice as bright or not at all. Now you want to select every single object and make it a holdout object under Object Properties - Ray Visibility - Camera.

Go to your first Viewlayer, AKA BackgroundView. Collection 1 and 2, "BackgroundCollection" and "AlwaysOver Shadows + Reflections" Should be turned on, with every other collection turned off.

Go to your second Viewlayer, AKA AlwaysOverAlphaView. Collection 3, AKA "AlwaysOver(Alpha)Collection" should be turned on, with every other collection turned off.

(OPTIONAL) Go to your final viewlayer, AKA HoldoutView. Turn on Collections AlwaysOver(Alpha)Collection (Collection 3) and BackgroundHoldoutCollection (Collection 4) with the other 2 collections being invisible/off.

1st Compositing step Go to the auto-generated compositing workspace in Blender, or create it yourself. Check "Use Nodes" at the top.

Create a new node "File Output" And change its details to be EXR Multilayer. Now you want 4 inputs: "Background" "AlwaysOverCol" "AlwaysOverAlpha" and "Holdout" (although if you were planning on doing compositing already you may need more inputs. If so, seperate inputs based off of the viewlayer and combine them into 4 images before I describe the 2nd compositing step).

Add 3 render layer nodes: Each should have each individual viewlayer (2 if you're doing the minimum). Connect them to their corresponding inputs on the file output (EXR multilayer) node.

Render image/animation.

2nd Compositing step

Mute the nodes you just created. Highlight them and press m to do so.

Nodes

Just follow what I did here, but here's some words in case the image disappears.

Create an image node. It should have 3 (OPTIONAL: 4) images when you select the EXR file. Below describes what 4 images should give you.

Connect AlwaysOverCol and Holdout to an alpha over node (in image) [Fac should be 1.0]. Holdout should be bottom image slot, AlwaysOverCol should be top image slot. Now this completed alpha over node should connect to a set alpha node (image) with AlwaysOverAlpha (From original 4 piece image node) connecting to "alpha." Apply mask should be selected, otherwise double blur will occur and the AlwaysOver object won't look exactly right. Connect the Setalpha node to another Alpha Over node (Image - Bottom) and connect Background (From original 4 piece image node) to the other Image slot. Factor of one. Connect this final Alpha over node to a file output.

Results (Cube stays at a scale of one the entire time): 3 View layers example, somewhat trippy

If using 3 images (bare minimum), skip the first alpha over node. AlwaysOverCol (From original 4 piece image node) should connect to the Set Alpha Node in Image, with AlwaysOverAlpha connecting to Alpha. The rest is described above.

Results for 2 view layers: Definitely less shiny, but has its own appeal

TLDR render 1st viewlayer w background with AlwaysOver obj shadow, no AlwaysOver obj visiblity, with AlwaysOver obj reflections in other objects render 2nd viewlayer just AlwaysOver Obj for alpha + alpha channel plus scene lighting (Emission objects invisible to camera rays) (Optional) render 3rd viewlayer Holdout channel for every object except the alpha over object, including emission lights

Composite

Side note: In the BackgroundCollection you can choose to disable AlwaysOver object shadows if you want. That will change the 'look' and abstract-ness of your final piece.

Original:Wacky looking

$\endgroup$

You must log in to answer this question.

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