Well, let’s discuss the need and sample implementation of a geometry “generating” programs - don’t know how they are called officially.
Do we need something like this? Can you propose some usage areas? Software implementation of such units would be rather Simple, I think. One can just take GLSL as base and define all glVertex* functions in it…
Some positive aspects I can see is possible speed-up of custom model generation, surface generation and shadow volumes construction(if anyone is going to use it anymore )
As T101 wished, I’m adding a list here. It sems a bit overcomplicated to me though Feel free to suggest edits
Possible uses:
[ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>Dynamic LOD - specifically thinking about terrain[/li] [li]Higher order surfaces[/li] [li]Shadow volume construction[/ul][/li]</font></font></font></font>[li]2. Options for placement:[/li][ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>A. Before vertex transform - this is more flexible, and may allow software emulation. [/li]But possibly problem with display lists - if either but not both are implemented in hardware.
[li]B. After vertex transform - can probably only operate on triangles and possibly quads, but[/li] can benefit from parallellism, and because of its limited functionality, simple to implement. But cannot be done in software without also performing the vertex transforms in software.
[/ul]
</font></font></font></font>[li]3. Possible functionality:[/li] [ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>A1 Replace only evaluator functionality. Generate vertices for a single primitive type (probably trianglelist or quadlist), using current texture bindings.[/li] [li]A2 Replace both display list and evaluator functionality. Pretty much anything that can be called from a display list, including recursion. Advantages: highly flexible, possibility to do preprocessing on the CPU, display list functionality can be implemented using a geometry program, clearly defined relation to display lists, suitable primitives can be started for certain types of geometry (e.g. automatic use of strips or fans). Disadvantages: complex to implement in hardware, possible byte-order issues between GPU and CPU, high resource requirements, possibly memory management issues when binding textures.[/li] [li]B. (After vertex transform)[/li] Custom interpolation/warping in eye-space
[/ul]
</font></font></font></font>[li]4. Input:[/li] [ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>A1 Vertex and attribute streams in object-space with attributes and parameters. Possibly one or more 1D/2D/3D/cubemap textures.[/li] [li]A2 Buffer objects - to be initialised at the CPU (both for custom structures and for compiled display lists if driver chooses to)[/li] [li]B. (After vertex transform) Vertex and attribute streams in eye-space with attributes and parameters. Possibly one or more 1D/2D/3D/cubemap textures.[/li] [/ul]
</font></font></font></font>[li]5. Output:[/li] [ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>A1 Vertex stream in object-space[/li] [li]A2 Command and vertex stream in object-space[/li] [li]B. (After vertex transform) Edited eye-space vertex stream - possible additions/deletions.[/li] [/ul]
Korval: I’m not sure where writing to vertex attributes would come in, possibly both A1 and B.
</font></font></font></font>[li]6. New constants/functions[/li] [ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>GL_PRIMITIVE_SHADER - Overmind’s suggestion for a primitive type to send vertices through the geometry program instead of using a standard primitive[/li] [li]glProcessGeometry(int first, int count) - Zengar’s suggestion for calling the geometry program after using vertex pointers to set up the streams[/li] [/ul]
</font></font></font></font>[li]7. Proposed GLSL built-in types/functions/variables[/li] No doubt just a subset of what will actually be required, very preliminary,
and both V-man’s and Overmind’s suggestions are in here.
[ul][li]<font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”><font size=“2” face=“Verdana, Arial”>vertex - the vector as well as all the attributes. Note: What would be the maximum number and type of the attributes? Also: could this be defined as a simple fixed struct?[/li] [li]Variables:[/li] [li]vec4 gl_Vertex{123} (or a vec3) for sending the coordinates of one triangle (V-man’s suggestion - superceded by gl_Triangle[n] I think?)[/li] [li]gl_Triangle[n] Triangle structure. Contains data for triangles. Containing: int index1,index2,index3; indices into the vertex array/VBO. - Would that be the edited or original array? If edited, how do you keep track? If not, how do you insert?[/li] [li]vertex gl_Vertex[n] to address the input vertex stream - with n=0 for the first vertex of the “current” triangle.Note: how do you advance the index?[/li] [li]gl_TriangleCounter int to keep track of the (total?) triangle count[/li]
Functions:
[li]glBegin()[/li] [li]glEnd()[/li] [li]glNormal()[/li] [li]glVertex()[/li] [li]vertex interpolate(vertex v1, vertex v2, float amount) - interpolate between vertex attributes[/li] [li]void gl_Triangle(vertex v1, vertex v2, vertex v3) - emit a triangle with these three vertices (incl. attribs)[/li] [li]??? gl_ControlMesh(???) - Some way of accessing parameters to the geometry program. V-man, if this is important, please elaborate.[/li] [/ul]