PDA

View Full Version : How to read variables in fragment shader?



R@y
09-20-2006, 03:33 AM
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

......
}

k_szczech
09-20-2006, 04:08 AM
Sorry, but your question is unclear. Are you asking how to pass variables from application to shader?

R@y
09-20-2006, 04:42 AM
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.

k_szczech
09-20-2006, 04:47 AM
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.

k_szczech
09-20-2006, 04:54 AM
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.

R@y
09-20-2006, 05:01 AM
many thanks :)

Jedimaster
09-27-2006, 09:21 PM
maybe you should use pbuffer or fbo to process the texture data