Mix environment mapping with diffuse texture

Looking for some help with what I imagine is a basic issue that I am overlooking?

I am wanting to mix my environment mapping with a diffuse texture.

Code for the fragment shader is as follows:

#version 330 core
out vec4 FragColor;

in vec3 N;
in vec3 P;
in vec2 tcs;

uniform vec3 camPos;
uniform samplerCube sB;
uniform sampler2D dT;

void main()
{             
    vec3 I = normalize(P - camPos);
    vec3 R = reflect(I, normalize(N));
    
    vec4 color;
    color = texture2D(dT, tcs);
    
    vec4 mapping;
    mapping = vec4(texture(sB, R).rgb, 0.6);
   
    FragColor.rgb = mix(color.rgb,mapping.rgb, 0.4);
}

If I render just the diffuse texture it works fine. If I render just the environment mapping it works fine. If use a fixed color value it works fine and also mixes with the environment mapping. However, if I use the diffuse texture and try to mix it then nothing appears.

I presumed then it must be some binding issue and did some reading on binding and found…

“Of course, once shaders came about, you can see how this all changes. The enable state becomes the sampler type in the shader. So now there’s no explicit code describing which texture target is enabled; it’s just shader stuff. So they had to make a rule that says that two samplers cannot use the same unit if they’re different types.”

So I have tried both binding them to the same unit and different units, with no impact.

I am creating the textures in difference classes of course, but I don’t see how that can be the issue? Binding code is as follows…

	glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0
	glBindTexture(GL_TEXTURE_2D, texture.getID());

	glActiveTexture(GL_TEXTURE0 + 1); // Texture unit 1
	glBindTexture(GL_TEXTURE_CUBE_MAP, skybox.getID());

Can someone put me out my misery, it would be much appreciated.

FragColor.rgb = mix(color.rgb,mapping.rgb, 0.4);

Maybe you forgot set the alpha value to 1.0;

FragColor.a = 1.0;

Thanks for the reply,

Unfortunately its still the same. Really is a very bizarre issue. I know drivers are super aggressive when it come to removing unused GLSL code, it almost seems like it is being deleted.

For example this works perfectly fine with the fixed color value ***

void main()
{             
    vec3 I = normalize(P - camPos);
    vec3 R = reflect(I, normalize(N));
    
    vec4 color;
    ***color = vec4(0.3,0.3,0.3,0.5);***
    
    vec4 mapping;
    mapping = vec4(texture(sB, R).rgb, 0.6);
   
    FragColor.rgb = mix(color.rgb,mapping.rgb, 0.4);
}