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 8203987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:44:56+00:00 2026-06-07T07:44:56+00:00

I am trying to create a scrolling list in OpenGL ES 2.0 on Android

  • 0

I am trying to create a scrolling list in OpenGL ES 2.0 on Android and I want the contents of my list to fade out as the list reaches the top or bottom. Right now I am implementing this in a fragment shader but it is very slow.

Here is my shader

precision mediump float;

uniform bool uEnableTexture;
uniform sampler2D uTexture;
uniform bool uEnableFade;
uniform float uTopFade;
uniform float uBottomFade;
uniform float uFadeWidth;

varying vec4 vPosition;
varying vec2 vTexCoord;
varying vec4 vColor;

void main(){
    if (uEnableTexture) {
        gl_FragColor = texture2D(uTexture, vTexCoord) * vColor;
    } else {
        gl_FragColor = vColor;
    }

    if (uEnableFade) {
        if (vPosition.y > uTopFade) {
            gl_FragColor = gl_FragColor * 0.0;
        } else if (vPosition.y > uTopFade - uFadeWidth) {
            gl_FragColor = gl_FragColor * (1.0 - (vPosition.y - (uTopFade - uFadeWidth)) / uFadeWidth);
        } else if (vPosition.y < uBottomFade) {
            gl_FragColor = gl_FragColor * 0.0;
        } else if (vPosition.y < uBottomFade + uFadeWidth) {
            gl_FragColor = gl_FragColor * (1.0 + (vPosition.y - (uBottomFade + uFadeWidth)) / uFadeWidth);
        }
    }
}

This is the effect I am trying to achieve.
Effect screenshot

Is there a more efficient way to achieve this?

EDIT: I was able to improve this a lot by using separate programs and using this shader only when I needed the fade.

void main(){
    gl_FragColor = texture2D(uTexture, vTexCoord) * vColor;

    if (vPosition.y > uTopFade - uFadeWidth) {
        gl_FragColor = gl_FragColor * (1.0 - (vPosition.y - (uTopFade - uFadeWidth)) / uFadeWidth);
    } if (vPosition.y < uBottomFade + uFadeWidth) {
        gl_FragColor = gl_FragColor * (1.0 + (vPosition.y - (uBottomFade + uFadeWidth)) / uFadeWidth);
    }
}

I could probably speed it up a little more by splitting this into two more shaders, one for the top and one for the bottom, or use uFadeWidth to determine the direction.

  • 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-07T07:44:57+00:00Added an answer on June 7, 2026 at 7:44 am

    Your best bet would probably not to do the math in shader, but to precompute a ‘fade texture’ that would be 1 pixel wide, and as ‘tall’ as your viewport.

    In this texture, you could store the fade value for every screen y.

    Then, in your shader, you’d be left with another texture2D call, and a multiply.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a endlessly scrolling bitmap background. I want to make it
I am trying to create a horizontally scrolling page and I want the page
im trying to create a horizontal scrolling box to create a timeline effect... but
I am trying to create a MainScreen with vertical scrolling. From what I've read
I'm trying to create a animation by scrolling the page, something like this: $(function()
I am trying to create a modular html document that employs smooth scrolling. If
I am trying to create an app with horizontal scrolling, so that one would
I want to create a RichTextField at the bottom half of the screen, while
I'm try to create a fast scrolling list using the creator of Tweetie, Loren
I'm trying to create a fade in effect using jQuery, html & CSS with

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.