gwaldron / osgearth

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

ModelLayer displays osgb model shader errors in Qt5 #2583

Closed gfyrtuwcv closed 1 month ago

gfyrtuwcv commented 1 month ago

osgearth 版本 [osgearth info] Hello, world. [osgearth info] [Capabilities] osgEarth Version: 3.6.0 build 158 [osgearth info] [Capabilities] GDAL Version: 3.8.5 [osgearth info] [Capabilities] OSG Version: 3.6.5 [osgearth info] [Capabilities] OSG GL3 Features: yes [osgearth info] [Capabilities] OSG FFP Available: no [osgearth info] [Capabilities] CPU Cores: 8 [osgearth info] [Capabilities] GL_VENDOR: NVIDIA Corporation [osgearth info] [Capabilities] GL_RENDERER: Quadro K2200/PCIe/SSE2 [osgearth info] [Capabilities] GL_VERSION: 3.3.0 NVIDIA 516.94 [osgearth info] [Capabilities] GL CORE Profile: yes [osgearth info] Goodbye. Use osgqt with qt5. When I add a string of code to make sure the sky layer is displayed correctly

    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
#ifdef OSG_GL3_AVAILABLE
    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setOption(QSurfaceFormat::DebugContext);
    qDebug() << QObject::tr("OPENGL3");
#endif
    format.setDepthBufferSize(24);
    //format.setAlphaBufferSize(8);
    format.setSamples(8);
    format.setStencilBufferSize(8);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    QSurfaceFormat::setDefaultFormat(format);

add the osgb model using ModelLayer, the enlarged model displays this message: Warning: detected OpenGL error 'invalid enumerant' at after RenderBin::draw(..) and this is what the model looks like: image Even if you remove this code the model shader will not work correctly: image I added osgb model code:

ModelLayer* layer = new ModelLayer();
layer->setURL(fileurl);//+".osgearth_shadergen"
GeoPoint point(srs, longitude, latitude, 0);
layer->setLocation(point);
map->addLayer(layer);
osgEarth::Viewpoint vp("", longitude, latitude, 0.0, 0, carmer->getViewpoint().pitch()->getValue(), 50076.7);
carmer->setViewpoint(vp, 2);
 osgEarth::ShaderGenerator gen;
 gen.run(earth.get());
gfyrtuwcv commented 1 month ago

I pulled up the latest code rebuild, the ModelLayer shading error is resolved! But the black model still appears after adding the code, is there a way to make them both work correctly?

    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
#ifdef OSG_GL3_AVAILABLE
    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setOption(QSurfaceFormat::DebugContext);
    qDebug() << QObject::tr("OPENGL3");
#endif
    format.setDepthBufferSize(24);
    //format.setAlphaBufferSize(8);
    format.setSamples(8);
    format.setStencilBufferSize(8);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    QSurfaceFormat::setDefaultFormat(format);
gwaldron commented 1 month ago

I'm confused. Does your model display correctly with osgearth_imgui and an earth file? Does your problem only happen in a Qt environment?

gfyrtuwcv commented 1 month ago

Leaving the Qt environment to directly load earth files or code stars is no problem, imgui I have not tried

gwaldron commented 1 month ago

We are not Qt experts so lets hope someone else in the community can help you.

gwaldron commented 1 month ago

There is a chance this was fixed in a recent commit. Please give it another try and report back.

gfyrtuwcv commented 1 month ago

I wasted some time building osgEarthCesium by using the wrong Cesion-main, but successfully built with 37.0 under release. The ModelLayer texture loaded smoothly, this issue has been fixed!