PDA

View Full Version : Render to texture: difference between ATI and nVidia?



hardtop
04-27-2006, 01:59 PM
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:
http://www.hardtopnet.net/temp/RADEON.JPG

on the Geforce, there are 2 bugs: the refraction itself is faulty, and there are "glitches" in the texture
http://www.hardtopnet.net/temp/NVIDIA.jpg

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):

http://www.hardtopnet.net/temp/NVIDIA_reflection.jpg

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

Matt Zamborsky
04-27-2006, 02:24 PM
you are using clip planes right? so there is a difference in using clip planes in GLSL.

sqrt[-1]
04-28-2006, 04:54 AM
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.

hardtop
05-02-2006, 04:44 AM
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

hardtop
05-02-2006, 05:19 AM
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

hardtop
05-02-2006, 08:35 AM
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

Mars_999
05-02-2006, 07:25 PM
Originally posted by hardtop:
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 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... :)

Korval
05-02-2006, 09:04 PM
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.

Relic
05-03-2006, 01:15 AM
I have successfully used clip planes in conjunction with the GLSL gl_ClipVertex output variable. Try adding that calculation to the vertex shader.

sqrt[-1]
05-03-2006, 03:49 AM
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

hardtop
05-03-2006, 06:17 AM
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

sqrt[-1]
05-03-2006, 06:44 AM
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.

hardtop
05-03-2006, 02:58 PM
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:

http://www.hardtopnet.net/temp/error_clip.jpg

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

HT

V-man
05-03-2006, 08:35 PM
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?

hardtop
05-04-2006, 01:42 AM
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?

hardtop
05-04-2006, 01:49 AM
Did I say "above"? I mean "below"...

k_szczech
05-04-2006, 12:32 PM
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.

hardtop
05-05-2006, 09:05 AM
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

hardtop
05-10-2006, 08:08 AM
Anybody got a clue? :)