我正在尝试在 opengl core 3.3 中实现阴影贴图。当我向 GLSL 中的纹理函数发送偏差时,它似乎根本没有做任何事情。我用错了吗?
#version 330
uniform sampler2D diffusetex;
uniform sampler2D normaltex;
uniform sampler2D postex;
uniform sampler2D depthtex;
uniform sampler2DShadow shadowmap;
uniform mat4 shadowmat;
in vec2 uv;
layout (location=0) out vec4 outColor;
void main(){
vec3 normal = normalize(texture(normaltex, uv).xyz);
vec3 world_position = texture(postex, uv).xyz;
vec4 shadowcoord = shadowmat*vec4(world_position, 1);
float shadow = texture(shadowmap, shadowcoord.xyz,0.5);
float luma = max(0.1,shadow);//ambient light
outColor = texture(diffusetex, uv)*luma;
}
我正在使用 linux、nvidia 专有驱动程序和 golang。怀疑它与它有什么关系,但以防万一,它就在那里。