gwaldron / osgearth

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

LineSymbol not working (when using a custom GC) #2368

Closed devil-darkside closed 10 months ago

devil-darkside commented 10 months ago

Hi, I tried to set some LineSymbol for a geometry in my code, see attached file.

osgearth_viewer_linesymbol.zip

If I put the following code to the osgearth_annotation application everything works.

utahStyle.getOrCreate<osgEarth::PolygonSymbol>()->outline() = true;
utahStyle.getOrCreate<osgEarth::LineSymbol>()->stroke()->color() = osgEarth::Color("#FF00FF");
utahStyle.getOrCreate<osgEarth::LineSymbol>()->stroke()->width() = 10.0;
utahStyle.getOrCreate<osgEarth::LineSymbol>()->stroke()->lineCap() = osgEarth::Stroke::LINECAP_FLAT;
utahStyle.getOrCreate<osgEarth::LineSymbol>()->stroke()->lineJoin() = osgEarth::Stroke::LINEJOIN_MITRE;
utahStyle.getOrCreate<osgEarth::RenderSymbol>()->transparent() = true;
utahStyle.getOrCreate<osgEarth::RenderSymbol>()->depthTest() = true;
utahStyle.getOrCreate<osgEarth::RenderSymbol>()->lighting() = false; // we do not want light on symbols
utahStyle.getOrCreate<osgEarth::RenderSymbol>()->backfaceCulling() = false;

I think there is something strange in how I create my GraphicContext.

gwaldron commented 10 months ago

You didn't say what the problem is, but maybe this will help: https://docs.osgearth.org/en/latest/faq.html#lines-or-annotations-do-not-render

devil-darkside commented 10 months ago

The problem is that the LineSymbol is not rendered. I think your comment is what I need. I'll try it.

devil-darkside commented 10 months ago

GLUtils::setGlobalDefaults(camera->getOrCreateStateSet()) does not have any effect. I cannot see the outline of the Utah polygon. I've tried it with camera and with the area group.

devil-darkside commented 10 months ago

I've tried again and I get always the same result. I tried also running ShaderGenerator on my node. I would like to render the stroke of the polygon, but if I create a graphic context by myself (Composite Viewer) there is no way to make it working. It only works if I use the "Standard Viewer".

utah_polygon_stroke

devil-darkside commented 10 months ago

I've found the issue. It is not the graphic context but that the annotation group was not added under a Map node with MapNode::get(root)->addChild(myArea); but simply with root->addChild(myArea); So the annotation group was not direclty under a Map node. There are still some render issues with lights but I do not need light to have effect on some node yet.

gwaldron commented 10 months ago

Ah, OK. Yes, annotations do need to under the MapNode in order to correctly inherit information about the SRS and also some viewport/camera information the MapNode makes available to shaders.

As for lighting - without looking at your code again - make sure your MapNode is a child of your SkyNode.