Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shadoh

Member Since 13 Nov 2012
Offline Last Active Nov 25 2012 11:00 PM
-----

Topics I've Started

values not transfering from vertex shader

13 November 2012 - 11:01 PM

Hi guys, I'm in dire need for help; For some reason my ins/outs don't seem to be matching up, and I can't figure out why, I've spent a few days on it now.
My code was based off a billboarding tutorial, I seem to have lost the link to it. But here's the source for my shaders below. Can you tell me what's going on?
My Color is black in the fragment shader, even though it's sent in to the shader as white. And even if I manually set the color to white in the vertex shader it still appears black in the fragment shader.

Geometry shader
#version 330
#extension GL_ARB_separate_shader_objects : enable
layout (points) in;
layout (triangle_strip) out;
layout (max_vertices = 4) out;
uniform mat4 gVP;
uniform vec3 gCameraPos;
layout (location = 1) in float inScale[1];
layout (location = 2) in vec4 inTexCoord[1];
layout (location = 3) in vec4 inColor[1];
layout (location = 1) out vec2 TexCoord;
layout (location = 2) out vec4 Color;

void main()
{
    vec3 Pos = gl_in[0].gl_Position.xyz;

vec3 toCamera = normalize(gCameraPos - Pos);
    vec3 up = vec3(0.0, 1.0, 0.0);
    vec3 right = cross(toCamera, up);
 
vec4 tc = inTexCoord[0];
float Sc = inScale[0];
vec4 col = inColor[0];
Pos -= (right * (Sc * 0.5));
Pos.y -= Sc * 0.5;
    gl_Position = gVP * vec4(Pos, 1.0);
    TexCoord = vec2(tc.x, tc.y);
Color = col;
    EmitVertex();
    Pos.y += Sc;
    gl_Position = gVP * vec4(Pos, 1.0);
    TexCoord = vec2(tc.x, tc.w);
Color = col;
    EmitVertex();
    Pos.y -= Sc;
    Pos += right * Sc;
    gl_Position = gVP * vec4(Pos, 1.0);
    TexCoord = vec2(tc.z, tc.y);
Color = col;
    EmitVertex();
    Pos.y += Sc;
    gl_Position = gVP * vec4(Pos, 1.0);
    TexCoord = vec2(tc.z, tc.w);
Color = col;
    EmitVertex();
    EndPrimitive();
}

Vertex shader
#version 330
#extension GL_ARB_separate_shader_objects : enable

layout (location = 0) in vec3 Position;
layout (location = 1) in vec2 TexCoord;
layout (location = 2) in vec4 Color;



// vertex shader

layout (location = 1) out vec2 TexCoordOut;
layout (location = 2) out vec4 ColorOut;



void main()
{
	gl_Position = vec4(Position, 1.0);
	TexCoordOut = TexCoord;
	ColorOut = Color;
}

Fragment shader
#version 330
#extension GL_ARB_separate_shader_objects : enable


uniform sampler2D TextureMap;
uniform float Alpha;

// fragment shader
in vec2 TexCoordOut;
in vec4 ColorOut;


out vec4 outputF;



void main(void)
{
	//vec4 tex = texture(TextureMap, TexCoordOut.xy);
	//tex.a *= Alpha;
	//tex *= ColorOut;
	//if (tex.a <= 0.0)
	//{
	//	discard;
	//}
	//else
	//{
		outputF = ColorOut;
	//}
}

PARTNERS