[osg-users] importing shaders

Robert Osfield robert.osfield at gmail.com
Tue Mar 10 02:03:49 PDT 2009

Hi Julia,

On Tue, Mar 10, 2009 at 4:35 AM, Julia Guo <osgforum at tevs.eu> wrote:
> I have a model made in 3DS with textures and shaders and I would like to use it within OSG. When I try displaying it with osgviewer.exe the textures are rendered but not the shaders.
> I know shaders are algorithms, so perhaps they are not exported with the model.
> Or 3DS may be using a DirectX shader while OSG is OpenGL based.
> Am I on the right track??

How are you loading the models?  If you are loading them via .3ds then
you certainly won't get any shaders as the .3ds format pre-dates any
such functionality.  You'll certainly needs to the use the OSGExp
plugin to 3D Studio.  The status of shaders with this plugin I'm
unsure about though as I've never used it personally.

> Is there a way to design models with shaders and import them into OSG?
> Or do I need to manually attach my shaders with osg::Shader (which would make models harder to design)?

As Guy mentioned the .osg format does support shaders, and being an
ascii format it's possible to edit it by hand.  Not ideal.  You can
also store the shaders in staight ascii files and load this into
osg::Shader.  See the osgshaders example.  osgVolume also make uses of
locally defined as well as ones sourced from

> (P.S. - in learning OSG I found the examples extremely useful, but I feel many have been over engineered so that they obscure their purpose. For instance many of the examples have a flag to use a Composite Viewer instead of the default Viewer. I think it would be ideal for beginners if the examples were stripped down to focus on their core functionality.)

Out of 133 examples I can only find 6 that use CompositeViewer at all,
and 2 of this specifically demonstrate the CompositeViewer, and the
others demonstrate windows integration that applies to both Viewer and
CompositeViewer save for the osgpick example that has the two options
to show the commonality between the two classes w.r.t picking.

So.. if you think many of the examples have both the CompositeViewer
and Viewer and this complicates things then please recalibrate your
perception by looking at the 127 other examples that do just stick to
Viewer and generally keep the viewer code to it's bare minimum, often
just three lines of code.


More information about the osg-users mailing list