It’s a question of setting up the layers, mask layers and compositing. You need to put your light source and your object on its own Collection (layer) and View Layer. Here’s a (really) quick and dirty example:
This is Collection #1
. It contains your object and a light source (in this case a plane with an Emission shader)…
This is Collection #2
. It contains the other objects and lighting in your scene. The cube on the right is in front of our center cube so you need to create a third Collection with the rightmost cube linked into it. Right-click Collection #2
in the Outliner and under View Layer click Set Holdout. This sets this layer as a mask layer like in previous Blender versions. You with me so far?
Finally you need to set up your View Layers (Render Layers in Blender 2.79 and before). You need to create the following View Layers…
- Solo cube: Collection 1 and 3 checkbox on (Included), Collection 2 off (Excluded)
- Main: Collection 2 checkbox on, the others off.
Now switch to the Compositing Layout window, create two Render Layers nodes, the first with your scene, View Layer: solo cube; the second Render Layer node: main. Hook these up to a Alpha Over node, connect tha Alpha Over to your Composite node and render away! You’ll end up with this…
If you want a common lighting on the entire scene, just put your lights (except your object’s light source) in its own Collection and include it in the View Layers.
Hope this helps with what you are looking to do. Cheers!