The shader needs to receive a sampler uniform containing the integer value
of a texture unit to use.

The right way to do this would be to scan the subgraph of the model for
state sets containing enabled texture units. Use a node visitor here. For
each of these texture units, create a uniform value containing the texture
unit and attach it to the model's state.

It might be a bit of a pain to write a shader for all kinds of different
textures and multitexturing modes though. There is a tool that might be
able to assist you here. So far this isn't integrated into OSG.

ShaderGen

https://github.com/mojocorp/ShaderGen

Christian



2015-01-27 13:50 GMT+01:00 Chris Hidden <ch...@erghis.com>:

> Ok so now back to the original intent with this question.
>
> So I can now attach a texture to my hand model with a vertex and fragment
> shader, which is great!  I load the texture via its file path and send it
> along to the shaders.
>
> However I was hoping to find a way to do this in a different workflow.  I
> have been and would like to continue to do a fair amount of the texture
> work in 3D Studio Max.  So when I export an FBX model and load it into the
> scene graph it under "normal" circumstances retains its embedded texture
> and displays accordingly.
>
> Is there a way I can access these textures for the FBX model, so that I
> could in some way load the texture directly from the model.
>
> So if I have
> osg::ref_ptr<osg::Node> model = osgDB::readNodeFile("myModel.fbx);
>
> Then I would like to acheive this somehow (Pseudo Code):
>
> osg::ref_ptr<osg::Texture2D> texture = model->GetEmbeddeFBXTexture();
>
> That way we could have a nice system that will take whatever our designers
> or modelers texture the model with directly through the code instead of
> having to manually switch in the code later on.
>
> Im sure this can be done one way or another.  Is there a somewhat simple
> approach to this?
> Thank you!
>
> Cheers,
> Chris
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=62492#62492
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to