片段着色器中是否存在问题

时间:2018-12-23 14:28:44

标签: android opengl-es-2.0

片段着色器中的代码是:

           "precision mediump float;\n" +
                "varying vec2 vTextureCoord;\n" +
                "uniform sampler2D sTexture;\n" +
                "uniform float Opacity;\n"  + // range 0.0 to 1.0
                "void main() {\n" +
                "    gl_FragColor = texture2D(sTexture, vTextureCoord);\n"+
                "    gl_FragColor.a *= Opacity;\n" +
                "}\n";

可行,我尝试在其中添加if

        "precision mediump float;\n" +
                "varying vec2 vTextureCoord;\n" +
                "uniform sampler2D sTexture;\n" +
                "uniform float Opacity;\n"  + // range 0.0 to 1.0
                "void main() {\n" +
                "    gl_FragColor = texture2D(sTexture, vTextureCoord);\n"+
                "    gl_FragColor.a *= Opacity;\n" +

                "    if(gl_FragColor.a < 250){;\n" +
                "         gl_FragColor.a = 250;\n" +
                "    }\n" +

                "}\n";

它不起作用,我无法弄清楚这一点,我将不胜感激

0 个答案:

没有答案
相关问题