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 

hardware instancing with VertexAttribs and VertexAttribsDivisor

Goto page Previous  1, 2
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 794

PostPosted: Mon Dec 01, 2014 8:32 am    Post subject:
hardware instancing with VertexAttribs and VertexAttribsDivisor
Reply with quote

Hi Nick,

One way to improve this is to place your "root" somewhere near the center of your instanced geometry and subtract the center from your instances positions.
This way the coordinates to be multiplied stay small in relation (as the big precision loss due to View*Model is done on the CPU side (during cull) instead of multiplying big coordinates one the GPU with the inverse.
So decorate your CustomGeometry subgraph with a transform and modify your instances position accordingly.

Quote:
Hi Community,

me again on this. I have it working, however, it looks really bad when using large coordinates (when placed on UTM or Geocentric). The model is somewhat distorted due to precission issues. I know how to avoid this, like working with double matrices, but when I pass double matrix on the vertex shader it kills the performance - from 60Fps to ~1 fps. Bellow is the vertex shader. Any hints?


Thanks a bunch as always


#version 150 compatibility


uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat3 osg_NormalMatrix;
uniform vec3 lightDirection;


in vec3 vPosition;
in vec3 vNormal;
in vec2 vTexCoord;
in mat4 vInstanceModelMatrix;


smooth out vec2 texCoord;
smooth out vec3 normal;
smooth out vec3 lightDir;


void main()
{
gl_Position = /*osg_ModelViewProjectionMatrix*/ gl_ModelViewProjectionMatrix * vInstanceModelMatrix * vec4(vPosition, 1.0);
texCoord = vTexCoord;


mat3 instanceNormalMatrix = mat3(vInstanceModelMatrix[0][0], vInstanceModelMatrix[0][1], vInstanceModelMatrix[0][2],
vInstanceModelMatrix[1][0], vInstanceModelMatrix[1][1], vInstanceModelMatrix[1][2],
vInstanceModelMatrix[2][0], vInstanceModelMatrix[2][1], vInstanceModelMatrix[2][2]);


normal = osg_NormalMatrix * instanceNormalMatrix * vNormal;
lightDir = lightDirection;
}



On Tue, Nov 25, 2014 at 12:06 PM, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi All,

On 24 November 2014 at 09:28, Sebastian Messerschmidt < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
The example I was looking for was in the submissions, called:

New example : culling and LODing performed on GPU side

Unfortunately Robert didn't approve or merge the nescessary changes. Maybe it went unnoticed.




I am still progressing through the submissions backlog and am delighted to say that this wee gem of an example is now checked into svn/trunk - look for osggpucull. I haven't had a chance to spend the time understanding it yet, but the code is there.

Robert.






_______________________________________________
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





--
trajce nikolov nick




Quote:
_______________________________________________
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
Trajce Nikolov NICK
Guest





PostPosted: Mon Dec 01, 2014 8:50 am    Post subject:
hardware instancing with VertexAttribs and VertexAttribsDivisor
Reply with quote

Thanks Sebastian.I could of thought of this. Let me give  it a shot. Thanks again!

Nick


On Mon, Dec 1, 2014 at 9:26 AM, Sebastian Messerschmidt < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi Nick,

One way to improve this is to place your "root" somewhere near the center of your instanced geometry and subtract the center from your instances positions.
This way the coordinates to be multiplied stay small in relation (as the big precision loss due to View*Model is done on the CPU side (during cull) instead of multiplying big coordinates one the GPU with the inverse.
So decorate your CustomGeometry subgraph with a transform and modify your instances position accordingly.

Quote:
Hi Community,

me again on this. I have it working, however, it looks really bad when using large coordinates (when placed on UTM or Geocentric). The model is somewhat distorted due to precission issues. I know how to avoid this, like working with double matrices, but when I pass double matrix on the vertex shader it kills the performance - from 60Fps to ~1 fps. Bellow is the vertex shader. Any hints?


Thanks a bunch as always


#version 150 compatibility


uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat3 osg_NormalMatrix;
uniform vec3 lightDirection;


in vec3 vPosition;
in vec3 vNormal;
in vec2 vTexCoord;
in mat4 vInstanceModelMatrix;


smooth out vec2 texCoord;
smooth out vec3 normal;
smooth out vec3 lightDir;


void main()
{
gl_Position = /*osg_ModelViewProjectionMatrix*/ gl_ModelViewProjectionMatrix * vInstanceModelMatrix * vec4(vPosition, 1.0);
texCoord = vTexCoord;


mat3 instanceNormalMatrix = mat3(vInstanceModelMatrix[0][0], vInstanceModelMatrix[0][1], vInstanceModelMatrix[0][2],
vInstanceModelMatrix[1][0], vInstanceModelMatrix[1][1], vInstanceModelMatrix[1][2],
vInstanceModelMatrix[2][0], vInstanceModelMatrix[2][1], vInstanceModelMatrix[2][2]);


normal = osg_NormalMatrix * instanceNormalMatrix * vNormal;
lightDir = lightDirection;
}



On Tue, Nov 25, 2014 at 12:06 PM, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi All,

On 24 November 2014 at 09:28, Sebastian Messerschmidt < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
The example I was looking for was in the submissions, called:

New example : culling and LODing performed on GPU side

Unfortunately Robert didn't approve or merge the nescessary changes. Maybe it went unnoticed.




I am still progressing through the submissions backlog and am delighted to say that this wee gem of an example is now checked into svn/trunk - look for osggpucull.  I haven't had a chance to spend the time understanding it yet, but the code is there.

Robert.

 




_______________________________________________
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





--
trajce nikolov nick




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





--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
Trajce Nikolov NICK
Guest





PostPosted: Mon Dec 01, 2014 9:02 am    Post subject:
hardware instancing with VertexAttribs and VertexAttribsDivisor
Reply with quote

Yeah, work well now. Thanks !!!

Nick


On Mon, Dec 1, 2014 at 9:45 AM, Trajce Nikolov NICK < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Thanks Sebastian.I could of thought of this. Let me give  it a shot. Thanks again!

Nick


On Mon, Dec 1, 2014 at 9:26 AM, Sebastian Messerschmidt < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi Nick,

One way to improve this is to place your "root" somewhere near the center of your instanced geometry and subtract the center from your instances positions.
This way the coordinates to be multiplied stay small in relation (as the big precision loss due to View*Model is done on the CPU side (during cull) instead of multiplying big coordinates one the GPU with the inverse.
So decorate your CustomGeometry subgraph with a transform and modify your instances position accordingly.

Quote:
Hi Community,

me again on this. I have it working, however, it looks really bad when using large coordinates (when placed on UTM or Geocentric). The model is somewhat distorted due to precission issues. I know how to avoid this, like working with double matrices, but when I pass double matrix on the vertex shader it kills the performance - from 60Fps to ~1 fps. Bellow is the vertex shader. Any hints?


Thanks a bunch as always


#version 150 compatibility


uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat3 osg_NormalMatrix;
uniform vec3 lightDirection;


in vec3 vPosition;
in vec3 vNormal;
in vec2 vTexCoord;
in mat4 vInstanceModelMatrix;


smooth out vec2 texCoord;
smooth out vec3 normal;
smooth out vec3 lightDir;


void main()
{
gl_Position = /*osg_ModelViewProjectionMatrix*/ gl_ModelViewProjectionMatrix * vInstanceModelMatrix * vec4(vPosition, 1.0);
texCoord = vTexCoord;


mat3 instanceNormalMatrix = mat3(vInstanceModelMatrix[0][0], vInstanceModelMatrix[0][1], vInstanceModelMatrix[0][2],
vInstanceModelMatrix[1][0], vInstanceModelMatrix[1][1], vInstanceModelMatrix[1][2],
vInstanceModelMatrix[2][0], vInstanceModelMatrix[2][1], vInstanceModelMatrix[2][2]);


normal = osg_NormalMatrix * instanceNormalMatrix * vNormal;
lightDir = lightDirection;
}



On Tue, Nov 25, 2014 at 12:06 PM, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi All,

On 24 November 2014 at 09:28, Sebastian Messerschmidt < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
The example I was looking for was in the submissions, called:

New example : culling and LODing performed on GPU side

Unfortunately Robert didn't approve or merge the nescessary changes. Maybe it went unnoticed.




I am still progressing through the submissions backlog and am delighted to say that this wee gem of an example is now checked into svn/trunk - look for osggpucull.  I haven't had a chance to spend the time understanding it yet, but the code is there.

Robert.

 




_______________________________________________
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





--
trajce nikolov nick




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





--
trajce nikolov nick








--
trajce nikolov nick

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


Joined: 25 Jul 2017
Posts: 1

PostPosted: Tue Jul 25, 2017 9:10 am    Post subject:
Re: hardware instancing with VertexAttribs and VertexAttribsDivisor
Reply with quote

Trajce Nikolov NICK wrote:
Hi Roman,
Once I complete some working version I will post my code, no problem. Maybe Sebastian can provide some snips from his NodeVisitor as well Wink

Nick


Hi,
I know I am bringing this topic back to life but I am stuck for a very similar problem.

Where can I find the code Nick developed?
I am having tons of problems with instancing and custom attributes
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Fri Jul 28, 2017 9:33 am    Post subject:
hardware instancing with VertexAttribs and VertexAttribsDivisor
Reply with quote

Hi Dario,


my work supposed to be part of an opensource project but the development has ended without a chance to implement this.


Have a look here,
http://3dcgtutorials.blogspot.mk/2013/09/instancing-with-openscenegraph-part-ii.html


Also, instead of using OpenGL code for the VertexAttribsDivisor Robert added (If I remember correctly) OSG wraps for it.


Hope this helps,


Cheers!
Nick




On Tue, Jul 25, 2017 at 11:10 AM, Dario Frost < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Trajce Nikolov NICK wrote:
Quote:
Hi Roman,
Once I complete some working version I will post my code, no problem. Maybe Sebastian can provide some snips from his NodeVisitor as well Wink

Nick



Hi,
I know I am bringing this topic back to life but I am stuck for a very similar problem.

Where can I find the code Nick developed?
I am having tons of problems with instancing and custom attributes

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





_______________________________________________
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



--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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 Tearing hair out over simple GLSL ins... loopy General 7 Thu Dec 22, 2016 5:17 pm View latest post
No new posts little bug in DrawArraysLength (insta... mp3butcher Submission 1 Fri Jun 03, 2016 1:07 pm View latest post
No new posts Verify hardware instancing capabilities mateas General 1 Fri Sep 04, 2015 3:09 pm View latest post
No new posts force vsync to false (sofware not har... Christian Schulte General 7 Mon Jul 06, 2015 8:06 am View latest post
No new posts OS X (10.9) Texture2D with hardware c... LEgregius General 8 Thu May 28, 2015 1:52 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