gwaldron / osgearth

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

Draping: using depth-offset with draping causes artifacts #2473

Closed YHLpuyu closed 4 months ago

YHLpuyu commented 6 months ago

When drawing a polygon, and set CLAMP_TO_TERRAIN, TECHNIQUE_DRAPE, the polygon is not absolutly clamp to terrain. I use the newest version of osgearth. When look around, the polygon has offset relavite to terrain.

Polygon* geom = new Polygon();
// put some coords

Style polyStyle;
PolygonSymbol* poly = polyStyle.getOrCreate<PolygonSymbol>();
poly->fill()->color() = Color(Color::Yellow, 0.4);
LineSymbol* line = polyStyle.getOrCreate<LineSymbol>();
line->stroke()->color() = Color::White;
line->stroke()->width() = 2;
AltitudeSymbol* alt = polyStyle.getOrCreate<AltitudeSymbol>();
alt->clamping() = alt->CLAMP_TO_TERRAIN;
alt->technique() = alt->TECHNIQUE_DRAPE;
RenderSymbol* rs = polyStyle.getOrCreate<RenderSymbol>();
rs->depthOffset()->enabled() = true;

Feature* f = new Feature(geom, _mapNode->getMapSRS());
_fn = new FeatureNode(f, polyStyle);
_fn->setMapNode(_mapNode);
_mapNode->addChild(_fn);

clamp

YHLpuyu commented 6 months ago

the boundary is moving when camera moving. Is there some option, that I don't set?

YHLpuyu commented 6 months ago

if set depthoffset to false, it looks normal

gwaldron commented 5 months ago

Draping uses projective texturing to draw the geometry on the terrain. I'm surprised that depth offsetting affects it; we will re-open this ticket and take a look. Thanks for finding this. (Depth offsetting only applies to "real" geometry (not draped) and therefore should have no effect when draping.)