Projective texturing artifacts

Started by
3 comments, last by Chargh 12 years, 8 months ago
I'm doing some reflective texture projection on a nonplanar surface and I'm pretty happy with the result, though I get some strange artifacts in places that I can't explain.

My rendering steps are:

1) Generate a texture by rendering the scene after flipping the camera over the water plane.
2) Disturb the water surface by adding some waves
3) Render the surface, while projecting the reflective texture using the flipped viewProjection matrix.

This is one of the images I've collected:

[attachment=1768:water2.jpg]

As you can see marked by the red arrow, there's some weird artifacts here. These are very view dependent, and always appear as some kind of triangular shape. They appear only when the camera is viewing the water from a low glancing angle.

Here's a look from a slightly different view.
[attachment=1769:waterReflect1.jpg]

These artifact pixels are blue because it is not getting a sample from the reflection map at that location, almost like there's a hole in it or something. I looked at the actual image I'm sampling from and it doesn't look like it has any issues:

[attachment=1770:reflect1.jpg]

It seems like the artifacts are always on the side of the wave that is most facing the camera. I thought this might have something to do with these being parallel with the reflected camera's location, but I don't understand why that would cause this to happen. I could understand if I had a very poor image quality in that location, maybe even a single texel that is heavily blurred, but I don't understand why it would seem to be totally missing. All I'm doing is calculating the world space position, multiplying that by the flipped viewprojection matrix, and then using that coordinate to sample the reflection map.
[attachment=1771:artifacts.jpg]

I don't know if that's got anything to do with the problem, I don't really understand how it could, but I'm just speculating.

Thanks for any ideas or suggestions.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Advertisement
Your reflection looks wrong. The vertical refleced lines are not distrurbed whereas the horizontal lines bend with the wave. The artifacts occurs at dent of your horizontal reflected lines, this looks like a calculation error where some component is zero or similar.
I will admit that the reflection is not 100% accurate, but that's really not possible short of full-blown raytracing, so I'm just trying to come up with something that looks convincing at decent framerates. I actually think it looks pretty good while in motion, so for now just trying to solve these artifacts. I can also add some offsets based on the normal to perturb the wave so the vertical lines aren't so straight, but basically with projective texturing it only really works when the water is perfectly flat plane, and requires some hacks and departure from reality to bend the surface.

I'm trying to think of what in my equations might cause this miscalculation, but there's not too much calculation to be done. Here's relevant snippets of the shaders:


main() { //vertex shader

vec4 worldVertex = ModelMatrix * inVertex;
float waveHeight = ...;
worldVertex += waveHeight;

}

main() { //frag shader

projVertexFlip = ViewProjMatrixFlipped * worldVertex;
projTexVertexFlip = texRemapMatrix * projVertexFlip; //map -1 to 1 ndc to 0 to 1 texture coordinates
vec4 reflectColor = textureProj(reflectTex, projTexVertexFlip);

}
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Hi,

I know this topic is a bit old, but have you ever solved this problem? I have similar problem and cant find solution.

Thanks

Hi,

I know this topic is a bit old, but have you ever solved this problem? I have similar problem and cant find solution.

Thanks


Maybe you have better luck PM-ing karwosts?

This topic is closed to new replies.

Advertisement