View Full Version : Depth Buffer Question...
02-28-2003, 12:38 AM
Hey all, I have a scene of a hypervoxel explosion. It has a dust emitter and a dirt emitter. The dust is finished and I want to render it and get it out of the way so I can focus on the dirt, so I need to be able to composite them later. I have rendered a test of the dust with its alpha and depth buffer masks, and a test of the dirt with its alpha and depth buffer masks. I have applied the alphas to each of the images and have them on top of each other in two layers in Photoshop. Now I need to figure out a way to use the depth buffers to composite them properly. I have the two depth buffers, and I need a way to composite the two layers based on that. I'm having trouble figuring out how to do this. Any help would be appreciated.
02-28-2003, 02:43 AM
Yeah, I've been wondering this too! If anyone could shed some light on this issue that would be great!!!! I know someone has to know how to do this, because its done in movies alllll the time. Thanks for you help - Eman
03-27-2003, 04:55 PM
Likely you will have to use "Combustion" or another compositing program that accepts the RLA or similar format. This is important because Photoshop will not import a depth buffer channel, because it does not support a format that has it. If you are able to get the depth buffer channel into photoshop some how then simply copy it to a new channel in the channels palette and "Ctrl + click" that new channel layer to select the contents of it (i.e. the shapes and shades that it contains; this is entirely different than "select all") then activate either the dust or dirt layer and click the "Add a mask" button at the bottom of the layers palette and voila!
This does not work just by adding a mask ! You would have to combine the 2 depth buffers to get a new mask. You need a mask that is a comparison of the 2 depth buffers (which pixel is in front of the other based on depth). Maybe subtract the depth buffers and then use Levels to get a 1-bit mask.
Anyway I think with Photoshop you will get into trouble with aliasing where the 2 layers have similar depths.
03-27-2003, 07:16 PM
Dans, when you say "comparison" is that the median between the two, the sum of the two, the difference of the two, I think I can help but I don't fully understand the problem? Please elaborate.
By "copmparison" I mean that you need a way to compare the
pixels of depth channel A with depth channel B. And for each pixel you have to decide if A is brighter (nearer) then B or not. The result should be white pixles for the case that A is infront of B and black where B is infront of A.
So the basic question is how to compare 2 channels pixel by pixel by their brightness. Maybe this can be achieved by subtracting the 2 depth channels and then increasing the contrast.
03-27-2003, 09:38 PM
I see, then in that case there is no automated process to accomplish this because, as Daniel said, you need to do a comparison between each pixel of the depth maps to "see" which one is on top and all of the methods that I am aware of would in the end require you to do this for ever level of gray in the depth map. One idea might be to create an "index" layer with graduated swatches of gray from 0-255 and then put both depth layers as seperate layers and do a "Select/Color Range..." with the fuzziness to 0 and then add or subtract the selection of the same colored swatch from one or the other and fill the result with black on a new "output" layer. Continuing this process until you have run the gamut of swatches and you have a resulting one bit layer that contains the mask for one of the layers and its inverse will be for the other layer. The problem with photoshop is that if the dust and the dirt are on seperate layers then one has to be on top of the other in the stacking order which literally puts one in "front" of the other. Because photoshop does not inherently handle a Z-axis you have to manually distinguish it by going through all of the levels of grey that are contained in the depth channel and in a sense convert them to become a mask. Because all photoshop can do is use those levels of grey to mask the varying opacity of a layer or layers. So in a sense you are converting that depth channel into an "on/off" 1-bit mask that either shows the dirt or the dust. This assumes that the semi-transparent edges of the dirt and dust have had their alpha channels applied properly so that those edges are not anti-aliased against the background that they were rendered on. Otherwise your edges will not work right. This is a lengthy process but I do not know of any other way with photoshop to adjust levels or curves or anything that would give you the desired result.
The comparison can be easily done with the filter factory plug-in that is on the Photoshop CD. The steps would be to put one depth channel into the red channel and the other into the green channel of the layer. Then run the custom filter factory filter on this layer that does the comparsion.
The filter factory code for red, green and blue is:
(r>g) ? 255 :0
01-14-2006, 12:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.