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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:16:57+00:00 2026-05-30T05:16:57+00:00

Im trying to create a fragment shader that will do the same job as

  • 0

Im trying to create a fragment shader that will do the same job as the photoshop levels output slider. I would like to do this on a specific channel (in this case blue).

I have the code as below:

varying highp vec2 textureCoordinate;

uniform sampler2D inputImageTexture;

#define GammaCorrection(color, gamma)       pow(color, vec3(1.0/gamma))

#define LevelsControlOutputRange(color, minOutput, maxOutput) mix(vec3(minOutput/255), vec3(maxOutput/255), color)


void main()
{

     lowp vec4 texel = texture2D(inputImageTexture, textureCoordinate);

     lowp vec3 outputColor;
     outputColor.rgb = texel.rgb;

     lowp vec3 pass3 = LevelsControlOutputRange(outputColor,200,255); 

     lowp vec4 pass4;
     pass4.r = outputColor.r;
     pass4.g = outputColor.g;
     pass4.b = pass3.b;

 gl_FragColor = pass4;


}

This has no effect on the resulting image so i think that i may have to do more with the line:

pass4.b = pass3.b;

Could anyone help point me in the right direction?

Thanks

  • 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-30T05:16:59+00:00Added an answer on May 30, 2026 at 5:16 am

    mix takes a value between 0…1 as the mixing parameter. Your 255 will be clamped to 1 and therefore you’ll always get the max output value. In a similar fashion texture values are in the range 0…1 to you must not divide by 255 to get into some range! BTW: Simply dividing by 255 is not correct – details here http://kaba.hilvi.org/programming/range/index.htm

    • 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 list fragment activity like this : public class FluxListeFragment
Trying to create my first iPhone app that would play back audio. When I
I'm trying to create a wireframe vertex/fragment shader in Unity. It seems possible according
I'm trying to create a music player that will be visible in all my
I'm trying to create super simple Perlin noise clouds in a fragment shader, using
I'm trying to create a small html fragment (a div element) consisted of three
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a small monitor application that displays current internet usage as percentage
I am trying to create an application for tablets that has a main screen
I'm trying to create a UniqueAttribute using the System.ComponentModel.DataAnnotations.ValidationAttribute I want this to be

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.