Android的GLES20.glBlendEquation不工作?工作、Android、glBlendEquation

2023-09-07 10:41:51 作者:再look就把你吃掉

我一直试图与深度和法线贴图纹理几个星期2.5D引擎现在,没有什么不同这里使用最新的的Linky 。思维的深度图在图中从纹理片段着色器后是不可能的,由于ES 2.0缺少gl_fragDepth可变我发现的教程的iOS那里他们使用glBlendEquation用模式GL_MIN / GL_MAX为假的深度片段的缓冲到帧缓存,纹理Linky. Unfortunely GLES20.glBlendEquation使得与UnsupportedOperationException异常在我的两个手机的应用程序崩溃(SGS 1/2)。所以,我想知道是否有人使用此功能,任何成功的? GL_MIN / GL_MAX似乎也从Android的OpenGL ES 2.0规范,以便即时通讯大概是出于运气在这里失踪? 任何想法?

Ive been trying to make a 2.5D engine with depth and normal map textures for a few weeks now, not unlike whats used here Linky. After thinking the drawing of a depth map in the fragment shader from a texture was impossible due to ES 2.0 missing the gl_fragDepth variable I found a tutorial for iOS where they used glBlendEquation with the mode GL_MIN/GL_MAX to "fake" depth buffering of the fragment to a framebuffer-texture Linky. Unfortunely GLES20.glBlendEquation makes the application crash on both my phones (SGS 1/2) with UnsupportedOperationException. So Im wondering if anyone has used this function to any success? GL_MIN/GL_MAX also seems to be missing from the Android Opengl ES 2.0 spec so Im probably out of luck here... Any ideas?

BTW它似乎使用片段着色器的法线贴图这不会工作,从我面前GL11Ext但因为即时通讯工作。

BTW It does seem to work in GL11Ext but since Im using the fragment shader for normal mapping this wont work from me.

推荐答案

我在尝试对我的维加片(Tegra的),而这个工作对我来说:

i was experimenting on my Vega tablet (Tegra) and this worked for me:

片段着色器:

#extension GL_NV_shader_framebuffer_fetch : require 
// makes gl_LastFragColor accessible

precision highp float;

varying vec2 v_texcoord;

uniform sampler2D n_sampler;

void main()
{
    vec4 v_tex = texture2D(n_sampler, v_texcoord);
    gl_FragColor = min(gl_LastFragColor, v_tex); // MIN blending
}

pretty的容易,是吧?但恐怕这将是NV-只。

Pretty easy, huh? But i'm afraid this will be NV-only.