Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:48:23+00:00 2026-06-09T09:48:23+00:00

I have a one big Sprite on the Scene – for example 200×200 and

  • 0

I have a one big Sprite on the Scene – for example 200×200 and in the app i have an array[200][200] in which i store 0 or 1 for each pixel in big sprite.

I want to draw one more textured sprite (for example 10×10) above existing one, but i want to calculate for eache pixel in new sprite if it needs to draw it on this scene depends on provided array (if in corresponding position of the pixel in new sprite in array is ‘1’ – i need to draw this pixel, if ‘0’ – i don’t want to draw it (maybe set alpha = 0)).

I think i can use fragment shader for each of new sprites, but i can’t understand how to provide array data to the shader to calculate color for each pixel.
I think also can use fragment shader for the whole scene (if render to texture).

I am quite new in opengl and can’t figure out in what way to move.

When i create resources for the scene – i try to create my mask:

    mask = new float[512*512*4];
    for (int i = 0; i < mask.length; i++)
    {
        mask[i] = 2f;
    }

    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 1029384756);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 1, GLES20.GL_RGBA, 512, 512, 0, GLES20.GL_RGBA, GLES20.GL_FLOAT, FloatBuffer.wrap(mask));
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

Then when i draw new item on scene i use shader:

    setShaderProgram(ShaderProgram.getInstance());

    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glUniform1i(RadialBlurExample.RadialBlurShaderProgram.sUniformMask, GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 1029384756);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

But i can’t see new item on scene (maskVal is <0.5).

I try to find working way to pass array as a texture but i can’t find it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:48:24+00:00Added an answer on June 9, 2026 at 9:48 am

    Upload your array as a second texture with the same dimensions as the sprite, and then when you draw the sprite, sample the second texture at the same texcoord.

    If the second texture doesn’t meet the mask criteria, discard the fragment

    uniform sampler2d sprite;
    uniform sampler2d mask;
    in vec2 uv;
    main() {
    
       float maskVal = texture2D(mask, uv).r;
       if(maskVal > 0.5) {
            gl_FragColor = texture2D(sprite,uv);
       } else {
            discard;
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an automatically generated regular expression, which basically is one big or group
I have big dataset (but the following is small one for example). I can
I have one BIG table(90k rows, size cca 60mb) which holds info about free
I am developing an animation app in the android. i have one big image
I have one big batch script which sets bunch of environment variables. I want
I have one big LinearLayout(vertical)(outer table) and three small linear layouts(horizontal)(one for each row).
I have one big SimpleLayoutPanel which is located in RootLayoutPanel.get() and this is a
I have one big buffer image. I want to create another buffer image with
Memcached is a great scalable cache layer but it have one big problem (for
Rather than have everything in one big dialog, I'm looking at being able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.