[osg-users] [osgOcean] 3D model material display error!
kcbale at googlemail.com
Mon Nov 2 02:13:21 PST 2009
Hi Jan, Tian,
osgOcean uses shaders for pretty much every effect in the scene -
fogging, depth of field, glare, lighting etc. If objects that are
added to the scene are to look consistent with the ocean effects they
will require a shader to be applied that takes into account these
effects. This is particularly necessary if the fullscreen effects are
used as they require the alpha component of the frame buffer to work.
In order to address this issue, OceanScene will apply a default shader
to objects added as children (default_scene.frag & vert) which
illustrates how to use the uniforms supplied by osgocean (prefixed
osgOcean_* ) in conjunction with your own shader. Since I could not
anticipate the many wierd and wonderful ways that shaders can be used
it only offers a very basic implementation (1 texture unit, limited
phong lighting etc) and should be seen as a shader to customise and
build on yourself.
You can override the default shader either by attaching a new program
to the object you wish to use in the scene or by using this function
/** Override the default scene shader for custom shaders.
* If custom shaders are required for individual nodes add them
before adding to the OceanScene.
* Dirties state.
void setDefaultSceneShader( osg::Program* program )
_defaultSceneShader = program;
_isDirty = true;
Alternatively you can turn the default shader off completely with
setter in OceanScene.
2009/11/2 Jan Ciger <jan.ciger at gmail.com>:
> "Tian Ma" <tianxiao888 at foxmail.com> wrote:
>> When I load a model into the osgOcean scene, the model looks white all
>> over, without any material. Anybody knows why?
> Yes, I have seen the same thing. I believe that the shaders applied by
> osgOcean are responsible and are not passing the the vertex colors along.
> I have yet to check the shader code, though.
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users