English 中文(简体)
GLSL两种文本中的FragColor数值
原标题:Alternate gl_FragColor values from two textures in GLSL

我有两种文字,即云层和山丘,每块面积512×512,并打算造一个冰川——FragColor输出,从以前的文字中获取六分数。 在本案中,想从第1版图中第1版图中获取第1版图,即第1版图中第1版图,第2版图中第2版图中第2版图中第2版图中第2版图中第1版图,第3版图中第3版图中第3版图形中第3版,第1版正文中第3页。 这里是我的碎裂的法典:

 uniform sampler2D tex0;
 uniform sampler2D tex1;

 void main() {
     vec4 cloud = texture2D(tex0, gl_TexCoord[0].st);
     vec4 hill = texture2D(tex1, gl_TexCoord[0].st);
     for (int i=0;i<512;i++) {
       for (int j=0;j<512;j++) {
            if ( j%2 == 0)
                gl_FragColor =  cloud;
            else
                gl_FragColor =  hill;
          }
     }
  }

这里设立的文本单位:

t1 = loadTexture("pY.raw", 512, 512);
t2 = loadTexture("pZ.raw", 512, 512);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, t2);
glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, t1);
glEnable(GL_TEXTURE_2D);

And here is the uniform setup: glUseProgram(program);

GLuint t1Location = glGetUniformLocation(program, "tex0");
GLuint t2Location = glGetUniformLocation(program, "tex1");

glUniform1i(t1Location, 0);
glUniform1i(t2Location, 1);

问题在于,该方案的产出只是山丘,而不知道如何解决这一问题。 任何建议?

最佳回答

你们不需要在你身上做任何 it。 将要求每个钢材在你标的中一台。 相反,利用冰川获得目前的文本坐标。 你们的法典应当看一看:

uniform sampler2D tex0;
uniform sampler2D tex1;

void main()
{
    vec4 cloud = texture2D(tex0, gl_TexCoord[0].st);
    vec4 hill = texture2D(tex1, gl_TexCoord[0].st);

    if ( int(gl_TexCoord[0].x*512)%2 == 0)
        gl_FragColor =  cloud;
    else
        gl_FragColor =  hill;

    }
}

即便是年长的公开性,也应努力:

#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D tex0;
uniform sampler2D tex1;

void main(void)
{

    if((gl_FragCoord/32.0- vec4(ivec4(gl_FragCoord/32.0))).x<0.5)
        gl_FragColor = texture2D(tex0, gl_FragCoord.xy/512.0);
    else
        gl_FragColor = texture2D(tex1, gl_FragCoord.xy/512.0);
}

http://www.iquilezles.org/apps/shadertoy/“rel=“nofollow”http://www.iquilezles.org/apps/shadertoy/

问题回答

暂无回答




相关问题
OpenGL 3D Selection

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it ...

CVDisplayLink instead of NSTimer

I have started to implement cvDisplayLink to drive the render loop instead of nstimer, as detailed in this technical note https://developer.apple.com/library/archive/qa/qa1385/_index.html Is it ...

Can the iPhone simulator handle PVR textures?

I have a really weird problem with PVR textures on the iPhone simulator- the framerate falls through the floor on the iPhone simulator, but on the iPhone itself it works just fine. Has anyone had any ...

Calculate fps (frames per second) for iphone app

I am using an opengl es iphone application. What is the most accurate way to calculate the frames per second of my application for performance tuning?

Java - Zoom / 3D Data Visualization Libraries

What are the best libraries/frameworks for doing 3D and/or Zoom interfaces in Java? I d like to be able to do some prototyping of creating new types of interfaces for navigating within data and ...

FLTK in Cygwin using Eclipse (Linking errors)

I have this assignment due that requires the usage of FLTK. The code is given to us and it should compile straight off of the bat, but I am having linking errors and do not know which other libraries ...

热门标签