-
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
......
}
-
Senior Member
OpenGL Pro
Re: How to read variables in fragment shader?
Sorry, but your question is unclear. Are you asking how to pass variables from application to shader?
-
Re: How to read variables in fragment 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.
-
Senior Member
OpenGL Pro
Re: How to read variables in fragment shader?
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.
-
Senior Member
OpenGL Pro
Re: How to read variables in fragment shader?
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.
-
Re: How to read variables in fragment shader?
many thanks
-
Re: How to read variables in fragment shader?
maybe you should use pbuffer or fbo to process the texture data
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules