Render to texture: difference between ATI and nVidia?

Hey all, I’ve just tested this on my brand new FS Amilo laptop, fitted with a 6800Go GeForce.

I don’t get the same result as with my desktop Radeon 9800 Pro. Here are the shots:

on the radeon, the refraction shows up correctly:

on the Geforce, there are 2 bugs: the refraction itself is faulty, and there are “glitches” in the texture

At first I rendered the reflection and refraction to a texture using glCopyTexSubImage2D and I had no glitch, but the refraction was wrong.

Now I render both using FBO’s and I experience the artefacts.

As for the refraction, if I go near the surface enough, it’s as if I went “under” the refraction image and I can see the correct reflection (although with artefacts):

I render both textures to a square viewport to a square (power of two) texture.

Anybody got a clue? I tested on 3 different nVidia graphic boards (6800Go, 6600GT, FX5200) and I always experienced the same behaviour.

Thanks a lot

HT

you are using clip planes right? so there is a difference in using clip planes in GLSL.

Can you perhaps do a GLIntercept XML frame grab on each ATI/Nvidia and post a link to the results.
(http://glintercept.nutty.org/)

(also ensure there are no GL errors while you are at it)

Or even better post a link to a .exe so we can try it out.

I am thinking you have a unset/undefined texture bound problem.

to sqrt[-1]> I’m doing the frame grab right now on the nVidia, I’ll post the results ASAP.

I’ll try the same on the ATI and post results tonight.

Thanks for helping!

to Matt> I’m using clip planes indeed. Should that make a difference between ATI and nVidia? I’m using 2 clip planes for my 2 render passes (one for reflection, which is working correctly, and one for refraction, which is buggy)

HT

OK results have been uploaded to http://www.hardtopnet.net/temp/Frame_002018.zip
(8 Mb download…)

here are the rendering steps:

> I render the scene once to a FBO for reflection
> I render the scene once more to another FBO for refraction
> I render the scene using reflection and refraction textures
> I render 2D elements

(OK I know, I’d have to cull more when rendering refl/refr textures, but I’m not through optimization yet, still have to implement octree and stuff…)

If you look at the code near the end, you can notice I render the scene using shader GLSL24 (you can search on that)

There I push:

1 -> reflection
2 -> bump map
3 -> dudv map
4 -> lightmap
5 -> refraction

I wonder if my camera / clipping plane are correct, it looks like one texture is flipped over or whatever. Strange it works on ATI.

One thing I remember is I had to set my clip plane just 0.1 unit below water plane, otherwise I’d have had artifacts.

HT

Okay after testing I noticed this:

> The strange wall at the surface is not caused by refraction but by reflection. If I disable refraction in the shader, the issue is still there
> If I remove reflection in the shader, I get no refraction, but a blueish tone.

This makes me think that the problem comes from clipping planes. I guess I’m not clipping right, as if the coordinated where inverted or whatever. Is there a difference between ATI and nVidia clipping plane implementation?? :?

HT

Originally posted by hardtop:
[b] Okay after testing I noticed this:

> The strange wall at the surface is not caused by refraction but by reflection. If I disable refraction in the shader, the issue is still there
> If I remove reflection in the shader, I get no refraction, but a blueish tone.

This makes me think that the problem comes from clipping planes. I guess I’m not clipping right, as if the coordinated where inverted or whatever. Is there a difference between ATI and nVidia clipping plane implementation?? :?

HT [/b]
I have had the same issue with my code on ATI and Nvidia. On ATI the clip plane seems to work as it should but on Nvidia it doesn’t work correctly. On ATI hardware I get a chopped off image when I RTT for my depth map and such, but with Nvidia it doesn’t do that, but renders the whole image… So as of now I am hoping someone from Nvidia can explain why that is… :slight_smile:

nVidia’s implementation of user clip-planes has always been… odd. There was something in GeForce 4-era hardware where two clip planes could be used, but it would actually take up a texture unit (one TU for 2 clip planes), presumably because it used the texture hardware and a special texture shader to implement it. If similar hacks are being employed now, that would explain why nVidia’s hardware isn’t necessarily doing the right thing, since it may be trying to do clip plane stuff in the actual fragment shader.

I have successfully used clip planes in conjunction with the GLSL gl_ClipVertex output variable. Try adding that calculation to the vertex shader.

I am sorry, but I am finding it too difficult to make sence of the log file (as also there are no color buffer dumps included to track the rendering )

I was under the impression that it was just a handful of render calls (judging from the screen shots) but the 100’s of immediate mode calls make it hard to debug.

I suggest you try the above suggestions of actually supplying a clip value in the vertex shader. (I have a vague memory of doing this for nvidia)

As a side note, did you try (and reject) the method of adjusting the near clip plane (in the projection matrix) and using it as the reflect clip plane? Lots of other people, including myself, do this.
http://www.terathon.com/code/oblique.html

thank you all for feedback

to sqrt and relic: I’ll test both possibilities (clip vertex and near plane adjustment)

to sqrt: I didn’t test and reject the solution yet, and I don’t see why I should reject it, as it seems to be a good workaround. I guess I should switch to projection matrix and adjust the near plane there. Maybe one solution is better than the other?

HT

Using the projection matrix clip planes:

Pros:

  • Full speed rendering (clip planes can cost)

Cons:

  • Slight depth buffer precision lost when rendering reflections. I have not had a problem with it however.

OK as I’m lazy, I tested the gl_ClipVertex implementation (and because my wife doesn’t want me to spend more time developing than necessary :-p )

I only use gl_ClipVertex when needed, i.e. when I need to clip, for reflection. When I set gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex, Everything is fine, except for the bump mapping shader, where I experience such a bug:

As you can see, the bump is blacked out. What could have gone wrong?

HT

I think clip planes are not a good idea. I was losing a lot of performance on a Radeon 9700, using GLSL. It was just for doing a flat mirror. I was wondering if it was done with software but someone from ATI said it is hw accelerated. I didn’t get around to do the clipping myself.

Anyway, why use it in the scene above?

For reflection of course! I don’t need it for refraction, but for reflection I have to clip everything that’s above water plane.

Anymore ideas?

Did I say “above”? I mean “below”…

Check your light source position, normal vectors, tangetn and binormals - these could go wrong in the reflected image.

BTW - I had one extremely weird experience with reflecting sky in the water. I had one float value computed in fragment shader that represented distance from eye vector to light source (sun) vector. I used this value to make sky brighter around sun, and to make a very bright circle (the sun itself) when this distance was very low. On NVIDIA it worked fine, but on ATI I had sun on the opposite side of sky that my bright area. Never actually find out what went wrong - my shader works fine now after some slight changes.

As for light source and tangent space, it works perfectly on ATI, for the reflection as well…
I don’t see why this could go wrong because I assign gl_ClipVertex… Or am I missing something?

Thanks

HT

Anybody got a clue? :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.