Z-Depth in Garry's Mod (Tutorial/Discussion)

When editing an image, you usually work with 3-D renders onto which you composite 2-D elements, i.e. fire. When using a 3-D program such as 3DS Max, you render something called a z-pass, a black and white image that uses shades of gray (black = far away, white = close) to tell an editing program, such as photoshop, where objects are in the image. This is incredibly useful, as it saves you from having to manually cut the image into layers. In this thread, I’m going to teach you how to mimic one of these in Garry’s Mod for editing purposes. This is divided up into 2 methods for getting the z-pass, and editing.

https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Method1.png

https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Method2.png

https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Editing.png

Now for the fun part, editing with the Z-Pass. Open your [base image](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/BaseExample01.jpg) and [z-pass](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/ExampleZD01.jpg) in photoshop. Paste the z-pass into base image’s alpha channel. Then paste the z-pass as another layer in your base image and invert it. Your channels/layers should look like this:

https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Layers.jpg

https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Channels.jpg

Now, first we can apply DOF to the image. Go to filters>blur>lens blur, and follow the image below.

[https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/thumb/Blur.jpg](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Blur.jpg)

This will apply a SDOF like effect to the image. Now, we add our effects. Import whatever element you want to edit into the image. Then, duplicate the inverted z-pass. Using image>adjustments>exposure, clamp the z-pass so that the objects in front of the element are black, and the ones behind it are white. You can see this done in the image below.

[https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/thumb/CreateMask.jpg](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/CreateMask.jpg)

Then, copy the z-pass into the layer’s mask (learn more about them here). This is demonstrated below.

[https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/thumb/UseMask.jpg](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/UseMask.jpg)

Repeat this process for your elements, match the DOF, shit color correction and bloom and lens flares all over it, etc. Using the z-pass as a new tool allows you to accomplish many cool things in much less time. When you’re done (and if you’re organized) your image should look something like this:

[https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/thumb/TheRest.jpg](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/TheRest.jpg)

Now, add any finishing touches (I like to merge all the layers and do some color-correction), and save your image. This works with the poster command by the way, now you can have 16k SDOF images.

[https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Final/720p.jpg](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Final/1080p.jpg)
[QHD](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Final/1440p.jpg) - [4k](https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/Final/4k.jpg)

Question…

Where do I find a fog editor?

**edited
**Wait I think I found one

Entities->Editors->Fog Editor

Hold down c, right click the editor when it spawns, select properties.

Even though I never edit: nice. It’s well written and easy to follow along.

darn kids and their shortcuts
back in me day we had naught but our wits and ol’ selection tool thingys

anyway this is cool, i have to try this when i get back in business

This is gonna be super useful, thanks so much.

I often give Winner tags to people around these parts, but this may be the most well-deserved one. Cheers for the tutorial! I’m looking forward to playing around with it when I have the time.

Wow thank you so much for this. Never though of recreating a depth map with fog, that’s pretty ingenious.

you can also use fog for very precise greenscreening: just make the start/end point really sharp to isolate your objects and then use the thing you just created as a layer mask (after inverting it so that the fog is black and the objects white, of course)

I dont get it is this basically a method of greenscreening which also gives the picture depth or something? What exactly is the effect achieved by this?

The ‘depth map’ created by having closer objects lighter and further objects darker, allows photoshop to create artificial depth of field in a scientifically accurate way, instead of a person just going and blurring things with a quick filter.

The science is that there’s a focal distance of the image, and the further away from that point objects are, the more blurry they will be. So having a greyscale gradient (the depth map) allows photoshop to accurately reproduce blur similar to how it would be if taken by a camera lens.

Really neat stuff.

This doesn’t necessarily give the image anything on it’s own, it’s just a tool that allows you to edit the image faster and more accurately. It takes out a lot of guess work, and allows precise DOF in post, as well as easier compositing of effects (for example lighting an object on fire with a bush in the foreground - usually you’d have to cut out the bush manually to put the fire behind it, which takes a lot of time)

As an example, I was able to put “sneaky text” in the image behind the foliage with about 1 minute of work.

https://dl.dropboxusercontent.com/u/17239680/Facepunch/Photoshop Contests/ScreenshotEdits/Z-DepthTut/Tut/EaseExample.jpg

[editline]dicks[/editline]

Sorry, thought automerge still worked after 3 hours

This is really neat, too bad the Sticky was removed, would fit in there quite well!

Yeah, it’d probably get added if I/others asked a mod. What I’d really like to see is people providing z-passes with their images in the edit my screenshot thread. I see so many beautiful pictures over there that I’d love to edit, but I just don’t have the time. This method can literally shave hours off of isolating all the tiny elements of an image, and would make editing someone else’s work much easier.

Sorry but How to paste the z-pass into base image’s alpha channel ?

  • Copy the Z-pass image;
  • Go to the Channels window in Photoshop;
  • Click the Add Layer Mask button in the bottom of the window (it’s the one with a rectangle that has a circle in it);
  • Paste the Z-pass in the Alpha 1 layer.

I ain’t even mad about the bump because, to be honest, I’d forgotten how easy the Z-pass method is. I think I’m gonna permanently adopt it for my comic making, should make some things much easier to do!

I thought I’d share a very simple method I discovered yesterday. I wanted to do a z-pass, but didn’t remember how to do the layer masks etc so here’s a super simple version of this.

Make the object you want to ultimately select as monotone as possible (white for example). I’m selecting the guy in mid here by having a high upclose fog and high contrast setting. Now put these layers on top of each other.

Select with the ‘magic tool’ (W button) by left clicking your object.

http://www.wduwant.com/index_uploads/uploads/a427d6a.JPG

Now click on the original background and press CTRL+C and CTRL+V. This will select the outline on your original of that object and make a copy.

http://www.wduwant.com/index_uploads/uploads/0fe10242f433.JPG

Now draw whatever you want on your original background.

http://www.wduwant.com/index_uploads/uploads/4033332a8895.JPG

Done. Drunk Hunters being tipsy

http://www.wduwant.com/index_uploads/uploads/2f764acc3a20.jpg

I can still see some jaggies on the end result though, as well as blurring in some parts. That’s partly because you went with the Magic Tool, which always gives unsatisfactory results. Color Range probably would’ve been a better option, here.

How do I do the debug white material thing???

Equip the materials tool, then find the pure white material, click on all the objects in your scene to color them white?