Thanks again, it looks like I need to get up to speed with using "in" and "out" 
vs attribute and varying since I cut my teeth on older tutorials and apparently 
attribute and varying are officially deprecated and are supported through 
compatibility mode.  I'm not used to needing historical context and having so 
many deprecated variables and different extensions to worry about like with 
GLSL.  GLSL-land is a bit of a wild place to be!

-Ethan


SMesserschmidt wrote:
> Hi Ethan
> 
> > Thanks Sebastian,
> > 
> > I have in fact looked through every geometry shader tutorial I could find 
> > and have tried to implement a simple pass-through sahder identical to the 
> > one you posted, but when I add the geometry shader I just get a black 
> > screen with no OpenGL error messages, and if I remove the geometry shader 
> > and keep the vertex and frag shaders I get my normal scene.   I'm not sure 
> > if maybe I'm missing passing through texture coordinates or something of 
> > that nature...?
> > 
> 
> Ok, you of course have to pass all your varyings through the geometry 
> shader. Thats the burden for using a geometry shader: you will have to 
> replicate the default funtionality.
> For example:
> Vertex shader:
> 
> out vec4 v_color;
> v_color =gl_Color;
> 
> in geometry shader:
> in vec4 v_color[];
> out vec4 g_color;
> 
> g_color = color[i]; //i = vertex number
> 
> and then finally in your fragment shader you can access:
> 
> in g_color
> 
> cheer
> Sebastian
> 
> > 
> > -Ethan
> > 
> > 
> > SMesserschmidt wrote:
> > 
> > > Hi Ethan,
> > > 
> > > 
> > > 
> > > 
> > > > Thanks, that makes sense that it would just be rendering a quad and 
> > > > that the original scene geometry would be lost.  However, the GLSL 
> > > > geometry shader only accepts primitives of the type point, line, or 
> > > > triangle->is it perhaps rendering two triangles to the geometry shader 
> > > > to make up the quad?  How would I even go about determining since 
> > > > there's no debugging available?
> > > > 
> > > > But back to what I'm trying to do, I'm trying to use a geometry shader 
> > > > to calculate the min, max, mean, std dev, and histogram of an RTT 
> > > > texture.  Fellow osg forum member Aurelius has advised me that he has 
> > > > working code that does this using geometry shaders and pointed me to:
> > > > http://http.developer.nvidia.com/GPUGems3/gpugems3_ch41.html
> > > > and
> > > > 
> > > > 
> > > This seems rather complicated for a starter. Also it requires feedback
> > > buffers which I never got working in OSG, so there might be some more
> > > obstacles here.
> > > 
> > > 
> > > > http://developer.amd.com/wordpress/media/2012/10/GPUHistogramGeneration_I3D07.pdf
> > > > but the first example only has Cg code and not GLSL, and the second 
> > > > example is a paper that describers an algorithm but doesn't have any 
> > > > src.  These are both potentially great resources, but I'm struggling to 
> > > > just get a basic pass-through geometry shader working to get some sort 
> > > > of starting point.
> > > > 
> > > > 
> > > Geometry shaders are really simple. You simply need to know your input
> > > primitives.
> > > A very basic geometry shader looks like this:
> > > 
> > > 
> > > #version 400
> > > layout(triangles) in; //we receive triangles
> > > layout(triangle_strip, max_vertices = 3) out;
> > > 
> > > void main()
> > > {
> > > for (int i = 0; i < 3; ++i)
> > > {
> > > 
> > > vertex = gl_in[i].gl_Position;
> > > gl_Position =  vertex;
> > > EmitVertex();
> > > }
> > > 
> > > EndPrimitive();
> > > }
> > > 
> > > But seriously, there are examples in OSG touching geometry shaders and
> > > there are plenty of tutorials about glsl and shaders.
> > > 
> > > cheers
> > > Sebastian
> > > 
> > > 
> > > > As a side note, I am also considering using a compute shader since this 
> > > > would be the more natual fit for this type of algorithm while the 
> > > > geometry shader method is more of a "hack" that goes against the 
> > > > original intention of the geometry shader, but I'd be happy using 
> > > > either method, I'm just trying to get some traction on either of them.
> > > > 
> > > > -Ethan
> > > > 
> > > > 
> > > > SMesserschmidt wrote:
> > > > 
> > > > 
> > > > > Am 18.11.2013 15:32, schrieb Ethan Fahy:
> > > > > 
> > > > > 
> > > > > 
> > > > > > Hello,
> > > > > > 
> > > > > > Preface: I realize this question comes about because I've never 
> > > > > > really learned OpenGL/GLSL from the ground up and am likely missing 
> > > > > > some simple concepts, but I mostly have been coasting by at the osg 
> > > > > > middleware level and have been doing OK so far.
> > > > > > 
> > > > > > If I want to do some simple post-processing I can create a 
> > > > > > render-to-texture camera and render to the framebuffer.  I can 
> > > > > > attach a texture to the framebuffer and then create another 
> > > > > > "screen" camera to render that texture to the screen.  I can add a 
> > > > > > GLSL shader program to this texture so that before the texture gets 
> > > > > > rendered to the screen it gets an effect added to it using the 
> > > > > > shaders.
> > > > > > 
> > > > > > When I use shaders attached to 3-D model nodes in the scene itself, 
> > > > > > the meaning of the vertex and frag shaders is easy to 
> > > > > > understand->the vertices of the 3-D model are the vertices 
> > > > > > referenced in the vertex shader.  However, When I render my scene 
> > > > > > to a texture and then do a simple pass-through vertex and frag 
> > > > > > shader combo, what is the meaning of the vertices in this scenario? 
> > > > > >  I had assumed that once you render your scene to a texture, all 
> > > > > > knowledge of the original scene's geometry and vertex locations has 
> > > > > > been lost, is this true?  If so, then what vertices am I dealing 
> > > > > > with?  It's easy enough to follow along with examples and to use a 
> > > > > > simple pass-through vertex shader, but I'd like to understand this 
> > > > > > better because I now want to insert a geometry shader in between 
> > > > > > the vertex and frag shaders and again I'm not sure whether to use 
> > > > > > point, line, or triangle in my geometry shader as the primitive 
> > > > > > type because I thought that the geometry and primitives of the 
> > > > > > original s
 cene
