[osg-users] [osgOcean] 3D model material display error!

Kim Bale kcbale at googlemail.com
Mon Nov 2 06:12:35 PST 2009


Hi MT,

For the reasons I just gave, you can't add objects to the scene and
have the full compliment of effects without either using the default
shader or using your own shader implementation.

Reflections/refractions etc will continue to work since they act on
the ocean surface and not the model. However, other such as glare,
depth of field, light scattering, fogging etc will not as they act on
the models themselves.

However, it is pretty straight forward to duplicate a subset of fixed
pipeline functionality within a shader and then add the relevant
osgOcean shader effects to it, you can just copy functions from the
default shader and mix them in with the result of your shader.

K.


2009/11/2 Tian Ma <tianxiao888 at foxmail.com>:
> Hi Jan,Kim:
>
> Thank you a lot.
>
>     Kim, does it means that: I can never keep the models looks like what they are before? And I have to program shaders for every loaded models, in order to have reflect or other effects?
>
>     I want to know that: is there a simple way to make the models just look like what they are?
>
>
>
> Kim Bale wrote:
>> 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
>> in OceanScene:
>>
>> /** 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.
>>
>> Regards,
>>
>> Kim.
>>
>>
>>
>>
>>
>>
>> 2009/11/2 Jan Ciger <>:
>>
>> > "Tian Ma" <> wrote:
>> >
>> > > Hi,
>> > >
>> > >    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.
>> >
>> > Regards,
>> >
>> > Jan
>> >
>> > _______________________________________________
>> > osg-users mailing list
>> >
>> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >
>> >
>> >
>> _______________________________________________
>> osg-users mailing list
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>  ------------------
>> Post generated by Mail2Forum
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=19021#19021
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


More information about the osg-users mailing list