Hi there,
I’ve been experimenting with geometry shaders lately. For that we have to work a little bit around MonoGame. Now I’ve tried to access adjacent vertices in the geometry shader by using `lineadj` as input. Unfortunately it does not work for me. Here is my code:

``````[maxvertexcount(6)]
{
float thickness = 0.06f;

// The vertices 0 and 1 form a line together. We want to create two triangles that widen this
// line into a faces.

// Get vector that points from point A to point B.
float2 direction = normalize( vertexData[2].Position.xy - vertexData[1].Position.xy );
float2 normal = float2(-direction.y, direction.x);

// Extrude from center.
normal *= thickness / 2.0f;
normal.x /= vertexData[1].AspectRatio;

float4 offset = float4( normal, 0, 0);

tA0.Position += offset;
tA1.Position -= offset;
tA2.Position += offset;

tB0.Position -= offset;
tB1.Position += offset;
tB2.Position -= offset;

tA0.Color = float4(1,0,0,1);
tA1.Color = float4(0,1,0,1);
tA2.Color = float4(0,0,1,1);

tB0.Color = float4(1,0,0,1);
tB1.Color = float4(0,1,0,1);
tB2.Color = float4(0,0,1,1);

triStream.Append(tA0);
triStream.Append(tA1);
triStream.Append(tA2);
triStream.Append(tB0);
triStream.Append(tB1);
triStream.Append(tB2);
}
``````

By this I try to draw lines. When using `line` and only two vertices, this works.

Does anybody know if this functionality has been even fully implemented in SharpDX?

Cheers,
Georg

There seems to be a bug in SharpDX. It’s code is ported over from SlimDX, but using the original SlimDX Shader Code Loading, it works:

``````var graphicsDevice = PiXServices.GetService<IGraphicsDeviceService>()
.GraphicsDevice;
//  .CompileFromFile( geometryShaderFilePath, "MainGS", "gs_5_0" );
var code = new SharpDX.D3DCompiler.ShaderBytecode( compiledGS.Data );

That means this can’t be easily done without forking MonoGame and changing `GraphicsDevice`, `PrimitiveType` and `GraphicsDevice::ToPrimitiveTopology`.