• Advertisement
Sign in to follow this  

Pixel processing question - kill/discard a pixel

This topic is 1433 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. Can you please explain me how pixel processing works in this cases:

1. I have a texture with data (some color after clear or some data after previous pass) and I'm processing a pixel which already have some data. If I discard that pixel - what will happen? Will the existing data stay or it will be gone?

2. I have a pixel which will be processed several times in render pass. If first process is successful and in the next one discard will be called - will the data from first draw stay or it will be discarded too? Will the next calls process that pixel or after killing it all subsequent drawings will be killed too?

3. What is the best way to not to change a data in texture. Say, I have some condition - if it's true I'll write new data. If false - I want to keep an old data.

Share this post


Link to post
Share on other sites
Advertisement

1. I have a texture with data (some color after clear or some data after previous pass) and I'm processing a pixel which already have some data. If I discard that pixel - what will happen? Will the existing data stay or it will be gone?

A pixel is just a small memory block. It contains some data. A pixel-shader have an input and output and some processing in between. If you discard the pixel in the shader, then the shader output (=pixel) will not be writen to the memory block. That means, the previous pixel content is still there.

 

 

 


2. I have a pixel which will be processed several times in render pass. If first process is successful and in the next one discard will be called - will the data from first draw stay or it will be discarded too? Will the next calls process that pixel or after killing it all subsequent drawings will be killed too?

See above, it will stay.

 

 

 


3. What is the best way to not to change a data in texture. Say, I have some condition - if it's true I'll write new data. If false - I want to keep an old data.
 

There are several ways and the best way depends on the concrete situation. Eg you can discard it in the shader, you can utilize the z-buffer, alpha mask or stencil mask. All of these methods are really useful, but which to use depends on the effect you want to archive.

Edited by Ashaman73

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement