math - glsl中光的半向量是什么?

标签 math opengl glsl

我正在使用每像素照明着色器,但我不知道一件事:什么是光源的半向量?

vec3 halfVector = normalize(gl_LightSource[1].halfVector.xyz);

我希望你能用数学行来解释它,我比文字更懂数学:)

最佳答案

来自 this post :

A "halfway vector" (if you mean that by "half vector") is the unit vector at the half angle between two other vectors. Normally the halfway vector [...] is computed between the vector to the viewer v and the light source l:


h := ( v + l ) / || v + l ||

因此,半向量是单位 angle bisector View 和光矢量。

编辑:有关包括半矢量在内的照明模型的完整说明,请参阅 Blinn-Phong wikipedia article

关于math - glsl中光的半向量是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3646401/

相关文章:

c - 在C编程中通过给定边查找三角形的角度

opengl - 如何获得硬边 - OpenGL

opengl - 从 GLSL 版本 1.20 开始允许 GLSL Uniforms 初始化

algorithm - 教科书长除法如何成为 O(n^2) 算法?

regex - 下列集合是否规则?

opengl - 交错顶点提交对性能有何帮助?

c++ - 如何在 GLSL 中使用 4x4 矩阵作为顶点属性?

c++ - 我的 OpenGL QQuickItem 没有我想要的大小

java - 如何选择光源来实现 Phong 着色?

algorithm - 找到极端高阶元素关系的优先级函数/字母顺序