How to read variables in fragment shader?

For example, depending on the variable A, an program will continue or stop by the end of every pass.

float4 main(…)
{

IF Condition
Change A


}

Sorry, but your question is unclear. Are you asking how to pass variables from application to shader?

Sorry, it was my fault.

I am writing a seed filling algorithm on GPU, and need passing some variables from shader to application. These variables will be used to change the application running: to continue to filling, to generate new seed and start new round seed filling or to stop the application.

Ok, actually you can’t pass variables from shader to application.
The only output of your shader are pixels (color, depth and indirectly stencil). So, your shader should draw a pixel, and application should read it using glReadPixels.
You could also use occlusion query to count pixels that were drawn if you need such information.

And one more thing - I don’t think that using GPU for seed fill is a good idea. The nature of this algorithm is too far away from the way GPU’s work. Seed fill is recursive/scatter and GPU’s are parallel/gather.

many thanks :slight_smile:

maybe you should use pbuffer or fbo to process the texture data

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.