qt + opengl
现在需要在光照模型上加上热力图的效果,着色器不知道该怎么写好
类似这种效果
写了一个半成品,但是显示不出来
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初学者 求帮忙
最好是有相关的源码