2,543
社区成员
发帖
与我相关
我的任务
分享
void main()
{
vec4 textureColor;
vec4 outColor;
vec4 U;
vec4 V;
if(PixFormat == 1000.0f)
{
//RGB32
textureColor = vec4(texture2D(textureUniformRGBA,textureCoordinate));
textureColor.a = textureColor.a*RGB_Alpha;
}
else
{
//YUV420 TO RGB32
textureColor = vec4((texture2D(textureUniformY, textureCoordinate).r - 16./255.) * 1.164);
U = vec4(texture2D(textureUniformU, textureCoordinate).r - 128./255.);
V = vec4(texture2D(textureUniformV, textureCoordinate).r - 128./255.);
textureColor += V * vec4(1.596, -0.813, 0, 0);
textureColor += U * vec4(0, -0.392, 2.017, 0);
textureColor.a = RGB_Alpha;
}
if(1 == dark)
{
float brightness = 0.45f;
//模糊
vec2 firstOffset = vec2(1.3846153846 * texelWidthOffset, 1.3846153846 * texelHeightOffset) * blurSize;
vec2 secondOffset = vec2(3.2307692308 * texelWidthOffset, 3.2307692308 * texelHeightOffset) * blurSize;
centerTextureCoordinate = textureCoordinate;
oneStepLeftTextureCoordinate = textureCoordinate - firstOffset;
twoStepsLeftTextureCoordinate = textureCoordinate - secondOffset;
oneStepRightTextureCoordinate = textureCoordinate + firstOffset;
twoStepsRightTextureCoordinate = textureCoordinate + secondOffset;
vec4 fragmentColor = texture2D(textureUniformRGBA, centerTextureCoordinate) * 0.2270270270;
fragmentColor += texture2D(textureUniformRGBA, oneStepLeftTextureCoordinate) * 0.3162162162;
fragmentColor += texture2D(textureUniformRGBA, oneStepRightTextureCoordinate) * 0.3162162162;
fragmentColor += texture2D(textureUniformRGBA, twoStepsLeftTextureCoordinate) * 0.0702702703;/
fragmentColor += texture2D(textureUniformRGBA, twoStepsRightTextureCoordinate) * 0.0702702703;
//加暗
textureColor = vec4((fragmentColor.rgb * vec3(brightness)), fragmentColor.a);
//最后画面
gl_FragColor = textureColor;
}