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

  • Home
  • SEARCH
  • 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 4346530
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:11:08+00:00 2026-05-21T12:11:08+00:00

I have an open GL quad that is rendered with a grayscale gradient. I

  • 0

I have an open GL quad that is rendered with a grayscale gradient. I would like to colorize it by applying a filter, something like:

If color = 0,0,0 then set color to 255,255,255
If color = 0,0,1 then set color to 255,255,254
etc, or some scheme I decide on.

Note the reason I do this in grayscale because the algorithm I’m using was designed to be drawn in grayscale and then colorized since the colors may not be known immediately.

This would be similar to the java LookupOp http://download.oracle.com/javase/6/docs/api/java/awt/image/LookupOp.html.

Is there a way to do this in openGL?

thanks,
Jeff

  • 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-05-21T12:11:08+00:00Added an answer on May 21, 2026 at 12:11 pm

    You could interpret those colours from the grayscale gradient as 1-D texture coordinates and then specify your look-up table as a 1-D texture. This seems to fit your situation.

    Alternatively, you can use a fragment program (shader) to perform arbitrary colour transformations on individual pixels.


    Some more explanation: What is a texture? A texture, conceptually, is some kind of lookup function, with some additional logic on top.

    A 2-D texture is something which for any pair of coordinates (s,t) or (x,y) in the range of [0,0] – [1,1] yields a specific colour (RGB, RGBA, L, whatever). Additionally it has some settings like warping or filtering.
    Underneath, a texture is described by discrete data of a given “density” – perhaps 16×16, perhaps 256×512. The filtering process makes it possible to specify a colour for any real number between [0,0] and [1,1] (by mixing/interpolating neighbouring texels or just taking the nearest one).

    A 1-D texture is identical, except that it maps just a single real value to a colour. Therefore, it can be thought of as a specific type of a “lookup table”. You can consider it equivalent to a 2-D texture based on a 1xN image.

    If you have a grayscale gradient, you may render it directly by treating the gradient value as a colour – or you can treat it as texture coordinates (= indices in the lookup table) and using the 1-D texture for an arbitrary colour space transform.

    You’d just need to translate the gradient values (from 0..255 range) to the [0..1] range of texture indices. I’d recommend something like out = (in+0.5)/256.0. The 0.5 makes for the half-texel offset as we want to point to the middle of a texel (a value inside a texture), not to a corner between 2 values.

    To only have the exact RGB values from lookup table (= 1-D texture), also set the texture filters to GL_NEAREST.

    BTW: Note that if you already need another texture to draw the gradient, then it gets a bit more complicated, because you’d want to treat the values received from one texture as coordinates for another texture – and I believe you’d need pixel shaders for that. Not that shaders are complicated or anything… they are extremely handy when you learn the basics.

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

Sidebar

Related Questions

How do I check that I have an open network connection and can contact
I have several small open-source projects that I wrote. All my attempts to find
I'm looking for a shortcut in vim that would launch chrome/chromium and have it
I have a DIV that slides open to the height of the content, but
In php I have open a .php file and want to evaluate certain lines.
I have an Open Source app and I currently only post the binary for
I have an Open Source app and I have it working on Windows, Linux
Assuming I have an open source web server or proxy I can enhance, let's
One problem I have with open-source is not often the product or documentation, but
Suppose I have an open file. How can I detect when the file is

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.