GSL

Started by
6 comments, last by dickymoe 18 years, 4 months ago
Hello, to start : sorry for my english !! I would like read the backbuffer with the shading language (GLSL), but i find no subject, tutorial to do that... Some people can help me ?
Advertisement
The shading language is designed to write pixel shaders and vertex shaders with. If you want to do some post-proccesing effects, render to a texture and than manipulate the texture with pixel shaders.
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Yes, but it's slowly...

For exemple, if I use the fonction : glReadBuffer, this one get data of the Video Ram to the Ram... That it slow... And stupid to do : Video Ram <-> Ram <-> Texture in video ram

I would like use GLSL to process my data, it is logical because the backbuffer is in the video card...

You are no ok with me ?
Have you tried to use a framebuffer object? This saves you the expensive copy.
There is no other way to read from the frame buffer.
--
I don't no the framebuffer... And im beginning GLSL !!

In fact i would like do, the blend function like photoshop... To do that I need the color of current pixel and back color pixel !!

I will try to look to the frame buffer.

Thanks you...

If another people have idea...
You are right, glReadPixels() is quite slow. What you want to look into is "render to texture," and/or the "framebuffer object;" you should be able to find plenty of results if you Google for one phrase or the other.

Pixel shaders are designed to output fragment values to the final stage of the pipeline -- they are not, themselves, the final write stage. You cannot use them (alone) to provide precise blending control -- they cannot read back from the current framebuffer, although they can read from textures so thats how you can get around that to some extent. You can render to texture and bind that texture without incurring a CPU readback (and thus, without incurring the massive pipeline stall).
You should use a Frame Buffer Object (ATI has a paper included in their oktober SDK, or see the other thread on these forums) to render the original image, then post-process it as a texture with your pixel shader.

For systems which do not support FBO's, you must unfortunately fall-back to p-buffers, which are kinda annoying as you will need an additional context for it, etc (but is works).

Crafter 2D: the open source 2D game framework

?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]

I look the documentation aabout framebuffer !!

It's a good way...

Thanks you

This topic is closed to new replies.

Advertisement