Poor precision in depth texture

Sage
Posts: 1,199
Joined: 2004.10
Post: #46
icklefrelp Wrote:My current plan on this is to try it on a PC to see if I get the same results on an NVIDIA card in a PC as I do on my 9600 in my G5. However my home PC is in bits and I was off work last week, so I didn't get a chance to start porting my engine to the PC again. It shouldn't take me that long, most of the code is portable, I just need to redo the PC specific parts.

Depending on the results whether I can get it working on PC in GLSL, or Cg or whether I just get the same results as on the Mac should indicate where any possible problem lies.

Thank you icklefrelp! If you can pinpoint it, it might make for a bug report to Apple. That is, if it's a bug.

I don't own a PC, and my only mac has a 5200, so I appreciate that you're doing your own testing.
Quote this message in a reply
Member
Posts: 30
Joined: 2006.04
Post: #47
I have an update on this, but it's still not good news. On the PC using the Geforce 6800GT
that I have in work, I'm getting the same banding as I got on my Geforce 6600 in my G5.
The code is the same, and currently using GLSL, I might try switching this shader to use Cg
instead but I'm not sure it will make any difference.

I'll post on the NVIDIA developer forums later and ask if there is any way to get the same results as I'm getting on the ATI card now I know that it's a NVIDIA issue not an Apple issue.

Will keep you posted.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #48
Thank you, it's good to know it's not just me.

Seems funny, to me, that the feature would even be exposed if it's so broken.
Quote this message in a reply
Member
Posts: 30
Joined: 2006.04
Post: #49
Well I went to NVidia's Developer forums to post my problem, but before hand I decided to do a quick search to see if anybody had posted something similar already. I think the first thread I checked was almost an exact match, 8-bit precission in the depth texture. The last post in the thread had a link to the solution to this problem, which didn't work to me.

http://www.opengl.org/discussion_boards/...3;t=013943

But the rest of the thread mentioned the basics:-

GL_LUMINANCE is needed for the depth texture lookup, _not_ GL_INTENSITY,
GL_NEAREST as interpolation, and the internal depth texture format must be
GL_DEPTH_COMPONENT24.

So I changed my filtering to use GL_NEAREST and would you believe it, it worked.
NOTE: This is on the PC, I haven't yet tried this on my Mac, I will do so when I get home in half an hour or so, hopefully it will work too. Here is the PC screenshot.

[Image: shot2.png]

I feel a bit foolish for not checking there earlier but oh well, you live and learn. I had to get my code working on the PC again at some point. I can't believe it was that simple.

Hope this solves your problem too.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #50
I'll be interested to hear if this works on your mac. Unfortunately, it's the exact approach I'm taking ( having seen similar posts ).

Perhaps it's failing because I'm using RECT textures? I know that sounds silly, but it's the only difference I can see...
Quote this message in a reply
Member
Posts: 30
Joined: 2006.04
Post: #51
I was using RECT tectures too. The code I am using is exactly the same on the PC as it is on my Mac save for the Cocoa / MFC interface.

Regardless, it also doesn't work on my G5 so I'm tempted to say now that it is a bug in Apple's Implementation as both cards are in the same family.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #52
Well, at least it's comforting -- in a way -- to know there's nothing I can do about it. Thanks for your hard work tracking this down. May I request you file a bug report? Apple may never realize this is broken unless you do!

( ideally, the bug report would include a working windows version as well, using the same gl code )
Quote this message in a reply
Member
Posts: 30
Joined: 2006.04
Post: #53
TomorrowPlusX Wrote:May I request you file a bug report? Apple may never realize this is broken unless you do!

( ideally, the bug report would include a working windows version as well, using the same gl code )

I have already done so. I included the basic steps to recreate the problem, creating the depth texture, my shader code and how I render the fullscreen effect which applys the shaders. I also attached a zip file containing three screenshots showing the results of running the code on the three different machines.

Unfortuanatly there is not a lot more I can do now but wait, which is a shame as now I've got this part of depth of field working in OpenGl on some machines I want to use it Sad
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #54
I want to use it too. My water shader's more or less good to go, but without being able to read back correct values from the depth buffer, I can't implement murky water ( like here: http://www.uen.org/utahlink/tours/admin/...4bass1.jpg )

So it goes.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #55
Well, I bought a new Mac Book Pro, and by god, it works here! So I added "visible depth" calculations to the water shader to take into account the "thickness" of the water compared to the depth map of the rendered scene, and it looks wonderful.

[Image: GLSLWaterApp-2006-11-03-00.png]

And larger ( linked, because it's huge )
http://zakariya.net/shamyl/etc/GLSLWater...-03-04.png

This makes me very happy.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2005.05
Post: #56
:o That looks amazing! Any chance of a built demo Grin ?
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #57
TomorrowPlusX Wrote:Well, I bought a new Mac Book Pro, and by god, it works here! So I added "visible depth" calculations to the water shader to take into account the "thickness" of the water compared to the depth map of the rendered scene, and it looks wonderful.

It looks real.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #58
Matrix Wrote::o That looks amazing! Any chance of a built demo Grin ?

Actually, I'll be posting the whole framework & source pretty soon.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #59
TomorrowPlusX Wrote:Actually, I'll be posting the whole framework & source pretty soon.

[Image: bowdown1.gif]
Quote this message in a reply
Ciaran
Unregistered
 
Post: #60
Coming late to this, but maybe it helps someone...

I had the same problem. Eventually got it working with:
GL_DEPTH_TEXTURE_MODE_ARB = GL_LUMINANCE
GL_TEXTURE_COMPARE_MODE_ARB = GL_NONE
GL_TEXTURE_MIN_FILTER = GL_NEAREST
GL_TEXTURE_MAG_FILTER = GL_NEAREST
depth texture format must be GL_DEPTH_COMPONENT24_ARB.

(as per the opelgl.org thread)

but making sure to use the GL_TEXTURE_RECTANGLE_ARB target on any glTexEnv calls. My shader is in Cg, but I suspect it's the same driver path.

This is with nvidia geforce fx and 7xxx cards on linux...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Normal Mapping Precision on iOS OptimisticMonkey 6 20,612 Apr 13, 2011 11:35 PM
Last Post: OptimisticMonkey
  Poor quality Maya PLE Render. Marjock 0 2,911 Jan 2, 2006 05:02 PM
Last Post: Marjock
  Higher color precision CobraMantis 2 3,258 Aug 20, 2005 03:49 PM
Last Post: arekkusu