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用法
标签:倒影,效果,0.0,float,vTexCoord,uniform,shader,vec2,mediump 来源: https://blog.csdn.net/qq_40239482/article/details/115357568