*([k * (step + 2) + i for i in range(step + 2)] + [-1])) vbo = GL.NewVertexBuffer(data) ibo = GL.NewIndexBuffer(idata) vao = GL.NewVertexArray(grass_prog, vbo, '3f3f3f1f1f', ['vert', 'direction', 'color', 'thickness', 'power'], ibo) ssao_vbo = GL.NewVertexBuffer( struct.pack('8f', 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0)) ssao_vao = GL.NewVertexArray(ssao_prog, ssao_vbo, '2f', ['vert']) ubo = GL.NewUniformBuffer(b''.join(struct.pack('2f', x, y) for x, y in kernel)) fbo, color, depth = GL.NewFramebuffer() GL.SetUniform(grass_prog['mat'], struct.pack('16f', *camera)) GL.SetUniform(ssao_prog['texture'], 0) GL.SetUniform(ssao_prog['depth'], 1) GL.UseUniformBuffer(ubo, ssao_prog['Kernel']) while WND.Update(): GL.UseFramebuffer(fbo) GL.EnableDepthTest() GL.Clear(0, 0, 0) GL.RenderTriangleStrip(vao, 1000 * 8) GL.UseFramebuffer(GL.SCREEN)
#version 330 in float d; out vec4 color; void main() { color = vec4(0.30 * d, 0.50 * d, 1.00 * d, 0.5); } ''') prog, iface = GL.NewProgram([vert, frag]) vbo = GL.NewVertexBuffer(struct.pack('72f', *verts)) vao = GL.NewVertexArray(prog, vbo, '3f1f', ['vert', 'diffuse']) nodes = [GL.NewFramebuffer(256, 256) for i in range(6)] enables = [ GL.ENABLE_BLEND, GL.ENABLE_CULL_FACE, GL.ENABLE_DEPTH_TEST, GL.ENABLE_BLEND + GL.ENABLE_DEPTH_TEST, GL.ENABLE_CULL_FACE + GL.ENABLE_BLEND, GL.ENABLE_BLEND + GL.ENABLE_DEPTH_TEST + GL.ENABLE_CULL_FACE, ] GL.Viewport(0, 0, 256, 256) for i, (fbo, color, depth) in enumerate(nodes): GL.UseFramebuffer(fbo) GL.Clear(*bg[i]) GL.EnableOnly(enables[i])