In Pixel shader

Started by
3 comments, last by JohnnyCode 11 years, 7 months ago
Is there a way to know what are the values of the pixel i am gonna render to, inside the pixel shader( ) method, without using a shader resource or effect variable?
Advertisement
Only if you are using the pixel shader with an unordered access view, and not in a render target view. Otherwise, the only way that the pixel value is read by the pipeline is in the output merger before it does the blending function. What type of algorithm are you trying to get set up?
in a 1D texture numObjects X 1, a pixel has the values that determine the position by time of the objecto only in one dimension,
so pixel.x =aceleration | pixel.y=velocity | pixel.z=initial position | pixel.z=mass
Then after some code of doing somethings... I have to modify those variables of an object(that means pixel), so i need to render to a pixel and know what are the values that that pixel had and another pixel of the texture too.
Have you considered keeping the data in a structured buffer, and using the compute shader to do the updating? That might make it easier to work with the data, instead of trying to fit it all to the paradigm of the pixel shader.
textures are often source of data for pixel shaders but the general technique is to bind this data as a texture sampler of the shader that reads them, and generating this data to texture is done by offscreen render target shader in a less recent pass.
If you realy need to have rendering to a target behave on the target content right away, only option I can think of is stencil buffer, but that is rather restricted and in your case it wouldn't apply.

This topic is closed to new replies.

Advertisement