Poor precision in depth texture

icklefrelp Wrote:The black area would be the focal point, and white at and beyond the near and far depth values. If I had a larger scene to play with I could show it over a larger range. However as I am not rendering the depth value directly, I am possibly hiding the evidence of any banding. This is running on a Mobility Radeon 9600 which slows down quite a lot with this shader probably due to the branching. I have not yet tried it on my Geforce 6600.

How are you generating your depthmap? Is it render-to-texture, or glCopyTexSubImage?

You ran this on an macbook? I thought the gma 950 didn't support fbo's?
Could you post a stack trace of the debug build? ( you might need to manually set the build architecture in xcode to x86, since I think on my machine it defaults to ppc ).

I'm using GLEW to bind opengl functions, and since this is a test ( not serious work ) I'm not actually testing for the presence of various methods. If you post a stack trace from the debug build I could see which gl call causes the crash ( if it is a gl call ).

TomorrowPlusX Wrote:How are you generating your depthmap? Is it render-to-texture, or glCopyTexSubImage?

Currently I'm using glCopyTexSubImage the same as you. And I am creating the texture
in the same way too. I was supprised, I was expecting to see banding as I'm not doing anything differently. Could it be down to different graphics cards if not my shader.

Damn, is there no end to the difficulties between video cards? You get banding on some, sometimes the same thing works one time and not another, even on the same video card! Such as your depth texture working, but not TomorrowPlusX's. Also, how my FBOs don't work correctly on NVidia cards. For my problem, I'll try having different depth renderbuffers for my two FBOs next to see if that's why it doesn't like clearing, but seriously, it's getting downright annoying.

TomorrowPlusX Wrote:Could you post a stack trace of the debug build? ( you might need to manually set the build architecture in xcode to x86, since I think on my machine it defaults to ppc ).

Well, the architecture in the debug build is set to $(NATIVE_ARCH) and it is producing an Intel binary. The stack trace returns the same as I posted above, but running it in the debbuger shows this line in main.cpp [294]:

So... is there any resolution on this? Between here and mac-opengl mailing list I've seen no actual response from anybody who knows the internals to tell me if NVIDIA cards ( or mine ) downsample gl_depth_component textures to 8-bit.

In principle, my water rendering looks good enough ( now that I've done some more refactoring and fixing up of normal handling ) but I'd sure like to add this feature.

No, they don't downsample depth textures. Plenty of games use depth textures successfully (Halo, Myst V), so I'm sure there's nothing wrong with the basic implementation. Whether they work with GLSL is, of course, a slightly different question.

My water's looking OK now, but I wish I could do per-fragment depth lookups without having to render to a dedicated depth texture.

That said, while I was on vacation I read through the orange book, and re-implemented my water adaptation. Primarily, the improvements are a better approach to the normalmap ( making for better wave interference ) and little bits like scaling the reflection/refraction distortion by distance from the camera.

It's time for me to start integrating this into my game.

... well... once I figure out why my lighting is inverted in my reflection

TomorrowPlusX Wrote:So... is there any resolution on this? Between here and mac-opengl mailing list I've seen no actual response from anybody who knows the internals to tell me if NVIDIA cards ( or mine ) downsample gl_depth_component textures to 8-bit.

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.