Dear Shayne,

Recently I used a vertex+fragment shader to do color-coding of
altitude of a terrain model in OSG. I don't have exact measurements,
but I did not experience (nor expected) noticeable performance issues.
In this typical case I used a simple in-shader colormapping (like
going from blue-to-yellow), but a 1D texture lookup gives you more
flexibility in coloring (as Gordon mentions, I see now).

To get your z-value in the fragment shader, you would typically use a
"varying float my_attitude" in both shaders, fill it in the vertex
shader :"my_attitude=glVertex.z", and use it in the fragment shader,
e.g. "gl_FragColor = vec4(my_attitude,my_attitude,my_attitude,1.0)". I
here consider the z to be normalized between [0..1], and generate a
color from black to white through grey.

I did experience some unpleasant side-effects in VPB-generated
terrains in POLYGONAL mode: the lower LOD levels have bigger "rough"
polys that pop in and out. With regular textures (e.g. aerial
photographs) you barely notice popping, but with artificial coloring
you really emphasize this and polygon ridges tend to stand out. Not
too much you could do about that, other than having extra/other data
besides the POLYGONAL terrain.

 I am now using a custom point-cloud "terrain" generated from LiDAR
data, which solves some of these coloring issues but has other
problems. To give you an idea of the colormapping effect using the
same shader on this data (shameless plug alert), see
http://graphics.tudelft.nl/~gerwin/media/3dtopo/Screenshot_pointcloud.png

good luck,
Gerwin

On Thu, Jan 15, 2009 at 5:42 PM, Tueller,  Shayne R Civ USAF AFMC 519
SMXS/MXDEC <[email protected]> wrote:
> Thanks Gordon. Good points for using a shader. Are there any performance
> hits with doing this at a pixel level? I wouldn't think so since the shader
> is pretty "thin"...
>
> -Shayne
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Tomlinson,
> Gordon
> Sent: Thursday, January 15, 2009 9:07 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] altitude terrain shading...
>
> With the Shader approach you still typically use a 1d texture, but can
> have good control of what color a pixel gets and you can place palettes
> in the texture etc.. Works well
>
>
> Gordon
>
> __________________________________________________________
> Gordon Tomlinson
>
> Product Manager 3D
> Email  : gtomlinson @ overwatch.textron.com
> __________________________________________________________
> (C): (+1) 571-265-2612
> (W): (+1) 703-437-7651
>
> "Self defence is not a function of learning tricks
> but is a function of how quickly and intensely one
> can arouse one's instinct for survival"
> - Master Tambo Tetsura
>
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
> Sent: Thursday, January 15, 2009 11:04 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] altitude terrain shading...
>
> Thanks to everyone that responded to my inquiry. I'll try the TexGen
> approach first and then do a shader at a later time...
>
> -Shayne
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Robert
> Osfield
> Sent: Thursday, January 15, 2009 1:58 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] altitude terrain shading...
>
> Hi Shayne,
>
> The standard way to do this would be to use a Texture1D for the colour
> banding and TexGenNode to compute the tex coords for you.  See the
> osgtexture1D example.
>
> Robert.
>
> On Wed, Jan 14, 2009 at 10:42 PM, Tueller,  Shayne R Civ USAF AFMC 519
> SMXS/MXDEC <[email protected]> wrote:
>> All,
>>
>>
>>
>> I have a requirement to do some altitude shading (coloring) to a
>> terrain database based off a referenced altitude. In other words, I
>> would like to shade the terrain to be green below a given altitude and
>
>> then shade it
> brown
>> at or above the given altitude. The reference altitude basically
> represents
>> the horizontal plane that intersects the terrain database. Any terrain
> below
>> the plane is shaded green and any terrain above the plane is shaded
> brown.
>>
>>
>>
>> My question is, is there any support in OSG that will allow me to do
>> something like this? My terrain is a database built with VPB.
>>
>>
>>
>> Any input would be most appreciated.
>>
>> -Shayne
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
>> org
>>
>>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to