gwaldron / osgearth

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

GL3 built has problems with loading 3DModels and osg particle system #2046

Closed nebsar closed 2 years ago

nebsar commented 2 years ago

When I try to load 3D models such as .obj, 3ds, and when I use particle system, I get the following warning repeatedly:

Warning: PolygonMode::apply(State&) - only GL_FRONT_AND_BACK is supported.

Is this because GL3 build does not support materials and other stuff? What can be the solution to this?

gwaldron commented 2 years ago

Try using the osgEarth ShaderGenerator when you load external models. You can either run it manually with

ShaderGenerator gen;
gen->apply(node);

or you can use the pseudo-loader extension:

osgDB::readRefNodeNode("mymodel.osg.osgearth_shadergen");

Unfortunately, some of OpenSceneGraph's fixed-function attributes will dump messages to the console when FFP is not supported, and you cannot turn them off with disabling all console output or by modifying OSG directly.

I don't know much about OSG's particle system but unless it's shader-based it likely will not work with osgEarth without some adaptation.

nebsar commented 2 years ago

I applied the recommended method, but it did not work. As follows: osg::ref_ptr model3d = osgDB::readRefNodeFile("model.obj"); ShaderGenerator gen; gen.apply(*model3d);

gwaldron commented 2 years ago

Please explain "did not work."

nebsar commented 2 years ago

Same messages are still dumped

nebsar commented 2 years ago

I also tried : osgEarth::Registry::shaderGenerator().run(model3d); But same result.

gwaldron commented 2 years ago

Read the docs on PolygonMode.

Must be GL_FRONT_AND_BACK for front- and back-facing polygons.

nebsar commented 2 years ago

Ok, I am sorry. Now it worked. I was using outline for the model. And that was causing the message dump. When I removed the outline it started working.

nebsar commented 2 years ago

Ok never mind. I am still trying to learn. I read the document you shared and adjusted the code. I have my outline again. Most probably, if do the same modification for the particle system, it will work. Thanks Glenn.

gwaldron commented 2 years ago

Glad you got it working :)

nebsar commented 2 years ago

By the way, I rebuilt the OSG removing the codes that includes materials from the Particle System. Then I used osgEarth's shader generator. Particle system worked well and no dumped messages to console from OSG. Here is the image.

image

gwaldron commented 2 years ago

amazing!