##start
##vertex

#version 150
#extension GL_ARB_explicit_attrib_location : enable


layout(location=0) in vec3 in_Position;
layout(location=1) in float in_size;

uniform mat4 modelViewMatrix;

out float size;

//out vec4 wpos;

void main()
{

    size = in_size;
   gl_Position = modelViewMatrix*vec4(in_Position,1) ;


}



##end

##start
##geometry
#version 150
#extension GL_EXT_geometry_shader4 : enable

layout(points) in;

layout(triangle_strip, max_vertices=4) out;
uniform mat4 projMatrix;
in float[1] size;

out vec2 tc;
out vec4 spherecenter;

void main() {
    if (gl_in[0].gl_Position == vec4(0,0,0,0)) return;

  vec4 pos = gl_in[0].gl_Position;
  vec4 coords = gl_in[0].gl_Position;
  vec4 center = gl_in[0].gl_Position;

  float dx=size[0];
  float dy=size[0];

  vec4 ix=vec4(-1,1,-1,1);
  vec4 iy=vec4(-1,-1,1,1);
  vec4 tx=vec4(0,1,0,1);
  vec4 ty=vec4(0,0,1,1);

  spherecenter = center;

  for(int i =0; i<4;i++){
      pos.x =ix[i]*dx +coords.x;
      pos.y =iy[i]*dy +coords.y;
      tc.x = tx[i];
      tc.y = ty[i];

      gl_Position = projMatrix*pos;
      EmitVertex();
  }
}


##end

##start
##fragment

#version 150 core


in vec2 tc;

out vec4 out_color;

uniform sampler2D diffuseTex;

void main(void)
{
     out_color = texture(diffuseTex,tc);
}


##end
