I have been pulling my hair out for 2 days over this.
First.. the code.. All of it.
//Leaf Vertex Shader
#version 330 compatibility
out vec4 VertexColor;
void main(void)
{
gl_Position = gl_ModelViewMatrix *gl_Vertex;
gl_TexCoord[0].st = gl_MultiTexCoord0.st;
gl_TexCoord[1].st = gl_MultiTexCoord1.st;
gl_TexCoord[2].st = gl_MultiTexCoord2.st;
gl_TexCoord[3].st = gl_MultiTexCoord3.st;
gl_TexCoord[4].st = gl_MultiTexCoord4.st; // this is out size in x.y
VertexColor = gl_Color;
}
Geo shader
#version 330 compatibility
#extension GL_EXT_geometry_shader4 : enable
//uniform float uNormalsLength;
out vec2 texCoord;
out vec4 color;
layout(points) in;
layout(triangle_strip, max_vertices = 4) out;
void main(void)
{
vec4 vVertex = gl_in[0].gl_Position;
vec2 uvs[4];
uvs[0] = gl_TexCoord[0].st;
uvs[1] = gl_TexCoord[1].st;
uvs[2] = gl_TexCoord[2].st;
uvs[3] = gl_TexCoord[3].st;
vec2 scale = gl_TexCoord[4].st;
float vx[4];
vx[0] = -1.0;
vx[1] = -1.0;
vx[2] = 1.0;
vx[3] = 1.0;
float vy[4];
vy[0]= -1.0;
vy[1]= 1.0;
vy[2]= 1.0;
vy[3]= -1.0;
int indi[4];
indi[0] = 0;
indi[1] = 3;
indi[2] = 1;
indi[3] = 2;
texCoord = uvs[0];
vec4 oVertex = gl_PositionIn[0];
color = vec4(0.5, 0.5, 0.5, 1.0);
for(int i = 0; i < 4; ++i)
{
oVertex.xyz = vVertex.xyz;
color = vec4(0.0, 0.0, 0.5, 1.0);
oVertex.x += (vx[ indi[i] ] * scale.x);
oVertex.y += (vx[ indi[i] ] * scale.y);
texCoord.xy = uvs[ indi[i] ].xy;
gl_Position = gl_ModelViewProjectionMatrix * oVertex;
EmitVertex();
}
EndPrimitive();
}
Frag shader
// leaf fragment shader
#version 330 compatibility
uniform sampler2D colorMap;
in vec2 texCoord;
in vec4 color;
out vec4 FragColor;
void main (void)
{
vec2 uv = texCoord.xy;
uv.y *= -1.0;
vec4 t = texture2D(colorMap,uv);
FragColor = t;
FragColor.rgb += color.rgb;
}
When I send this a point, I get nothing out but a point. I have tried sending triangle_stips.. It makes no difference.
When I check the int32 returned gl_getuniformlocation for colorMap, its -1.
It is almost like this program does NOT running when I call gl_useprogram. It has not effect.. I can't even effect the color and.. getting back -1 for colorMap makes me think the fragment shader never gets any input. I have tried hard coding a vertex in the vertex shader and it makes no difference.
I'm not sure about the transform but I can't test this as I cant see ANYTHING but a point. Like I said.. Its like its never being loaded. If I send the vertices as a triangle_strip, I see a triangle_strip on the screen. Thanks for any one that takes the time to read this.
Sorry about all the code but maybe someone can spot something I'm missing. Also.. There is a lot of deprecated things in there but it has never been a problem in my other shaders.
colorMap
to shader? – user3813674GL_EXT_geometry_shader4
extension on GLSL 3.30, which has core GS functionality). – Nicol BolasGl.glActiveTexture(Gl.GL_TEXTURE0) Gl.glBindTexture(Gl.GL_TEXTURE_2D, Trees.flora(i).branch_textureID)
– Mike O