bubbbbbai 2023-06-08 19:38 采纳率: 0%
浏览 19

opengl模型光照上叠加热力图,shader该怎么写啊

qt + opengl
现在需要在光照模型上加上热力图的效果,着色器不知道该怎么写好

类似这种效果

img

写了一个半成品,但是显示不出来

  vec3 ambient = ambientStrength * lightColor;
        // diffuse light
        float diff = max(dot(Normal, lightDirection), 0.0);
        vec3 diffuse = diff * lightColor;
        if (lightN == 2) {
            float diff2 = max(dot(Normal, lightDirection2), 0.0);
            diffuse += diff2 * lightColor2;
        }
        // add up
        FragColor = vec4((ambient + diffuse) * vec3(FragColor.x, FragColor.y, FragColor.z), 1.0f);

                vec4 c = vec4(0.0f, 0.0f, 0.0f, 1.0f);
            if (aPosOrigin.z < colorPos[0]) {
            } else {
                float color_pos_offset = aPosOrigin.z - colorPos[0];
                float color_index = color_pos_offset / colorPos[1];
                if (color_index + 1.0f > float(colorSize)) {
                } else {
                    // calculate weighing factor
                    int color_index_int = int(color_index);
                    float wt = color_index - float(color_index_int);
                    // color for blending
                    vec3 blend_color =
                        colorLegend[color_index_int] * (1.0f - wt) + colorLegend[color_index_int + 1] * wt;
                    // blend
                    c = vec4(blend_color, 1.0f);
                }
            }
            FragColor = FragColor * (1.0f - alpha) + c * alpha;

opengl初学者 求帮忙
最好是有相关的源码

  • 写回答

1条回答 默认 最新

报告相同问题?

问题事件

  • 创建了问题 6月8日

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算