OpenGL纹理没有找到匹配的重载函数

时间:2015-05-15 18:29:39

标签: opengl textures

首先是我的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':没有计算找到的重载函数(使用隐式转换) 我查看了GLSL文档,但我认为是正确的。之后,我在我的OpenGL文件中搜索了一个错误...但我看起来还不错。

1 个答案:

答案 0 :(得分:1)

您正尝试使用3D坐标从2D采样器读取。将-module(z). -define(DELAY(X), fun() -> X end). -define(FORCE(X), X()). create(Dx, N) -> [0 | ?DELAY(create_loop(Dx, N))]. create_loop(Dx, N) -> [Dx*N | ?DELAY(create_loop(Dx, N-1)]; % This is an abuse of improper lists create_loop(_, 0) -> []. map(F, []) -> []; map(F, [V | Thunk]) -> [F(V) | ?DELAY(map(F, ?FORCE(Thunk)))]. sum([], Acc) -> Acc; sum([V | Thunk], Acc) -> sum(?FORCE(Thunk), V + Acc). integral(X1,X2,Dx, F) -> N = trunc((X2-X1) / Dx), Points = create(Dx, N), Vals = map(fun(X) -> F(X)*Dx end, Points), sum(Vals). 更改为in vec3 TexCoords或将纹理查找从in vec2 TexCoords更改为texture(material.diffuse, TexCoords)