Making Port Lights

classic Classic list List threaded Threaded
2 messages Options
marcoma9023 marcoma9023
Reply | Threaded
Open this post in threaded view
|

Making Port Lights

Hi,

I'm writing because the idea is to make the port light.

Then I have two solutions and I would like an opinion on which is the best for you.

1) Use the OSGSim::LightPoint,
where I'm able to create a spherical point of which I can customize a few parameters like colour, intensity, blink sequence and the sector in which you can see it.


2) Use osg::Light,

in this case I'm able to create only a light like a sun. Instead I'm studying to create a spotlight, like a lighthouse.

Furthermore, with this solution I'm not able to set correctly the altitude of the light, instead it remains as you can see, from the image, attached to the ocean.

                GeoPoint p(geosrs, 8.91732, 44.4064, 8, ALTMODE_ABSOLUTE);
                osg::Vec3d world;
                p.toWorld(world);
               
                GeoPoint p(geosrs, 8.91732, 44.4064, 8, ALTMODE_ABSOLUTE);
                //osg::Vec3d world;
                p.toWorld(world);
                //GeoPoint p(geosrs, -121, 34, 5000000., ALTMODE_ABSOLUTE);
                //p.toWorld(world);

                osg::Light* spot = new osg::Light(lightNum++);
                spot->setPosition(worldToVec4(world));
                spot->setAmbient(osg::Vec4(1, 0, 0, 1));
                spot->setDiffuse(osg::Vec4(1, 0, 0, 1));
                spot->setSpotCutoff(15);
                spot->setSpotExponent(10.0f);
                world.normalize();
                spot->setDirection(-world);

                osg::LightSource* spotLS = new osg::LightSource();
                spotLS->setLight(spot);
                spotLS->setLocalStateSetModes(osg::StateAttribute::ON);
                spotLS->setStateSetModes(*state, osg::StateAttribute::ON);
                lights->addChild(spotLS);
                root->addChild(lights);


where in the GeoPoint p the altitude  = 8.

Another aspect, there is the possibility to see the Light like in the image without the PhongLightingEffect?

Image with PhongEffect:











Image without PhongEffect:











Thanks


----
Marco
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Making Port Lights

Marco,
I'm not sure what you mean "attached to the ocean." It seems like if the altitude were zero, you would not see any light cast on the surface at all, right?

Lights in osgEarth are detected using the shader generator, and then rendered with a lighting shader. So no -- you cannot render a light without one of the lighting shaders. Phong is one, SimpleSky is the other. You can write your own lighting shaders if you prefer.
Glenn Waldron / Pelican Mapping