WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-05-2019, 04:24 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
The depth buffer on GPUs is non-linear, in order to provide greater precision to nearby objects.

You can convert a raw depth buffer value to linear and world units using the following code:

Code:
z = <raw depth buffer value>
znear = viz.MainWindow.getNearClip()
zfar = viz.MainWindow.getFarClip()

# Compute normalized linear depth value (0-1 range)
linear = (2 * znear) / (zfar + znear - z * (zfar - znear))

# Compute world depth value (distance from view plane)
world = (2.0 * znear * zfar) / (zfar + znear - (2.0 * z - 1.0) * (zfar - znear))
Reply With Quote
 


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying Scene? Brett Lindberg Vizard 0 08-28-2009 11:56 PM


All times are GMT -7. The time now is 01:35 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC