rendergather / osgocean

Automatically exported from code.google.com/p/osgocean
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Problems using osgOcean with CompositeViewer #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There are some problems using osgOcean with a CompositeViewer with multiple 
views. The last view added to the viewer (so presumably the last one to be 
rendered) will control LOD of the ocean tiles, and will be the only view in 
which some effects will be visible (refraction, transparency, height map). I am 
investigating this, but it seems only effects requiring MRT behave this way - 
reflection is fine in multiple views.

I have modified the oceanExample to demonstrate this when run with the 
--compositeViewer argument. The post-render passes (DOF, glare) won't work at 
all in multiple views, I get a black screen. However, this is of less 
importance for us in the short term as we don't use these effects anyways, so I 
have disabled them completely for now.

The effects that concern me right now are reflection and transparency (which 
uses the refraction MRT pass). Reflection works correctly in multiple views 
already. But in the short-term I need to use transparency.

Symptoms of the problem:

1. LOD
This is not really a problem for us, as both views' viewpoints will generally 
be close to each other in our present application.

2. Refraction
The refraction MRT only applies to the last view in the CompositeViewer. Is 
this because the MRT just uses the same textures? Would we need to have 
multiple target textures, one for each view, and just swap them in the cull 
traversal for each camera? If so, we might want to adopt a strategy similar to 
the osgShadow view dependent techniques, which is to store a ViewData object 
per view and use this for things that must be kept different for each view.

3. Shadow in refraction
When the refraction MRT is used with osgShadow, the shadow in the refraction 
seems to be one frame late (presumably because the refraction MRT happens 
before the shadow pass for the current frame). 

Let me quickly describe an example of when that happens: Imagine there is a 
port with a dock, where the dock has a floor pretty near the surface. Some 
object in the port (say a crane) casts a shadow that is visible through the 
water on the dock floor. The crane's shadow outside the water is fine, but the 
shadow on the dock floor when seen through the water surface (so in the 
refraction MRT) is one frame late, which we can clearly see when 
moving/rotating the camera.

Presumably, we would need to ensure the shadow pass happens before the 
refraction MRT, but I have no idea how to do this.

As mentioned above, I modified the oceanExample to demonstrate this use case.

Use --compositeViewer to trigger the creation of a small inset view.

You should also use --testCollision so you can see the effects without having 
to move towards an island. Still, moving toward an island is educational as 
well, as you'll clearly see that the ocean tiles only take the last view (the 
inset by default) into account.

Then, to see the result when adding the main view last (instead of the inset 
view which is the default, since it's the case I've seen in most apps) you can 
use the --mainViewLast argument. Then the main view will be OK, but if you move 
the main view's camera towards an island, you'll see that in the inset view, 
the boat floats way above the ocean because the ocean tiles are now at a very 
low LOD. When staying close to the boat in both cases, you'll see the 
refraction/transparency doesn't apply to the inset view, even though reflection 
is fine.

I'd like some comments on this, mostly focusing on the transparency effect. 
What are some possible solutions, is the one suggested above a good one?

Original issue reported on code.google.com by jean.sebastien.guay13@gmail.com on 14 Apr 2011 at 1:58