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.
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)
> 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)
> 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?? :?
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…
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 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
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?
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?
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.
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?