# GLSL can't calculate texture and reflection

I'm working on a universal shader, and have a function for calculating reflections and a function for textures. When I run the shader, it seems to give up and discard all fragments. The texture and reflection work fine when run independently, however, when I try to calculate both the texture and the reflection at the same time, it gives up. Even if I leave the result of the reflection alone and don't do anything with it, the fragment gets discarded.

in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoords;

uniform vec3 ViewPos;

uniform sampler2D texture_diffuse1;
uniform samplerCube skybox;

vec3 CalcReflection(vec3 normal, vec3 frag, vec3 view, float shine);

void main() {
// properties
vec3 norm = normalize(Normal);

//Both of these statements work as long as the other isn't called
vec4 texColor = vec4(texture(texture_diffuse1, TexCoords).rgb, 1.0);

vec4 reflection = vec4(CalcReflection(norm, FragPos, ViewPos, mat.shininess), 1.0);

FragColor = texColor; //I'm not doing anything with reflection, yet it still discards the fragment
}

vec3 CalcReflection(vec3 normal, vec3 frag, vec3 view) {
vec3 I = normalize(frag - view);
vec3 R = reflect(I, normal);
return vec3(texture(skybox, R).rgb);
}


I'm not too worried about blending the texture and reflection yet, but to start on that I need to know why this doesn't work.

The answer is probably obvious, but I've been stuck on this for a while and need a fresh perspective

Edit: Added more things from my actual code (skybox definition, alpha values)

• How is 'skybox' defined ? Have you tried to output with alpha=1 also, e.g. FragColor=vec4(texColor,1); - You will need to set the output type to vec4 for FragColor. – PaulHK May 5 '18 at 9:20
• Do you have OpenGL debug output turned on? If not, that would be my first step, and see if it gives you any errors for this shader. My guess is there's some problem binding uniforms/textures when both diffuse and reflection are turned on. – Nathan Reed May 6 '18 at 22:34
• I didn't know about that, i'll try it and get more info, thanks – hippo_o_matic May 8 '18 at 3:54