【发布时间】:2015-09-23 15:01:57
【问题描述】:
我正在片段着色器中为球体实现简单的光线追踪,我目前正在研究计算漫反射球体颜色的函数。这是函数的代码:
vec3 shadeSphere(vec3 point, vec4 sphere, vec3 material) {
vec3 color = vec3(1.,2.,3.);
vec3 N = (point - sphere.xyz) / sphere.w;
vec3 diffuse = max(dot(Ldir, N), 0.0);
vec3 ambient = material/5;
color = ambient + Lrgb * diffuse * max(0.0, N * Ldir);
return color;
}
我在使用 max 函数的两行出现错误。我从使用函数 max(dot(ec_light_dir, ec_normal), 0.0); 的 webgl 备忘单中获得了分配 max(dot(Ldir,N),0.0) 的行的代码
出于某种原因,我的实现无法正常工作,因为我收到了错误:
ERROR: 0:38: 'max' : no matching overloaded function found
我正在使用的这些 max 函数中的任何一个可能有什么问题?
【问题讨论】:
标签: opengl-es glsl webgl fragment-shader