Jump to content

  • Log In with Google      Sign In   
  • Create Account

blending question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 16 May 2013 - 07:42 PM

I am rendering to a 2D texture R32G32B32A32 with blending enabled and the blending adds the value the pixel shader returns to the value that render target already has. 

The question is:

Is there an easy and fast way to make the pixel shader reset the value of the render target texel to float4(0.0f,0.0f,0.0f,0.0f), when a condition inside the pixel shader is true?

without having to copy paste the render target values to a shader resource. or making a ping pong render targets.


Edited by lomateron, 16 May 2013 - 07:43 PM.


Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 16 May 2013 - 07:54 PM

You should be able to use the alpha channel as a sort of mask for both the pixel shader value as well as the value from the render target.  Use the add blend op, but use the D3D10_BLEND_SRC_ALPHA blend mode for both the source and destination.  Then you can set your alpha channel to either be 1.0 (do the additive blend of the pixel shader output and render target contents) or set it to 0.0, which would effectively zero out both the source and destination.

 

I haven't tried this out, but it seems like this could work for you.  That is of course assuming that you don't use the alpha channel already!



#3 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 16 May 2013 - 08:01 PM

Oops I forgot to say that too, I can't use alpha

Any other way?


Edited by lomateron, 16 May 2013 - 08:01 PM.


#4 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 16 May 2013 - 08:33 PM

In that case, I don't think its possible without having a copy of the render target available as a SRV...  I would be happy to see someone come up with a solution, but I don't think you can do it.



#5 Tsus   Members   -  Reputation: 1036

Like
0Likes
Like

Posted 17 May 2013 - 01:24 AM

Hi!

Will your float texture ever contain negative values?

It's not strikingly elegant, but: in case you need to clear a pixel, you could write out a large negative value, giving you after the additive blending something that is smaller than zero.

When you use the texture later, you could clamp the value again up to zero: max(0, texture_color).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS