Top-down zdepth projected to camera

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2013   #1
Top-down zdepth projected to camera

Hi all, I have an interesting little problem and I'm new to working with matrices so I thought I'd ask for help here.

I need to create a depth map. Unfortunately the one made in my camera's space is not very good... we need the depth as though it were from the top-down and then rendered from the camera.

I imagine there has to be a way to get the zdepth data from the top-down, and then use the camera's transform or projection matrix to get it "back" into camera space and render from there?

Any help or pointers in the right direction would be greatly appreciated.
 
Old 03 March 2013   #2
falloff map type:distance direction:object.
create dummy somevhere up. set it as object.
put right near far dist.
__________________
My TEN entry My THU entry
I didn't leave Max/Autodesk...they left me.
 
Old 03 March 2013   #3
Quote:
Originally Posted by stefan
falloff map type:distance direction:object.
create dummy somevhere up. set it as object.
put right near far dist.


Better to use direction:World Z-Axis.
Using an object would introduce inaccuracies on a big enough scene.
 
Old 03 March 2013   #4
I'll definitely try this, thanks guy!

Is there a way to clamp the map? The actual height of the scene isn't terribly tall and I need good precision.

By default does the map clamp to the lowest and tallest objects in the scene if you use direction:World Z axis?
 
Old 03 March 2013   #5
The values are mapped to the min/max distances you specify. Measure the height of your object/scene and use its lowest point as the min and its highest point as the max.
 
Old 03 March 2013   #6
have you tried rendering the z depth as 32 bit per channel exr file ?

I make the assumption that max does resolve the depth correctly.....

1000 meters @ 8 bit should give a resolution of 3.9 meters per level
1000 meters @ 16 bit should give a resolution of 0.015258 meters per level
1000 meters @ 32 bit should give a resolution of 0.000000232 meters per level

suppose is does depend on you ability to access the data in the exr file

or even something along the lines of....

Code:
bm = render $camera01 outputHDRbitmap:true vfb:false channels:#(#zDepth) getChannel bm [404,263] #zdepth


might do the trick

Last edited by Klunk : 03 March 2013 at 02:45 PM.
 
Old 03 March 2013   #7
seems to give pretty good depth resolution....

Code:
fn ScreenToWPostion xy zdepth vp_size = ( vp_pos = mapScreenToView xy zdepth vp_size; vp_pos * inverse (viewport.getTM()) ) fn PointRenderSceneFromDepthMap w h = ( -- render depth bm = render $camera01 outputHDRbitmap:true vfb:false channels:#(#zDepth) outputwidth:w outputheight:h; for i = 0 to w - 1 do ( for j = 0 to h - 1 do ( zdepth = getChannel bm [i,j] #zdepth if zdepth[1] > -100000.0 then point pos:(ScreenToWPostion [i,j] zdepth[1] [w,h]) size:200 ) ) ) viewport.setCamera $camera01 PointRenderSceneFromDepthMap 32 32



kept the width and height low when creating points this will then render points to the scene from the rendered depth map.

Last edited by Klunk : 03 March 2013 at 07:55 PM.
 
Old 03 March 2013   #8
this shows it off better though you need to go to vertex subobject level to see the result

Code:
fn ScreenToWPostion xy zdepth vp_size = ( vp_pos = mapScreenToView xy zdepth vp_size; vp_pos * inverse (viewport.getTM()) ) fn PointRenderSceneFromDepthMap w h = ( -- render depth msh = mesh numverts:(w*h) numfaces:0 bm = render $camera01 outputHDRbitmap:true vfb:false channels:#(#zDepth) outputwidth:w outputheight:h; verti = 1 for i = 0 to w - 1 do ( for j = 0 to h - 1 do ( zdepth = getChannel bm [i,j] #zdepth if zdepth[1] > -100000.0 then ( setvert msh verti (ScreenToWPostion [i,j] zdepth[1] [w,h]) verti+=1; ) ) ) update msh msh; ) viewport.setCamera $camera01 PointRenderSceneFromDepthMap 400 400
 
Old 03 March 2013   #9
Quote:
Originally Posted by solarnoise
Hi all, I have an interesting little problem and I'm new to working with matrices so I thought I'd ask for help here.

I need to create a depth map. Unfortunately the one made in my camera's space is not very good... we need the depth as though it were from the top-down and then rendered from the camera.

I imagine there has to be a way to get the zdepth data from the top-down, and then use the camera's transform or projection matrix to get it "back" into camera space and render from there?

is anything different than the height map? (see HeightMap : BakeElement)

# set projection
# apply planar mapping
# render heightmap element to the texture
# (don't use cage, use ray offset)
 
Old 03 March 2013   #10
Thanks for the suggestions, guys. I'll try out these methods and see which yields the best result.

Question about the falloff map parameters: what are near and far distances relative to? I'm assuming it's from the camera, which is not top-down... but I really need a nice evenly applied map that falls off from the lowest object to the highest object on the World Z axis. I set the direction to be World Z but am getting some weird results still, trying to find the right near and far values.
 
Old 03 March 2013   #11
Quote:
Originally Posted by solarnoise
Thanks for the suggestions, guys. I'll try out these methods and see which yields the best result.

Question about the falloff map parameters: what are near and far distances relative to? I'm assuming it's from the camera, which is not top-down... but I really need a nice evenly applied map that falls off from the lowest object to the highest object on the World Z axis. I set the direction to be World Z but am getting some weird results still, trying to find the right near and far values.


If you are using the direction of the World Z Axis in the falloff map, the near/far values are the actual world Z values in scene units, unrelated to the camera.
 
Old 03 March 2013   #12
Quote:
Originally Posted by lo
If you are using the direction of the World Z Axis in the falloff map, the near/far values are the actual world Z values in scene units, unrelated to the camera.


That's what I was hoping!

Now sorry if this is a dumb question, but shouldn't I be allowed to input a negative value to account for the objects that are sitting below the XY plane? Going off what you said, a near value of 0 and a far value of 1 means it'll grab everything between the XY plane and a Z of 1... but what about objects with negative Z?
 
Old 03 March 2013   #13
I'm trying it now and it doesn't seem to work at all. Perhaps it's not as I remembered.
I'm pretty sure BerconGradient can do it though.
 
Old 03 March 2013   #14
You can right-click the spinner and via Show in Track View change its value to negative one. That said, it seems to be broken nonetheless: Falloff: Distance Blend: World XYZ-Axis (Broken)
__________________
Scripts :: linkedin
 
Old 03 March 2013   #15
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:50 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.