OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

obj plugin does not support diffuse and specular texture maps


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Ralf Habacker
Guest





PostPosted: Tue Sep 19, 2017 6:21 am    Post subject:
obj plugin does not support diffuse and specular texture maps
Reply with quote

Hi,

we tried to use the obj plugin in an osg based vr application for the
HTC Vive to load the steamvr controller (which is provided as .obj file)
and recognized that it is displayed with black surfaces instead of
showing the provided textures (which works for example in blender).

We found out that the osg plugin shows always black surfaces if a
material used by an obj file contains a diffuse *and* a specular texture
which could be verified with the appended test case.

Are there any hints how to solve this issue ?

Regards
Ralf






------------------
Post generated by Mail2Forum
Back to top
Chris Hanson
Guest





PostPosted: Tue Sep 19, 2017 6:51 am    Post subject:
obj plugin does not support diffuse and specular texture maps
Reply with quote

I think all that what's going on is that the loader is simply assigning the image maps (diffuse and specular) to various texture unit numbers:http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osgPlugins/obj/ReaderWriterOBJ.cpp?rev=13006#L67
http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osgPlugins/obj/ReaderWriterOBJ.cpp?rev=13006#L835



but it doesn't really set up a shader or anything special to utilize them, so the specular texture just clobbers the diffuse texture. You most likely need to write a small fragment shader to actually interpret the maps in whatever way you want.



On Mon, Sep 18, 2017 at 2:10 AM, Ralf Habacker < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

we tried to use the obj plugin in an osg based vr application for the
HTC Vive to load the steamvr controller (which is provided as .obj file)
and recognized that it is displayed with black surfaces instead of
showing the provided textures (which works for example in blender).

We found out that the osg plugin shows always black surfaces if a
material used by an obj file contains a diffuse *and* a specular texture
which could be verified with the appended test case.

Are there any hints how to solve this issue ?

Regards
Ralf




_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum
Back to top
Ralf Habacker
Guest





PostPosted: Tue Oct 17, 2017 11:04 am    Post subject:
obj plugin does not support diffuse and specular texture maps
Reply with quote

Hi Chris,

thanks for this explanation.

After looking into osg source I think this may be solvable by:

1. extend ShaderGenCache and related classes to support additional
texture maps.

2. extend the obj plugin to provide a map holding recent texture type
and unit index assignments. This map is required by the ShaderGenCache
class to be able to setup the correct texture uniforms.

3. In the obj plugin it is required to setup an event handler to support
the "toogle lighting" key 'l' which is provided by the state set
handler. On each lighting state change the osgUtil::ShaderGenVisitor
instance need to get the recent camera state set and the loaded nodes
need to accept the shaderGen visitor, which recreates or removes shader
from the related nodes.

Can someone confirm or is there a better solution ?

Ralf

Am 18.09.2017 um 21:22 schrieb Chris Hanson:
Quote:
I think all that what's going on is that the loader is simply assigning
the image maps (diffuse and specular) to various texture unit numbers:
http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osgPlugins/obj/ReaderWriterOBJ.cpp?rev=13006#L67
http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osgPlugins/obj/ReaderWriterOBJ.cpp?rev=13006#L835

but it doesn't really set up a shader or anything special to utilize
them, so the specular texture just clobbers the diffuse texture. You
most likely need to write a small fragment shader to actually interpret
the maps in whatever way you want.

On Mon, Sep 18, 2017 at 2:10 AM, Ralf Habacker <
<mailto:>> wrote:

Hi,

we tried to use the obj plugin in an osg based vr application for the
HTC Vive to load the steamvr controller (which is provided as .obj file)
and recognized that it is displayed with black surfaces instead of
showing the provided textures (which works for example in blender).

We found out that the osg plugin shows always black surfaces if a
material used by an obj file contains a diffuse *and* a specular texture
which could be verified with the appended test case.

Are there any hints how to solve this issue ?

Regards
Ralf




_______________________________________________
osg-users mailing list

<mailto:>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
<http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>




--
Chris 'Xenon' Hanson, omo sanza lettere.
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL
4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded •
Mobile • iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel
<http://facebook.com/alphapixel> (775) 623-PIXL [7495]






------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11193

PostPosted: Tue Oct 17, 2017 12:07 pm    Post subject:
obj plugin does not support diffuse and specular texture maps
Reply with quote

Hi Ralf,


osgUtil::ShaderGen will be deprecated by the shader_pipeline functionality, the ability of toggling GLSL features on and off will be possible by toggling GL style modes that map to #define's.  The shader_pipeline branch already has the abilty to toggle features on/off this way.



For the .obj plugin I think one would want to make sure loads the obj data properly and makes it possible post processing to enable shader functionality that maps what the data suggest is appropriate.  I don't think it would be appropriate to push shader functionality into the obj plugin to handle this, or for the ShaderGen itself to be worked on when it's not far away from being replaced.



Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ralf Habacker
Guest





