hardcoded compute shader

This commit is contained in:
2018-04-09 18:34:10 -04:00
parent 6539dd5ee6
commit dd5f05a12f
2 changed files with 33 additions and 3 deletions

View File

@@ -112,7 +112,7 @@ namespace Platformer
GL.BindVertexArray(_polyVao);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _pEdges);
GL.Uniform3(_render.UnifLoc("color"), .1f, .1f, .9f);
GL.Uniform3(_render.UnifLoc("color"), .1f, .1f, .6f);
GL.DrawElements(BeginMode.Lines, _pEdges.Count, DrawElementsType.UnsignedInt, 0);
GL.Flush();

View File

@@ -15,11 +15,41 @@ layout(std430, binding=2) buffer PolyVerts
vec4 polyVerts[];
};
layout(std430, binding=3) buffer EdgeInds
layout(std430, binding=3) buffer PolyEdges
{
uint edgeInds[];
uint polyEdges[];
};
uniform PlaneMats
{
mat4 tform;
};
layout(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
void main () {
uint ti0 = gl_GlobalInvocationID.x * 4;
uint pv0 = gl_GlobalInvocationID.x * 4;
uint pe0 = gl_GlobalInvocationID.x * 8;
uint ii = 0;
uint vv = 0;
// polyVerts[pv0 + vv++] = vec4(-1,0,0,1);
// polyVerts[pv0 + vv++] = vec4(1,0,0,1);
//
// polyEdges[pe0 + ii++] = pv0 + 0;
// polyEdges[pe0 + ii++] = pv0 + 1;
for(uint i = 1; i < 4; i++)
{
polyVerts[pv0 + vv++] = (tetraVerts[ti0] + tetraVerts[ti0 + i]) / 2;
}
polyEdges[pe0 + ii++] = pv0 + 0;
polyEdges[pe0 + ii++] = pv0 + 1;
polyEdges[pe0 + ii++] = pv0 + 1;
polyEdges[pe0 + ii++] = pv0 + 2;
polyEdges[pe0 + ii++] = pv0 + 2;
polyEdges[pe0 + ii++] = pv0 + 0;
}