shader倒影效果

vertex shader:

attribute vec3 kzPosition;
attribute vec2 kzTextureCoordinate0;
uniform highp mat4 kzProjectionCameraWorldMatrix;
uniform mediump vec2 TextureOffset;
uniform mediump vec2 TextureTiling;

varying mediump vec2 vTexCoord;

void main()
{
    precision mediump float;
    
    vTexCoord = kzTextureCoordinate0*TextureTiling + TextureOffset;
    gl_Position = kzProjectionCameraWorldMatrix * vec4(kzPosition.xyz, 1.0);
}

fragetment shader:

`uniform sampler2D Texture;
uniform lowp float ReflectProg;
uniform lowp float BlendIntensity;
varying mediump vec2 vTexCoord;


void main()
{
    precision lowp float;

    vec4 color = texture2D(Texture, vTexCoord);
    vec4 bg = vec4(0.0,0.0,0.0,0.0);
    float mixval = smoothstep(0.0,1.0,vTexCoord.y/ReflectProg);
    color = mix(color,bg,mixval);
    
    gl_FragColor.rgba =  color.rgba * BlendIntensity;
}

备注:openglES用法

上一篇:折纸效果! Cocos Creator 3.0


下一篇:C++描述 LeetCode 567. 字符串的排列