Sign in to follow this  
bene81

Fullscreen Texture

Recommended Posts

Hello, I think a really simple question for the image processing experts: I have a floating point texture and want to sum up all the values (integration). My Idea is to let the texture fill the whole screen and to sum the calculated fragment in uniform variable which is later read back. What is the exact way to create an equality between texel and pixel ? ThanX!

Share this post


Link to post
Share on other sites
Quote:
to sum the calculated fragment in uniform variable

Aren't they read only?

What kind of 3D card do you have?
If it can do GL_SGIS_generate_mipmaps for the FP textures, then you just need to read and scale the values from the lowest level.
(In case of not 2n texture you will have to prefill outer area with 0.)

Another option would be to draw this texture into FP buffer and use blending (maybe with texture filtering) to sum the values.
Then read the accumulated values back into the texture and repeat this process until it all summed up.

Share this post


Link to post
Share on other sites
From your answer, I think I my question may not be clear.

I want to show the texture as an image, filling the whole screen. I assume that the texture width has the width of the fbo. So a texel could match a pixel.

Uniforms are r/w, attributes are r/o.

I have an ATI Radeon 1950 Pro, supports auto creation of mipmaps, but this is not necessary. I used it and it has huge performance faults.

I draw the texture into an fp buffer, but blending is not necessary, I only want to show the whole texture filling the whole screen, 2D -> 2D, 256tx -> 256px

I think that than a fragment in the fragment shader corresponds to a pixel (I do not change depth value), so I can sum up the value.

Or are there any other possibilites to do this ??

Share this post


Link to post
Share on other sites
Quote:
Uniforms are r/w
Really? In the shaders?
Since when? [rolleyes]

There is no way to have global variable R/W from the shaders.
It will require serious locks (critical sections) to ensure consistent state when say 64 shader units will try to access such variable simultaneously.
I'm not even talking about multi-GPU configurations...

btw, you may find this useful:
OpenGL Shading Language (GLSL) Quick Reference Guide

Quote:
I have an ATI Radeon 1950 Pro, supports auto creation of mipmaps, but this is not necessary. I used it and it has huge performance faults.
Actually, normally it's quite fast.
That is, if the texture sizes are power of 2.
On the other hand, that's how they must be for the summation trick to work.

Share this post


Link to post
Share on other sites
Downsample texture.
For example: you have 256x256 texture. Draw rectangle to 128x128 texture, sampling four neighbour texels from source texture, sum their values, and output result to destination texture. In next step, do the same for 64x64 ([edited] use generated 128x128 texture as 'source texture'[/edited]), and so on. So when you will finish with 1x1, it will contain sum of all texels from first texture.

There is nothing writable from fragment shader but color output (or multiple color outputs in "multiple draw buffers" case).

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