osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

ShaderGenerator don't work model loaded black without texturing

Open mingweiLIU opened this issue 3 months ago • 5 comments

Hi, I am loading a osgb file with osgearth, I used osgEarth::Registry::shaderGenerator().run() to generate shader the node needed, while it turned out to be black, the code is: `

    osgEarth::initialize();
osgViewer::Viewer* viewer = new osgViewer::Viewer();
osg::ref_ptr<osgEarth::Map> map = new osgEarth::Map();

osgEarth::MapNode* mapNode = new osgEarth::MapNode(map.get());

osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("Tile_+006_+008.osgb");
osgEarth::Registry::shaderGenerator().run(node.get());

osg::ref_ptr<osgEarth::GeoTransform> xform = new osgEarth::GeoTransform;
xform->addChild(node);
xform->setPosition(osgEarth::GeoPoint(osgEarth::SpatialReference::create("EPSG:4326"),osg::Vec3(120,30,100)));
osg::ref_ptr < osgEarth::ModelLayer> oneModelLayer = new osgEarth::ModelLayer();
oneModelLayer->setName("test");
oneModelLayer->setNode(xform.get());
map->addLayer(oneModelLayer.get());
viewer->setSceneData(mapNode);`

the osgearth version is: [osgearth info] Hello, world. [osgearth info] [Capabilities] osgEarth Version: 3.5.0 build 150 [osgearth info] [Capabilities] GDAL Version: 3.8.1 [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] GL_VENDOR: NVIDIA Corporation [osgearth info] [Capabilities] GL_VERSION: 3.3.0 NVIDIA 528.24 [osgearth info] [Capabilities] GL CORE Profile: yes the output is: Snipaste_2024-03-17_23-39-17

mingweiLIU avatar Mar 17 '24 15:03 mingweiLIU

I don't see any obvious problems with your code -- are you able to post your .osgb file for us to look at?

gwaldron avatar Mar 19 '24 14:03 gwaldron

Tile_+006_+008.zip sorry for late reply, attached is the .osgb file

mingweiLIU avatar Mar 23 '24 13:03 mingweiLIU

I do not know why, but this model does not display correctly in the GL CORE profile. Try setting this environment variable and see if it works (Windows)

set OSG_GL_CONTEXT_PROFILE_MASK=2

gwaldron avatar Mar 27 '24 19:03 gwaldron

It is so strange, it works fine with osgviewer

mingweiLIU avatar Mar 30 '24 02:03 mingweiLIU

i've got a model with blue texture after running osgEarth::Registry::shaderGenerator().run() and i've noticed that if i zoom out and turn around the earth until the moon appeared, then nav to my model, the texture was normal. maybe some shaders were applied when the moon rendered. i don't know how to apply these shaders manually, do you guys have any ideas about it?

my code almost the same with you, but i added a SkyNode to the view

I used the vcpkg version osgearth this is my version infos: [osgEarth] [Capabilities] Capabilities: [osgEarth] [Capabilities] osgEarth Version: 3.4.0 build 148 [osgEarth] [Capabilities] OSG Version: 3.6.5 [osgEarth] [Capabilities] GDAL Version: 3.7.0 [osgEarth] [Capabilities] GEOS Version: 3.11.2 [osgEarth] [Capabilities] GPU Vendor: NVIDIA Corporation [osgEarth] [Capabilities] GPU Renderer: NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2 [osgEarth] [Capabilities] GL/Driver Version: 3.3.0 NVIDIA 545.92 (330) [osgEarth] [Capabilities] GL Core Profile: yes

image

image

alexhsu avatar Apr 03 '24 11:04 alexhsu