> > > > > > 
> > > > > 
> > > > 
> > > 
> > wou
> > 
> > > 
> > > > ld
> > > > 
> > > > 
> > > > > b
> > > > > 
> > > > > 
> > > > > 
> > > > > > e lost after rendering to texture.
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > Usually when doing the post-processing pass you will be rendering to a
> > > > > fullscreen quad. So the vertices you are dealing with are those of the
> > > > > quad you are rendering too.
> > > > > And yes, If you don't any further actions, rendering to texture will 
> > > > > not
> > > > > preserve the information on your orignal vertices etc.
> > > > > The question is what you want to achieve. A geometry shader inbetween
> > > > > your postprocessing pass will work on the quads vertices.
> > > > > Maybe you should elaborate which kind of post processing you want to
> > > > > achieve, so we can help you here.
> > > > > 
> > > > > 
> > > > > 
> > > > > > What am I missing here?  Any clarification is most welcome.
> > > > > > 
> > > > > > -Ethan
> > > > > > 
> > > > > > ------------------
> > > > > > Read this topic online here:
> > > > > > http://forum.openscenegraph.org/viewtopic.php?p=57281#57281
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > _______________________________________________
> > > > > > osg-users mailing list
> > > > > > 
> > > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > _______________________________________________
> > > > > osg-users mailing list
> > > > > 
> > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > 
> > > > > ------------------
> > > > > Post generated by Mail2Forum
> > > > > 
> > > > > 
> > > > ------------------
> > > > Read this topic online here:
> > > > http://forum.openscenegraph.org/viewtopic.php?p=57285#57285
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > _______________________________________________
> > > > osg-users mailing list
> > > > 
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > 
> > > > 
> > > 
> > > _______________________________________________
> > > osg-users mailing list
> > > 
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > 
> > > ------------------
> > > Post generated by Mail2Forum
> > > 
> > 
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=57298#57298
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > osg-users mailing list
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> 
> 
> _______________________________________________
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  ------------------
> Post generated by Mail2Forum


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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to