首先是我的Fragmenshader代码。
#version 330 core
struct Material{
sampler2D diffuse;
};
struct Light{
vec3 position;
vec3 ambient;
vec3 diffuse;
};
in vec3 Normal;
in vec3 FragPos;
in vec3 TexCoords;
out vec4 color;
uniform vec3 viewPos;
uniform Material material;
uniform Light light;
void main()
{
//ambient
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
//Diffuse
vec3 norm = normalize(Normal);
vec3 lightDir = normalize(light.position - FragPos);
float diff = max(dot(norm,lightDir),0.0);
vec3 diffuse = light.diffuse * diff *vec3(texture(material.diffuse,TexCoords));
color = vec4(ambient+diffuse,1.0f);
}如果我想编译,我会得到这样的错误:'texture':not mathcing overloaded found (使用隐式转换)我查看了GLSL文档,但我看起来是正确的。之后,我在我的OpenGL文件中搜索了一个错误...但我看起来还好。
发布于 2015-05-16 02:50:31
您正在尝试使用3D坐标从2D采样器读取数据。将in vec3 TexCoords更改为in vec2 TexCoords或将纹理查找从texture(material.diffuse, TexCoords)更改为texture(material.diffuse, TexCoords.xy)
https://stackoverflow.com/questions/30266435
复制相似问题