gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.47k stars 772 forks source link

get image texture in contour map #2580

Closed YHLpuyu closed 1 month ago

YHLpuyu commented 1 month ago

I want draw contour line instead of the all surface, so is there a way i can get imagery in FS, and just draw contour line. like below:



void oe_contour_fragment(inout vec4 color)
{
    // the color already has pixel of imagery,
    float height;
    color=mix(color,black,mod(height,5.));

}
gwaldron commented 1 month ago

There is a built-in function called oe_terrain_getElevation you can call to get the height like so:

float oe_terrain_getElevation(in vec2 uv);
in vec4 oe_layer_tilec;

void oe_contour_fragment(inout vec4 color)
{
    float height = oe_terrain_getElevation(oe_layer_tilec.st);
    ...
}
YHLpuyu commented 1 month ago

thanks , i read the contourmap.glsl, and enable get height. But i want draw contour line above terrain tile, both see the imagery on the earth. i use step,mod in FS shader only draw slice of contour, the backgorund is white, if i don't set some color. i wish the background can contains imagelayer like tmsimagelayer. there is a screenshot in cesium, red line is contour line, background is texture of imagery image

is there a texture of terrain tile?

gwaldron commented 1 month ago

Then you should put the shader on the imagery layer.

<TMSImage name="ReadyMap 15m Imagery">
    <url>https://readymap.org/readymap/tiles/1.0.0/7/</url>
    <shader>
      <![CDATA[
        #pragma vp_function contour_line fragment
        in vec4 oe_layer_tilec;
        float oe_terrain_getElevation(in vec2 uv);
        void contour_line(inout vec4 color) {
            float height = oe_terrain_getElevation(oe_layer_tilec.st);
            color = mix(color, vec4(1,0,0,1), step(mod(height, 100.0), 1.0));
        }
      ]]>
    </shader>
</TMSImage>
YHLpuyu commented 1 month ago

Thank you very much for your help.

YHLpuyu commented 1 month ago

Thank you very much for your help.