在GLSL中混合红色和白色之间的颜色

时间:2017-12-27 10:10:30

标签: opengl-es glsl glsles

我想混合基色和鬼色之间的褪色 基色为白色,鬼色为红色,现为淡化为黑色,不变为白色(与红色混合)

我的基色为白色,鬼色为红色,漫反射色取决于光线方向(正常和相机位置的点积)

#version 100
precision highp int;
precision highp float;

uniform float time;
uniform float line;
uniform float fadingTime;
uniform vec4 ghostColor;
uniform vec4 baseColor;
uniform float edgeIntensity;



varying float  lightDiffuse;

void main()
{

    float rampLight =lightDiffuse;

    float light = (1.0 - rampLight) * 0.9;
    vec4 lightColor = vec4(ghostColor.r, ghostColor.g, ghostColor.b, ghostColor.a);
    vec4 diffuseColor = lightColor*light;
    float sintime = clamp(abs(cos(time*fadingTime)), 0.0, 1.0);    

    float edgeIntens = edgeIntensity;
    edgeIntens*= sintime;
    vec4 smootheddiffuseColor = smoothstep(baseColor, vec4(lightColor), vec4(edgeIntens));

    vec4 mixeddiffuseColor = mix(baseColor, diffuseColor, vec4(smootheddiffuseColor));

    gl_FragColor = mixeddiffuseColor;

}

0 个答案:

没有答案