Artifact with Caelum and far clip plane

khawkins

02-01-2009 04:37:08

I'm using the trunk version of Caelum (rev 355) and have been noticing an artifact that flickers when I move the camera. Here's a screenshot:



The Ogre::Camera is attached to a scene node, and the scene node is transformed to move the camera around the world. I have my own main loop (no frameStarted, etc.) so I'm handling the CaelumSystem::notifyCameraChanged(), the camera scene node transforms are setup before CaelumSystem::updateSubComponents(), which is called prior to renderOneFrame().

I noticed that if I set the camera far plane to infinite (0.0), then the artifact goes away. My near plane is 1.0. The artifact starts to show up when the far plane is around 100.0 and gets worse the further out the far plane is set. I first noticed this when I disabled stencil shadows, I assume because of the far plane no longer being 0.0, so things have been working (or looking) great for a while until then.

Any ideas?

Edit: I should have mentioned that this only seems to happen in two places in the environment: +/- 90 degrees of camera y-axis rotation from identity, or basically along the world x-axis.

cdleonard

08-01-2009 18:58:31

I was hoping all the far clip plane issues were gone by now. I have no immediate ideas; but maybe you can give more info:
- Does this happen in motion or when standing still? Flickering in motion is caused by poor ordering of update calls.
- Can you reproduce this in the demos? CaelumLab has a far clip plane slider.

scratchyrice

16-01-2009 07:47:41

I seem to be having the same problem (i think). However, i only seem to get a flicker, when i change the yaw of the camera. I have a demo http://www.scratchyrice-dev.co.uk/downloads/chaosengine.rar demonstrating this. It uses hydrax, but ive completely disabled it in this demo, I.e, im not even making an instance of the hydrax class. The hydrax dll is included simply for easy linking.

Anyway, you can control the camera with the arrow keys. Test first by just going left and right. It works fine. Then try up and down, combined with left and right, and the terrible artifacts appear. It looks like some kind of plane is being updated incorrectly, the plane seems to change colour according to the light, So its hard to see at times, But it is there. Also notice how it seems to flicker every other frame.

My order of update is:
Camera
Caelum
Ogre

Im using the manual update (->updateSubComponents). Ive tired using the addFrameListener method, but it does the exact same thing. Also it seems to do the exact same thing with hydrax. Ive almost got caelum and hydrax intergration working fully, apart from this small thing.

I hope this helps.

Cheers,
Scratchy.

Edit: Sorry about the size, Alot of it is caelum textures tho, so i hope you wont mind.

Edit Again: Oops, my bad, seems its not caelum textures, but hydrax.

Azatoth

16-01-2009 11:25:48

This issue might perhaps be caused by the situation described here?

scratchyrice

16-01-2009 16:36:52

This issue might perhaps be caused by the situation described here?
Thanks, but this is a caelum related issue im having. Hydrax is working fine. Ive tried completely disabling hydrax, and it does the exact same thing, as the demo shows.

Azatoth

16-01-2009 16:43:39

The issue I described in that post is not specific to Hydrax. It's about how the position of the camera isn't updated correctly until after a full scene traversal has occurred. It just happens to manifest as an error in Hydrax, but could as easily manifest as an error in any other code which also depends on the derived position of the camera.

scratchyrice

16-01-2009 17:26:59

Ah i see, Thanks. I will give it a look. But surely if it happens in caelum, and it was that problem, it would also happen to hydrax?

scratchyrice

16-01-2009 17:28:39

Ok ive had a look, But im not controlling the camera via scene nodes (I dont see the advantage as a debug camera at this point), but with directly setting the yaw, pitch, roll of the camera. Is this the problem?

Azatoth

16-01-2009 17:31:45

If you're altering the camera directly and don't alter any scene nodes that could exists between the camera and the root node you're in the clear. The issue is something else.

scratchyrice

16-01-2009 18:57:21

If you're altering the camera directly and don't alter any scene nodes that could exists between the camera and the root node you're in the clear. The issue is something else.
Indeed, That is what im doing. Editing directly by cameraName->yaw, cameraName->roll, cameraName->pitch.

As i said, this artifafact only appears when i move the camera on the x axis, and then move the camera. If i keep it at its original yaw(i think), no artifacts appear.

scratchyrice

16-01-2009 19:03:13

Update - The artifacts become more and more obvious as i increace the far clip distance. Thing is, i need a high clip distance for hydrax to work.

scratchyrice

16-01-2009 19:38:40

Update - Found the problem. Setting clip distance near, to 4 or above seems to work. It may be able to go lower, but i havent tested.

Scratchy.

khawkins

16-01-2009 20:00:52

Azatoth: I saw that post while researching how to fix this issue, so I added the _update() call but didn't get a change in behavior.

