[osg-users] GLSL for non-rendering operation

2011-03-22 Thread Simon Kolciter
Hi, I have a model the geometry of which is being modified in real time and therefore, the PER_VERTEX normal vectors have to be updated as well. The modification of normals takes too much computing force, so I thought of pushing the computation onto the GPU. My question: Is it possible to use

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Peter Hrenka
Hi Simon, Am 22.03.2011 16:58, schrieb Simon Kolciter: > Hi, > > I have a model the geometry of which is being modified in real time and > therefore, the PER_VERTEX normal vectors have to be updated as well. > > The modification of normals takes too much computing force, so I thought of > push

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Chris 'Xenon' Hanson
On 3/22/2011 9:58 AM, Simon Kolciter wrote: > 1. Push the list of vertices and primitive indices to the GPU. > 2. Call GLSL function. Fine so far. > 3. Pull the resulting list of normals from the GPU. Good lord, why? You're going to USE them on-GPU aren't you? Pulling them back across the b

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Chris 'Xenon' Hanson
On 3/22/2011 10:27 AM, Peter Hrenka wrote: > You could use a geometry shader to calculate > the normals on the GPU. The geometry shader > basically "sees" the whole primitive and can > can therefore perform the normal calculation > of a deforming geometry. I have been told by some hardware engin

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Peter Hrenka
Hi Chris, Am 22.03.2011 17:34, schrieb Chris 'Xenon' Hanson: > On 3/22/2011 10:27 AM, Peter Hrenka wrote: >> You could use a geometry shader to calculate >> the normals on the GPU. The geometry shader >> basically "sees" the whole primitive and can >> can therefore perform the normal calculation >

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Jason Daly
On 03/22/2011 12:31 PM, Chris 'Xenon' Hanson wrote: You should be able to do what you're looking for on-GPU. There are some cache and read/write issues when you need to write to a data store and then immediately read it back and use it for drawing. Others can comment on that. I haven't do

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Simon Kolciter
Well, the problem is that the normal vertices are PER_VERTEX, not PER_PRIMITIVE. In Geometry shader, I only have access to the current primitive, not the whole mesh, right? I need to 1. calculate the normal vector of each face (triangle) and add it to the normal vectors of all 3 vertices 2. n

Re: [osg-users] GLSL for non-rendering operation

2011-03-22 Thread Chris 'Xenon' Hanson
On 3/22/2011 9:12 PM, Simon Kolciter wrote: > Well, the problem is that the normal vertices are PER_VERTEX, not > PER_PRIMITIVE. > In Geometry shader, I only have access to the current primitive, not the > whole mesh, right? Correct. > I need to > 1. calculate the normal vector of each face (

Re: [osg-users] GLSL for non-rendering operation

2011-03-23 Thread Peter Hrenka
Hi Simon, Am 23.03.2011 04:12, schrieb Simon Kolciter: > Well, the problem is that the normal vertices are PER_VERTEX, not > PER_PRIMITIVE. > > In Geometry shader, I only have access to the current primitive, not the > whole mesh, right? In principle, you are right, the geometry shader can onl

Re: [osg-users] GLSL for non-rendering operation

2011-03-23 Thread Simon Kolciter
Ok, no access to the whole geometry in geometry shader. However, since you can access to gl_Position of every vertex for a given primitive, can't you also access gl_Normal of these vertices? Because that would actually suffice. -- Read this topic online here: http://forum.opensc

Re: [osg-users] GLSL for non-rendering operation

2011-03-23 Thread Chris 'Xenon' Hanson
On 3/23/2011 1:37 PM, Simon Kolciter wrote: > Ok, no access to the whole geometry in geometry shader. > However, since you can access to gl_Position of every vertex for a given > primitive, can't you also access gl_Normal of these vertices? Yes, I believe so. > Because that would actually suff

Re: [osg-users] GLSL for non-rendering operation

2011-03-23 Thread Jason Daly
On 3/23/2011 3:37 PM, Simon Kolciter wrote: Ok, no access to the whole geometry in geometry shader. However, since you can access to gl_Position of every vertex for a given primitive, can't you also access gl_Normal of these vertices? Accessing gl_Normal only makes sense if you've provide

Re: [osg-users] GLSL for non-rendering operation

2011-03-23 Thread Simon Kolciter
Jason Daly: What if I assign a normal array to the OSG Geometry (setNormalArray) and only modify the values in geometry shader? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37851#37851 ___ osg-use

Re: [osg-users] GLSL for non-rendering operation

2011-03-24 Thread Sergey Polischuk
Hi, Simon That dont make any difference. Why you want to do this? If you are going to calculate normals in shader for just rendering - it would not make any difference, because you not use values assigned in osg, just more overhead and slower render. If you want to get calculated normals back t