基于Qt的OpenGL可编程管线学习(13)- 变亮变暗
更新:HHH   时间:2023-1-7


图片混合变亮与变暗的效果,如下图所示


变暗效果


变亮效果


变亮shader

uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;

varying vec2 M_coord;

void main()
{
        vec4 blendColor = texture2D(U_SubTexture, M_coord);
        vec4 baseColor = texture2D(U_MainTexture, M_coord);
        gl_FragColor = max(blendColor, baseColor);
}


变暗shader

uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;

varying vec2 M_coord;

void main()
{
        vec4 blendColor = texture2D(U_SubTexture, M_coord);
        vec4 baseColor = texture2D(U_MainTexture, M_coord);
        gl_FragColor = min(blendColor, baseColor);
}


返回编程语言教程...