PostPosted: Tue Oct 17, 2017 12:59 pm    Post subject:
obj plugin does not support diffuse and specular texture maps
Reply with quote

Am 17.10.2017 um 14:07 schrieb Robert Osfield:
Quote:
Hi Ralf,

osgUtil::ShaderGen will be deprecated by the shader_pipeline
functionality, the ability of toggling GLSL features on and off will be
possible by toggling GL style modes that map to #define's.
I guess they are propagated to the shader on shader compile time

Quote:
The shader_pipeline branch already has the abilty to toggle features on/off this way.
that means for example switching light on and off will effect the
related shaders immediatly or is a recompile required ?

I will give it a try - is there any abstract available for this feature
branch ?

Quote:
For the .obj plugin I think one would want to make sure loads the obj
data properly and makes it possible post processing to enable shader
functionality that maps what the data suggest is appropriate.
I assume you are refering to adding a node call back in the obj plugin,
which does the real work after loading ? It needs to get the texture
type to unit index mapping (either automatically assigned or by obj
plugin options)

Quote:
I don't think it would be appropriate to push shader functionality into the obj
plugin to handle this,
any hint where to add such stuff into the shader pipeline branch of the
osg framework?

or for the ShaderGen itself to be worked on when
Quote:
it's not far away from being replaced.
make sense

Ralf



------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11193

PostPosted: Tue Oct 17, 2017 4:07 pm    Post subject:
obj plugin does not support diffuse and specular texture maps
Reply with quote

Hi Ralf,

On 17 October 2017 at 13:58, Ralf Habacker < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
> The shader_pipeline branch already has the abilty to toggle features on/off this way.
that means for example switching light on and off will effect the
related shaders immediatly or is a recompile required ?


It has immediate effect, if the particular combination of modes/defines has never been compiled into a gl program before then a new one is compiled and linked, but this is all done automatically for you. Once all the required gl programs are created the toggle is little more than the OSG backend selecting the appropriate gl program to use.  This particular feature mimics what the fixed function pipeline does in the GL driver, internally it maps the modes you've selected to a gl program.



 
Quote:
I will give it a try - is there any abstract available for this feature
branch ?


The only docs are my discussions of the work here on the mailing list/forum, just search for shader_pipeline references.

 
Quote:
> For the .obj plugin I think one would want to make sure loads the obj
Quote:
data properly and makes it possible post processing to enable shader
functionality that maps what the data suggest is appropriate.
I assume you are refering to adding a node call back in the obj plugin,
which does the real work after loading ? It needs to get the texture
type to unit index mapping (either automatically assigned or by obj
plugin options)


Having a callback mechanism in a plugin is really awkward, it forces you to push the interface to the callback into osgDB, assign this to an osgDB::Options that you pass into the readNodeFile() call and then having the plugin check for this and call it.  Given the OSG has a large number of plugins if you start doing using this approach you open the door to an ever messy API and implementation.


The plugins are decoupled from the core OSG to keep things extensible.



The right way to handle things to load the data and post process if required.  If you want you don't want to explicitly invoke the post processing then you can use a osgDB::ReadFileCallback to catch all attempts to read files and then post process them as you wish.



 
Quote:

Quote:
I don't think it would be appropriate to push shader functionality into the obj
plugin to handle this,
any hint where to add such stuff into the shader pipeline branch of the
osg framework?

or for the ShaderGen itself to be worked on when
Quote:
it's not far away from being replaced.
make sense


As a short term solution I would suggest just writing a shader yourself for these problem .obj files, this would be the quickest way to get things working at your end.  You could leverage #pragma(tic) shader composition to help toggle on/on off features, but you'll need an even handler that toggles the StateSet::setDefine()'s rather than leverage the StateSet::setMode(..) functionality.



With the shader_pipeline work one would need to have a top level shader that is able to handle the diffuse and specular texture maps in an appropriate way.  The current top level shader I've worked on so far is OpenSceneGraph-Data/shaders/shaderpipeline.vert and shaderpipeline.frag, this is just early days though, but might give you an idea where this functionality is going and how one might add support for different texturing and lighting approaches.



With ShaderGen it's there as stop gap to generate some shaders for a subset of the fixed function pipeline that is common in a subset of the OSG loaders. It is just a means of getting "something" on the screen on platforms like GL core profile and GLESL 2+, it's not an all purpose fully functioning solution.



Robert.

 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Make ObjOptionsStruct in obj plugin a... Ralf Habacker Submission 1 Fri Oct 20, 2017 8:31 am View latest post
No new posts Problem With Osg Texture Colors! Bobykhani General [forum] 1 Tue Oct 10, 2017 8:20 am View latest post
No new posts Multiple video textures using ffmpeg ... mmaurus Plugins [osgPlugins] 6 Thu Oct 05, 2017 10:02 am View latest post
No new posts LIDAR plugin Michael W. Hall General 11 Fri Sep 01, 2017 1:49 am View latest post
No new posts PLY Plugin robertosfield Submission 0 Tue Aug 15, 2017 2:45 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP