Sign in to follow this  

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

This topic is 2567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

This topic is 2567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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