View Full Version : Color mapping texture pixel values
10-22-2008, 01:28 PM
I am looking to alter the way my images are displayed by putting a clamp on the color values. By that I mean cause all pixel values below the lower clamp to display as 0.0, all pixel values above the upper clamp to display as 1.0, and all values between the clamps be linearly mapped from 0.0 to 1.0.
Previously I was displaying my image using glDrawPixels and solving the clamping problem by using glPixelMap and creating a color map that specified the desired values. However, I am now using textures to display my image and glPixelMap doesn't work.
How can I solve this problem?
Oh, and I can't alter the image data.
10-22-2008, 01:32 PM
Fragment shaders. As simple as that.
10-22-2008, 03:31 PM
How hard is it to write a fragment shader, I've never written one before?
10-22-2008, 03:43 PM
Not really hard. :) You have to keep in mind you need GL >= 1.4-compliant hardware for GLSL support, though. A very good tutorial can be found at Lighthouse3D (http://www.lighthouse3d.com/opengl/glsl/index.php?intro). You don't really need to read through the Pipeline section, but it's better if you do as it gives you the big picture of fragment and vertex processing.
10-22-2008, 03:44 PM
look at lighthouse3D GLSL tutorial (http://www.lighthouse3d.com/opengl/glsl). This one is perfect to start with shaders. It would not be difficult for your purpose.
10-23-2008, 03:20 PM
Ok so I've been attempting the fragment shader. I got to the point where, after much time spent just figuring out this whole shader thing, I had code that I would try to run. However, I am getting a NullReferenceException on Gl.glCreateShaderObjectARB(Gl.GL_FRAGMENT_SHADER_A RB).
So I checked Gl.glGetString(Gl.GL_EXTENSIONS) for GL_ARB_fragment_shader and it isn't there. I do have GL_ARB_fragment_program though.
My graphics hardware has ogl 1.4.
Does this mean I can't use fragment shaders? If so, then I'm still lost as to how to solve my problem.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.