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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:15:01+00:00 2026-05-28T18:15:01+00:00

Let’s say I have this texture on a polygon: How would I render that

  • 0

Let’s say I have this texture on a polygon:

img

How would I render that polygon and only allow the blue color to shine through and de-saturate the red color? I assume it will require the use of a specifically designed OpenGL shader.

Are there any good examples of this for specific values i.e. if blue > 200 and red < 20 and green < 20 then render that color else, desaturate the color. Would I be manipulating the color buffer?

  • 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-28T18:15:02+00:00Added an answer on May 28, 2026 at 6:15 pm

    Yes you could design a shader and use the fragment shader to do (in pseudo-shader):

    frag()
    {
        float4 color = tex2D(myTexture);
        return float4(0,0,color.b,1);
    }
    

    This will only return the blue color spectrum of your texture. Notice that color values in the fragment shader are always between 0 and 1.

    ANSWER TO QUESTION 1

    It returns the parts of your texture that contain any blue. So in case of your red-blue texture. It will only return the blue parts and the red parts will be black instead. If you would have some kind of mixed texture, you would get a blue tinted texture.

    I realise that you actually don’t want to see the red parts at all. You can do it in different ways. In HLSL, there is a clip function. But I don’t know the GLSL synonym. Another one would be to set the transparency of your texture like so:

    frag()
    {
        float4 color = tex2D(myTexture);
        return float4(color.rgb, color.b);
    }
    

    This will use the blue part of your texture to determine the transparency. Since red has no blue, red will be completely invisible. And blue has 1, so it will be completely visible.

    ANSWER TO QUESTION 2

    If you would have a texture of rock/stone and you would only like to see blue pixels in a range, you should make an if statement. If you want to see the “blue-ness” of the texture, this shader will do the trick.

    If it really is for debugging purposes, it would be better to use the first shader, because it will keep the alpha value to 1. So instead of transparency, you will get black.

    To use only show a range of “blue-ness”, you could combine the if-statement with the color creation described above:

    frag()
    {
        float4 color = tex2D(myTexture);
        float4 result;
    
        if(color.b > 0.2f && color.b < 0.7f)
        {
            result = float4(0,0,color.b,1); // only return the blue part
            // or
            result = float4(color.rgb,1); // return the original color if blue is ok
        }
        else
        {
            result = float4(0,0,0,0); // fully transparent, won't show a thing
        }
    
        return result;
    }
    

    As you can see, it is fairly easy to make these checks. GLSL is the same as C, so you can use your basic programming skills for such statements.

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

Sidebar

Related Questions

Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say that I have a set of relations that looks like this: relations
Let's say that I have classes like this: public class Parent { public int
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.
Let say I have the following desire, to simplify the IConvertible's to allow me
Let's say I have table with column 'URL' whrere I store urls like this

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.