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 

passing material properties to shader uniforms


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum]
View previous topic :: View next topic  
Author Message
gpantar
Newbie


Joined: 15 May 2017
Posts: 2

PostPosted: Mon May 15, 2017 1:17 pm    Post subject:
passing material properties to shader uniforms
Reply with quote

Hi,

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.


As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.


I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

Thank you!

Cheers,
Goran
Back to top
View user's profile Send private message
gpantar
Newbie


Joined: 15 May 2017
Posts: 2

PostPosted: Thu Jun 01, 2017 9:43 am    Post subject:
passing material properties to shader uniforms
Reply with quote

Hi,

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.


As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.


I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

Thank you!

Cheers,
Goran

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70931#70931







------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11021

PostPosted: Thu Jun 01, 2017 2:17 pm    Post subject:
passing material properties to shader uniforms
Reply with quote

Hi Goran,

In standard OSG (3.2.x, 3.4.0 or the 3.5.x dev series) there isn't any
way to automatically remap osg::Material to uniforms so you'll have to
run a traverser through the scene graph and replace the osg::Material
to osg::Uniform's.

If you are willing to experiment with bleeding edge experimental code
then have a look at the shader_pipeline branch of the OSG, in this
branch I'm working on a new scheme for automatically mapping old fixed
function state like osg::Material to uniforms and #define settings
that can then be used by #pragma(tic) shader composition to provide a
fully integrated shader+fixed function state solution.

Robert.

On 15 May 2017 at 14:18, Goran Pantar <> wrote:
Quote:
Hi,

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.


As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.


I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

Thank you!

Cheers,
Goran

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70931#70931








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





PostPosted: Sun Jun 04, 2017 1:37 am    Post subject:
passing material properties to shader uniforms
Reply with quote

For OpenGL 3.2, I've taken the approach of using an uniform block to replace the materials, (if you think about this materials are currently treated as something that is shared between all shaders, which is how they are implemented in the fixed function pipeline) each material has a buffer on the GPU, and I just switch the uniform block pointer as part of the material apply. I found using callbacks really slowed down the scene graph update as the scene got larger. And there were also a number of bugs I hit by using material uniforms where scene graph optimizations seemed to lose them.

-Gedalia


On Thu, Jun 1, 2017 at 10:12 AM, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi Goran,

In standard OSG (3.2.x, 3.4.0 or the 3.5.x dev series) there isn't any
way to automatically remap osg::Material to uniforms so you'll have to
run a traverser through the scene graph and replace the osg::Material
to osg::Uniform's.

If you are willing to experiment with bleeding edge experimental code
then have a look at the shader_pipeline branch of the OSG, in this
branch I'm working on a new scheme for automatically mapping old fixed
function state like osg::Material to uniforms and #define settings
that can then be used by #pragma(tic) shader composition to provide a
fully integrated shader+fixed function state solution.

Robert.

On 15 May 2017 at 14:18, Goran Pantar < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

I'm using OpenGL ES 2.0 and having dificulties to pass the old style material properties (ambient, difusse, specular, shininess) to the uniforms used in my fragment shader.

For the 3d model I use models in 3ds format with multiple materials and multiple drawables.


As a dirty hack I changed the Material.cpp Material::apply(State&) function. This worked properly and I was able to modify this several global uniforms used by my shader.

Now I'm trying to do this the OSG way using updateCallbacks and visitors but the uniform are not updated during the rendering. Probably only the last drawable material properties are set to the uniform and than this is used when rendering.


I expect that there is some perfectly elegant way to do this, so please point me in the right direction.

Thank you!

Cheers,
Goran

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70931#70931





_______________________________________________
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
_______________________________________________
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






--
DI-Guy Engineering Lead, VT MÄK
150 Cambridge Park Drive, 3rd Floor, Cambridge, MA 02140

------------------
Post generated by Mail2Forum
Back to top
uwew
Newbie


Joined: 05 Feb 2014
Posts: 5

PostPosted: Tue Aug 01, 2017 2:25 pm    Post subject:
passing material properties to shader uniforms
Reply with quote

Hi Robert,

I am currently trying to port a fixed function pipeline application to the Hololens and thus to GLES
I followed your advice and tried the shader_pipeline branch but I don't see where and how osgMaterial state or Light source information is passed to the shader. Is that still in development or was I too stupid to find it?
Is there any documentation on how the compositing should work?


Regards,
Uwe
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11021

PostPosted: Tue Aug 01, 2017 5:07 pm    Post subject:
passing material properties to shader uniforms
Reply with quote

Hi Ewe,

I an away on a trip so not in a position to dive into the code and see what would be appropriate. I will back at the end of the week.


Robert 


On 1 Aug 2017 3:24 p.m., "Uwe Woessner" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi Robert,

I am currently trying to port a fixed function pipeline application to the Hololens and thus to GLES
I followed your advice and tried the shader_pipeline branch but I don't see where and how osgMaterial state or Light source information is passed to the shader. Is that still in development or was I too stupid to find it?
Is there any documentation on how the compositing should work?


Regards,
Uwe

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71356#71356





_______________________________________________
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


------------------
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 [forum] 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 setAttribute / Material issue Valzul General 1 Wed Aug 16, 2017 8:15 am View latest post
No new posts draw primitive sets and geometry shad... wernerM General 0 Wed May 24, 2017 3:20 pm View latest post
No new posts Scale problem while transforming obje... YuraIU02 General 1 Sat Apr 15, 2017 4:26 pm View latest post
No new posts shader 崔 献军 General 1 Fri Apr 07, 2017 1:55 am View latest post
No new posts Merge Shader::Program from differents... Paradox General 1 Tue Feb 28, 2017 3:53 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