Jump to content
  • Advertisement
Mihumihu

WebGL How to get RGB colors from image (with glsl)

Recommended Posts

Posted (edited)

Hi,

I'm trying to solve a problem where I can get all colors from image. 

I see only one: walk through a loop at raster data and collect all bytes, I'm sure there is a better way to get colors from image.  I'm thinking about some sort  of collecting colors in result texture...

Is it ordinary situation, could you help me, I didn find anithing on the internet...

Thanks.

Edited by Mihumihu
grammar mistake

Share this post


Link to post
Share on other sites
Advertisement

Sounds like you're trying to build a color histogram (if I'm not misunderstanding your question :D ). 

Since WebGL doesn't have Compute shaders, retrieving texels on the CPU (using glReadPixels) and building the histogram on the CPU-side is probably the easiest way to solve your problem.

You'll have to iterate each bytes to count how many colors there are in your image in any case.

Share this post


Link to post
Share on other sites
1 hour ago, petitrabbit said:

Sounds like you're trying to build a color histogram (if I'm not misunderstanding your question :D ). 

Since WebGL doesn't have Compute shaders, retrieving texels on the CPU (using glReadPixels) and building the histogram on the CPU-side is probably the easiest way to solve your problem.

You'll have to iterate each bytes to count how many colors there are in your image in any case.

I understand...I d like to speculate towards whole glsl approach

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!