Jason,

I was able to figure out the technique to accomplish this on Thursday before I 
went out of town.  Here are the steps I went through:

*         Create a polygon of the lake

*         Create an osg::Texture2D

*         Create an osg::Camera

o   Set to pre-render mode

o   Set to render in the frame buffer

o   Set to an orthographic view

o   Attach the lake polygon to the camera, it seems to me that this is how the 
geometry is used to populate the newly created texture and that this is 
referred to and render to texture (RTT or RTT camera)

*         Apply the newly created texture to the osg::Heightfield

I got this working using a simple test application to figure out how to do it.  
I will add it to the real application today, but I expect it will work out as 
nicely as it did in the test application.  I will let you know how it goes and 
at that time I will also post the source code for my test application in case 
anyone else wants to see how this works.

Thanks,
James

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jason Jerald
Sent: Thursday, October 22, 2009 4:41 PM
To: 'OpenSceneGraph Users'
Subject: Re: [osg-users] z-fighting issue with coplanar polygons

James, I am fairly new to OSG so I do not know what specific classes or API 
calls might be used.

In non-OSG terms I think a way to do it would be to:


1.       Create your lake geometry placed in relation to the terrain

2.       Set up an orthographic camera looking from above, down towards the lake

3.       Render the lake to texture

4.       Set the uv texture coordinates of your terrain geometry to be equal to 
x,y (i.e., ignore the height)

5.       Apply the lake texture to the terrain geometry

I am sure there are more specific steps to think about as you implement it.  
Let us know if it works or if you think of something better.

Jason




From: [email protected] 
[mailto:[email protected]] On Behalf Of James Adkison 
ARA/CFD
Sent: Thursday, October 22, 2009 4:02 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] z-fighting issue with coplanar polygons

Jason,

I'm going to try the 'project textures onto the terrain via UV mapping' 
solution today.  I searching how to do this right now and I'm not sure if I 
finding relevant information.  Can you provide a brief/high-level description 
of the steps I would need to go through to perform the UV mapping, specifically 
what classes and/or API calls would be involved, or a tutorial?  I found some 
information on a RTT camera but I'm not sure if this is what I'm looking for.

James

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jason Jerald
Sent: Wednesday, October 21, 2009 9:09 PM
To: 'OpenSceneGraph Users'
Subject: Re: [osg-users] z-fighting issue with coplanar polygons

I don't see much for performance implications as long as you are not 
dynamically changing the texture every frame.

Jason


From: [email protected] 
[mailto:[email protected]] On Behalf Of James Adkison 
ARA/CFD
Sent: Wednesday, October 21, 2009 11:56 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] z-fighting issue with coplanar polygons

I'm not very experienced in OSG and I spoke to a co-worker about this approach. 
 The thought is that there might be some performance implications with this 
approach.  This is because there may be multiple surface feature types and they 
can be enabled/disabled separately.  For example, if there are lakes and 
forests they will be created in the texture but each time one of them is 
enabled disabled this process has to be repeated and each texture would be 
approx 1k x 1k.  I'm going to give it a shot and see how it performs.   Any 
other thoughts in the mean time?

James

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jason Jerald
Sent: Wednesday, October 21, 2009 2:16 PM
To: 'OpenSceneGraph Users'
Subject: Re: [osg-users] z-fighting issue with coplanar polygons

Can you project onto a texture and then apply the texture to the geometry?  
Either in a modeling package or algorithmically by rendering to a texture and 
then project that texture onto the terrain by planar uv mapping?

 Jason




From: [email protected] 
[mailto:[email protected]] On Behalf Of James Adkison 
ARA/CFD
Sent: Wednesday, October 21, 2009 10:25 AM
To: [email protected]
Subject: [osg-users] z-fighting issue with coplanar polygons

I'm using an Heightfield to represent my terrain and parts of the terrain could 
have a surface feature (e.g. a lake).  The lake is being drawn as a polygon 
directly on the surface of the terrain.  This, of course, is causing z-fighting 
to occur between the terrain and the surface feature.  I have been trying to 
solve this problem and have run across a couple solutions but they aren't 
working for me.

I have tried using polygon offset with the GL_OFFSET_POLYGON_FILL mode, which 
works when zoomed out far but up close z-fighting still occurs.

I have tried using a stencil buffer approach but I can't get it to work 
properly.  I can get the surface feature to stencil out the area of terrain but 
if you rotate the scene so that the surface feature is behind a mountain the 
stencil is still in place and the feature is rendered through the mountain.  
Hopefully, I am doing something wrong and someone can explain how I can make 
this work.

James
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to