Sign in to follow this  
nadro

OpenGL How Can I write to application values from GLSL Shader?

Recommended Posts

Hi. For Graphic Render I use Irrlicht in OpenGL and GLSL support. How Can I write values from pixel shader to my application buffor or outside file. I need use 2 shaders to calculating more than 3 per pixel lighting. I planning calculate gl_FragColor in first shader, next write this value to application and in second shader download this value and using in calculating colour example: OutColor = curColor + prevglfragcolor; gl_FragColor = OutColor; How Can I do it?

Share this post


Link to post
Share on other sites
You can't, as far as I know. You would have to render to a texture, then extract the values you need from the texture.

ADDED: I just read your post closer, and realized that you didn't actually want to access the data in your program, only in the second shader program.... you would render to a texture and utilize that texture in your next pass.

Share this post


Link to post
Share on other sites
Quote:

You can't, as far as I know.

This is correct; uniforms and constants and their counterparts in other languages are are one-way. As you said, the only way to preserve data for later access, by another shader program or the CPU, is to render to a texture.

Share this post


Link to post
Share on other sites
OK. I have one pass in texture, I add shader to node and have two pass in texture2. How Can I split this "screens/textures"? Can I please source code?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this