【问题标题】:Computing a pixel's specular value?计算像素的镜面反射值?
【发布时间】:2015-06-01 22:42:25
【问题描述】:

我一直在互联网上寻找公式来计算光线追踪器中给定像素的漫反射值(当然,光线相交的地方)。

我发现的示例都涉及将颜色乘以其他颜色。 Nvidia的公式如下:

diffuse = Kd x lightColor x max(N · L, 0)

地点:

- Kd is the material's diffuse color
- lightColor is the color of the incoming diffuse light
- N is the normalized surface normal
- L is the normalized vector toward the light source
- P is the point being shaded

这个公式对我来说似乎并不难,但在尝试对其进行编程时,我发现Kd x lightColour 是 2 个 RGB 值的乘积。这让我感到困惑,因为除非只是将 R、G 和 B 值相乘,否则没有办法像这样相乘。

类似地,镜面反射公式要求将 RGB 值提高到与材质的光泽度系数相等的幂,这又是 3 分量数据类型本身的乘积。

这可能是我对数学感到困惑,但如果有人能解决这个问题,将不胜感激。

【问题讨论】:

    标签: opengl math graphics rgb raytracing


    【解决方案1】:

    Kd x lightColour 是一个分量乘法:

      a       d       a*d
    [ b ] x [ e ] = [ b*e ]
      c       f       c*f
    

    在镜面反射照明的公式中(假设您谈论的是phong 或 blinn-phong 照明模型),没有向量的幂运算。

    specular = ks x lightcolor x (R · V)^a
    

    R · V 的结果是一个浮点数,因此幂只适用于单个数字。

    【讨论】:

    • 对数学符号的简短评论。向量的分量乘法称为“Hadamard 积”,通常用一个空心圆圈表示(请记住,函数组合也使用相同的符号)。
    猜你喜欢
    • 1970-01-01
    • 2016-07-30
    • 2018-07-14
    • 2015-09-28
    • 2015-05-25
    • 1970-01-01
    • 1970-01-01
    • 2018-07-09
    • 2017-10-06
    相关资源
    最近更新 更多