Sampler behaving differently on my laptop

So I’m trying to write a simple fragment shader that samples a texture and discards any non-solid colors. This is also my first attempt at using multiple samplers in one project, though they’re not both in this one shader. Now this program works perfectly on my PC (Radeon 7850, GL_SHADING_LANGUAGE_VERSION = 4.20), but even playing with it I can’t get the shader to do anything on my laptop (AMD integrated, GL_SHADING_LANGUAGE_VERSION = 4.30). I suspect that the problem is with my samplers and my inabity to properly use more than one.
I’m using glfw3, glew, and SOIL to load images.

So here’s my vertex shader(works fine afaik):


#version 330
layout(location = 0) in vec4 position;
layout(location = 1) in vec2 vertexUV;

out vec2 UV;

layout(std140) uniform GlobalMatrices{
mat4 MVP;
};

void main(){
gl_Position = MVP * position;
UV = vertexUV;
};

Here’s the troubling fragment shader:


#version 330
in vec2 UV;
out vec3 color;

uniform sampler2D pngSampler;

void main(){
vec4 colorin = texture(pngSampler, UV);
if(colorin.a < 1.0) discard;
color = colorin.rgb;
};

Finally here’s some bits of code from initializing the samplers and some from drawing:


//Initialization after program linkage:
transpTexShader.sampler = glGetUniformLocation(transpTexShader.theProgram, "pngSampler");
glProgramUniform1i(transpTexShader.theProgram, transpTexShader.sampler, 0);

//Image load with SOIL;
TEX_IMG = SOIL_load_OGL_texture(File, 
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
		);
if (TEX_IMG <= 0) cout << "IMG ERROR: " << File << endl;

//Drawing:
glUseProgram(shader->theProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TEX_IMG);
//glBindSampler(0, shader->sampler);//doesn't do anything for me
...bindBuffers, draw, etc

Not shown is the code for my regular texture shader which works fine, and initializes another sampler on a different shader object/program and with a different string name. I suspect my PC’s graphics card is covering for a mistake I’m making because my transparency shader works even with only that regular sampler set. Any advice would really help.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.