GLSL - Is there really no way to read and write in one go?

Started by
6 comments, last by SuperVGA 13 years, 4 months ago
Hello everyone!

I was thinking, if my fragment shader writes something. Anything, really, is it not possible to use that
in an earlier stage for the next vertex?
I just want to check on the vertex stage for the next vertex, wether something has been drawn in a specific place.
First, i just wanted to use a texture attached to an active fbo, but its not really doable, right?
Advertisement
No not really. You have no way to know or control the order in which which vertices and which pixels get written. Every vertex in your mesh could be executed before the pixel shader executes at all.

There's no such thing as a 'next' vertex, they all go at the same time (or at least as close to the same time as gpu can handle.)

Can you explain what you actually want to do this for?
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Yeah, I'm just trying to decrease overdraw in a call to a single vbo.
My fragment shader is slow, its a raycaster and the vbo contents approximate a surface of my volume.
The order of the vertices doesn't matter, so the next vertex may be anyone.
If there were any kind of linear relationship between vertices/pixels, that would blow away the ability for the GPU to operate in a massively parallel fashion. :P
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Yes. Then it's multiple passes and texture swapping to achieve what i wanted, i guess.
Thanks! :)
Quote:
Yeah, I'm just trying to decrease overdraw in a call to a single vbo.

Then it's multiple passes and texture swapping to achieve what i wanted, i guess.


I hope "wanted" means you are not going to try and implement in a multi-pass as that is even more overdraw.

What are you drawing that has that much over-draw? Single objects shouldnt have hardly any overdraw. A cube has no overdraw, character maybe if the arms overlap the body.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Pass 1 : Depth only render with a simple fragment shader.
Pass 2 : render color and use your complex fragment shader.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Quote:Original post by dpadam450
Quote:
Yeah, I'm just trying to decrease overdraw in a call to a single vbo.

Then it's multiple passes and texture swapping to achieve what i wanted, i guess.


I hope "wanted" means you are not going to try and implement in a multi-pass as that is even more overdraw.

If done correctly, yes it will overdraw as in the fragments being considered, but no if we're talking about actual drawing, if the fragments are discarded by the detection of some depth that are < far.
Quote:Original post by dpadam450
What are you drawing that has that much over-draw? Single objects shouldnt have hardly any overdraw. A cube has no overdraw, character maybe if the arms overlap the body.

Mind you, the fragments take a long time to finish, even though i's just render a cube it is still sort of a naive raycaster.
But as i said earlier, the rendereed stuff is a coarse surface approximation,
take for instance a 3D '+' around a sphere. A little overdraw there.
Quote:Original post by V-man
Pass 1 : Depth only render with a simple fragment shader.
Pass 2 : render color and use your complex fragment shader.

Exactly!

This topic is closed to new replies.

Advertisement