cdleonard: It's only flickering because the camera moves and the artifact changes size/shape, but the screenshot I took was when the camera was frozen and the artifact appeared to where I could get a screenshot of it. Basically, I'm able to rotate the camera to a point where I can get the artifact to remain on the screen. I haven't tried out CaelumLab, but a friend of mine says he sees the same issue in another application that uses Caelum with texture shadows enabled.

scratchy: I played around with the near/far clip plane to get it to minimize the effect as well, but in doing so the clip settings are not acceptable for both Hydrax and my application. And yes, the artifacts become more and more obvious the higher the far clip distance. For me the artifacts started at a far clip of 100, which also clips the layered clouds of Caelum and frankly makes the scene look pretty bad.

scratchyrice

16-01-2009 20:23:37

I played around with the near/far clip plane to get it to minimize the effect as well, but in doing so the clip settings are not acceptable for both Hydrax and my application. And yes, the artifacts become more and more obvious the higher the far clip distance. For me the artifacts started at a far clip of 100, which also clips the layered clouds of Caelum and frankly makes the scene look pretty bad.
khawkins

This is weird, as now i have my near clip set to 4, and my far set to 9999999*6, And i no longer get any artifacts.

Scratchy.

cdleonard

18-01-2009 12:39:52

Recent versions of caelum (trunk) should work with any near and far clip plane settings; by resizing the domes. There were some issues in 0.3 which got fixed later but we're not merged in 0.3. That was still several months ago.

I updated documentatin about what you need to call in order to keep CaelumSystem running: http://caelum.sourceforge.net/doc/trunk/html/classCaelum_1_1CaelumSystem.html#_details.

I'm sorry; but I don't know what else I can do to help.

scratchyrice

18-01-2009 17:22:18

I'm sorry; but I don't know what else I can do to help.
Cheers dude, I will check this out. Don't worry about it, The fact that this awesome library is free, is enough for people to want to use it.

xadh00m

18-01-2009 22:25:48

The fact that this awesome library is free, is enough for people to want to use it.
...and allows it to look into the code ourself! :wink:

khawkins

31-01-2009 05:53:59

I haven't been able to look at this for a few weeks, but once I had a chance I decided to start over with Caelum by cleaning out my code and grabbing v0.4 from the SVN. Unfortunately, the problem is still there - actually it's worse if I put the near/far clip plane distances to 4 and 999999*6, respectively:

[attachment=2]caelumissue2.jpg[/attachment]

Of course, it also works just fine if I move the camera to another angle (hence the appearance of "flicker" when moving/rotating the camera quickly):

[attachment=1]caelumissue3.jpg[/attachment]

Here's another view of the 4/99999*6 clip plane distance results:

[attachment=0]caelumissue4.jpg[/attachment]

As I rotate the camera's forward vector closer to the x-axis the gray area gets smaller, and as I rotate the camera's forward closer to the y-axis the gray area gets bigger, although it looks like it's stopping halfway there.

I mentioned it before, but I never saw this until I turned stencil shadows off. Actually, after upgrading to v0.4, I figured out that as long as stencil shadows are on these problems don't come up. If I turn shadows off altogether or turn on texture shadows then this happens. My update order is:

1. Update camera(s) position/orientation
2. for each camera call notifyCameraChanged()
3. Call updateSubcomponents()

If I am reading it right, then I believe that is what the documentation says to do (http://caelum.sourceforge.net/doc/trunk/html/classCaelum_1_1CaelumSystem.html#_details).

So, I'm at a loss at this point too. I really like Caelum and have used it for a long time without seeing this sort of thing, so it kind of sucks to run into an issue once I disable stencil shadows.

cdleonard

03-02-2009 18:06:22

Do you really use multiple cameras? You should first updateSubcomponents and then notifyCameraChanges for each individual camera before rendering with the camera. Yes; this means you can't rely on auto-updates ogre target (very bad).

Also; you can use an infinite far clip distance (by setting it to 0) without stencil shadows.

I tried your very large clip ranges and was still unable to reproduce the issue.

khawkins

04-02-2009 04:34:58

The screenshots I've shown aren't actually using multiple cameras, but yes the system supports multiples.

I tried a bunch of things, including the order you suggested, starting from scratch with the setup and update code, and trying the framelistener route similar to CaelumLab - but no luck. However, changing the camera far clip to 0.0 did fix the problem.. I'd just hate to do that since it's not the real fix.

I may shelve it for now and come back to the problem later, possibly with a deeper investigation of my Caelum usage code. I don't have enough understanding right now about Caelum and Ogre to spend time fixing this problem in a reasonable time frame.

Thanks for taking a look and trying.

khawkins

23-02-2009 02:35:26

I just wanted to update, particularly for cdleonard. I ran the code on my laptop, which has an ATI Mobility X1400, and this problem does not occur.

Previously I ran this on my desktop, which has an NVIDIA 8800 GT. It doesn't really make sense to me, but I thought I'd update with this latest information.