-
- 我使用描述了OpenGL與GLSL着色器做高斯模糊效果的機器人ES 2.0。
- 如果沒有alpha通道,它的工作原理是正確的,但是當我有png的alpha通道時,結果會變得太暗,它將會是相同的鏈接:http://www.jhlabs.com/ip/premultiplied_blur.jpg(中間有一個黑暗的效果)。
- 而所有的文章說使用預乘alpha,但我不知道如何使用它,是同一個人可以幫助我,謝謝。
- 我使用描述了OpenGL與GLSL着色器做高斯模糊效果的機器人ES 2.0。
我該怎麼辦模糊
- 負荷爲png質感
- 創建FBO渲染水平模糊
- 創建FBO呈現垂直模糊
- 渲染結果紋理屏幕
我着色器文件
\t static const char* ULBlurShader_vertexShader =
\t \t "uniform mat4 fpsWorldViewProjectionMatrix;\n"
\t \t "attribute vec4 gInPosition;\n"
\t \t "attribute vec2 gInTex0;\n"
\t \t "varying vec2 varTex0;\n"
\t \t "void main() {\n"
\t \t " \t gl_Position = fpsWorldViewProjectionMatrix * gInPosition;\n"
\t \t " \t varTex0 = gInTex0.xy;\n"
\t \t "}\n";
\t static const char* ULBlurShaderHor_pixelShader =
\t \t "uniform sampler2D sampler0; \n"
\t \t "uniform vec4 fpsGaussBlur; \n"
\t \t "uniform vec4 fpsGaussWeights[65]; \n"
\t \t "varying vec2 varTex0;\n"
\t \t "vec4 gaussBlurHorizontal(const int anRadius,vec2 avBaseCoo, vec2 avSamplerRes)"
\t \t "{ \n"
\t \t " \t float fStartX = avBaseCoo.x - anRadius*avSamplerRes.x; \n"
\t \t " \t vec4 color = vec4(0, 0, 0, 0); \n"
\t \t " \t for (int x = 0; x < anRadius * 2; x++) \n"
\t \t " \t { \n"
\t \t " \t \t color += texture2D(sampler0, vec2(fStartX + x*avSamplerRes.x, avBaseCoo.y))*fpsGaussWeights[x/4][x % 4]; \n"
\t \t " \t } \n"
\t \t " \t return color; \n"
\t \t "}\n"
\t \t "void main() {\n"
\t \t " \t gl_FragColor.rgba = gaussBlurHorizontal(int(fpsGaussBlur.y), varTex0, vec2(fpsGaussBlur.z, fpsGaussBlur.w)); \n"
\t \t "}\n";
\t static const char* ULBlurShaderVert_pixelShader =
\t \t "uniform sampler2D sampler0; \n"
\t \t "uniform vec4 fpsGaussBlur; \n"
\t \t "uniform vec4 fpsGaussWeights[65]; \n"
\t \t "varying vec2 varTex0;\n"
\t \t "vec4 gaussBlurVertical(const int anRadius,vec2 avBaseCoo, vec2 avSamplerRes)"
\t \t "{ \n"
\t \t " \t float fStartY = avBaseCoo.y - (anRadius*avSamplerRes.y); \n"
\t \t " \t vec4 color = vec4(0, 0, 0, 0); \n"
\t \t " \t for(int y=0; y<anRadius*2; y++) \n"
\t \t " \t { \n"
\t \t " \t \t color += texture2D(sampler0, vec2(avBaseCoo.x, fStartY+y*avSamplerRes.y))*fpsGaussWeights[y/4][y%4]; \n"
\t \t " \t } \n"
\t \t " \t return color; \n"
\t \t "}\n"
\t \t "void main() {\n"
\t \t " \t gl_FragColor.rgba = gaussBlurVertical(int(fpsGaussBlur.y), varTex0, vec2(fpsGaussBlur.z, fpsGaussBlur.w));\n"
\t \t "}\n";
你的意思是「其中1/fGamma是在0.0和1.0之間的浮動」?你使用了哪些陰影代碼?我嘗試了對文本模糊進行伽馬校正,但文本仍然不可見 – PhilLab