return value from shader

somewhere seen info on how to return values from shader to program but cannot find now

So question is
how to return values from shader to program or where to look for relevant info?

I’m quite sure that you can’t get infos to your program out of a “shader”,only the opposite is possible with the use of local or environment parameters.

A vertex program takes one vertex as an input and puts out one vertex,nothing less nothing more.Same for a fragment program.It gets one fragment and puts out one fragment (except you kill it in the fp).

glReadPixels it the way to get any information back from the shader.

Originally posted by Humus:
glReadPixels it the way to get any information back from the shader.

maybe my memory tricks me…

but actually it is just as if - I read somewhere some guy developed a trick to return a value from shader ( not a pixels to screen but something like int to a program…)

but OK anyhow the response is usefull - I will try to find another solution to the things I wanted to do… (something with depth comparison
between depth texture and actual depths of objects in depth replace shader code…)

Originally posted by Humus:
glReadPixels it the way to get any information back from the shader.

It sounds like getting data back from shader require special non-trivial setup - one must know where in buffer resulting data will be located. And use of vertex program with such technique become impossible (at general)…
And probably getting result back from shader bad idea as it destroy GPU/CPU parallelism.