Page 1 of 1

[2.1] Geometry Shader Line Adjacency

Posted: Tue Oct 30, 2018 4:24 pm
by gabbsson
Render System: GL3Plus


I'm writing a geometry shader to create lines of a given thickness.
Currently I have a solution which lets me set thickness and it works fine, example:

As you can see there are gaps between line segments due to how the expansion is done (normal to the line).
I have found plenty of examples on how to remedy this, but it requires that the shader knows about adjacent lines.
This seems to be a fairly common concept, as it is possible to "request" lines_adjacency in the geometry shader.

If I have understood correctly this should give me 4 vertices (3 line segments) instead of the usual 2 (single line segment).
The indexes are now: 0 - prev segment start, 1 - prev end/current start, 2 - current end/next start, 3 - next end.

I have tried to set the input layout: layout(lines_adjacency) and adjusted my indexes accordingly, but the line is not rendered.
To clarify: I am trying to switch from lines to lines_adjacency and do nothing new with the information, just render as before using the new indexes.
It does not complain about the indexing (as it would if I try to access an index above 1 for lines without adjacency).

A quick search through the Ogre source showed that the render system should detect if adjacency is needed or not (OgreGL3PlusRenderSystem.cpp line 2539):

Code: Select all

// Use adjacency if there is a geometry program and it request adjacency info.
bool useAdjacency  = (mGeometryProgramBound && mPso->geometryShader && mPso->geometryShader->isAdjacencyInfoRequired());
Unfortunately I am stuck here and don't know how to debug this.
There is a reference to adjacency in the manual which should be set using material scripts, I am not using material scripts (since switching to 2.1) at all, are they required?

I would add more information if I knew what else to try, will supply any information you need just ask!

Re: [2.1] Geometry Shader Line Adjacency

Posted: Fri Nov 02, 2018 8:42 am
by gabbsson
Perhaps I can rephrase the question to: is there a good way to know if the rendersystem is currently using adjacency information for my shader?
That way I could figure out if I am doing something wrong in the shader or if the shader is not getting the correct information.

My geometry shader is defined in the HLMS folder for (a version) of Unlit.
Not sure how to consolidate that with material/program scripts. I see plenty of examples in the samples for scripts but there are not present in the samples hlms folder.