Re: Texture colour wrapping

Dirk Reiners <[email protected]>
Newsgroups gmane.comp.python.opengl.user
Message-ID <[email protected]>
	Hi Brice,

On 11/07/2011 01:45 PM, Brice Thurin wrote:
> Thanks a lot for the example. It helps me quite a bit however I am not sure how
> to do what I wish to do. I attached to this email an example of what i would
> like to do.
> On the left hand side is my original phase map data on a polar grid. I want to
> make a polar to cartesian transformation of this phase map so it looks like the
> middle plot in the figure attached, here the phase map is on a cartesian grid.
> For this two first figures the grayscale cover -5 to 25 radians. Finally I want
> to wrap the phase data so the maximum grayscale value is max 6.28 radians.
>
>
> I managed to do the first step (polar to cartesian) using quad strip and texture
> mapping but i am not sure how I can get the vertex value from the middle stage
> map as it is already a texture. I am certainly missing something but I can not
> see what.

ah, that's a different story. If you only have the input data as an image my 
example won't work.

Three options:

1) Do the color mapping on the image. Just create a texture that has the same 
size as your input image, and do a pixel by pixel mapping from your input data 
to whatever output you want. Use the new image instead of the old one. This work 
ok if the data doesn't change.

2) Turn it into geometry. Create your quad strip vertices so that each pixel in 
the input image has a vertex. Assign the input data as a texture coordinate to 
that vertex. Then use my original example to do the mapping.

3) Use a shader. If 1 or 2 are no options, you can use a shader to do the color 
mapping. It would be a fairly simple fragment shader (look at 
PyOpenGL-Demo/proesch/shaderProg/textureShader.py for a basic example how to do 
shaders) that gets the data from the input image and then uses the read data 
value as the texture coordinate for the lookup table.


Hope it helps

	Dirk




------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.