Jump to content

  • Log In with Google      Sign In   
  • Create Account

blend states 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
6 replies to this topic

#1 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 08 September 2012 - 09:36 PM

In this operation
OutputPixel = ( Sr.rgba * Sr.aaaa ) ADD ( De.rgba * (1,1,1,1) )
Does the OutputPixel values rgba will be, lets say:

Sr.r = 30.0f
Sr.a = -4.0f
De.r=3.0f

so
OutputPixel.r = (30*-4)+(3*1) = -117.0f
Is that the real output value or the values will be in some way converted to the rage from 0 to 1.

Sponsor:

#2 Tsus   Members   -  Reputation: 1036

Like
0Likes
Like

Posted 09 September 2012 - 03:52 AM

Hi lomateron!

It all depends on the formats of the textures.
For shaders and blending operations the values from the textures are first converted to floats, then comes the operation (or shader code) and then they are converted to the output format.

If you have DXGI_RGBA8_UNORM for instance, the 8 bits in the input slots (0..255) are converted to a float by scaling to 0.0f..1.0f (e.g. 127 is mapped to about 0.5f). If DXGI_RGBA8_UNORM is the output format it is the other way around. A 0.5f would be mapped to 127. (Note that the next shader or blending operation would read it as a 0.5f, again.) Besides, the input and output floats are always clamped to 0.0f and 1.0f. An operation like yours wouldn't be possible, since the input and output values would both be clamped.

If you would use a float texture, e.g. DXGI_R32G32B32A32_FLOAT, no conversion is necessary, thus the value 123.0f would still be 123.0f in the shader or blending operation. In that case, nothing is clamped. This means, any float value is possible for input and output!
Having said that, you would need a float format for your input and output textures and for your given sample values the operation should work just fine.

Best regards!

#3 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 09 September 2012 - 12:35 PM

Another question
Sr=(-3,6,1)
De=(-1,5,1)

Op=( Sr.rgb) MIN ( De.rgb)

what happens there?
Op=(-3,5,1)?

Edited by lomateron, 09 September 2012 - 12:37 PM.


#4 Tsus   Members   -  Reputation: 1036

Like
0Likes
Like

Posted 09 September 2012 - 02:06 PM

Hi!

what happens there?
Op=(-3,5,1)?

Yes, that's correct!

Best regards

#5 lomateron   Members   -  Reputation: 342

Like
0Likes
Like

Posted 10 September 2012 - 05:03 PM

thinking on this but Cant find a way using the blending to make this:
when rendering to a pixel, when the pixel shader returns a float4 pix and
pix.w != 0 replace the pixel rendering to with pix
pix.w = 0 leave the pixel rendering to the same.

the pixel values arent used for displaying colors, they are vectors.

Edited by lomateron, 10 September 2012 - 05:08 PM.


#6 Tsus   Members   -  Reputation: 1036

Like
0Likes
Like

Posted 11 September 2012 - 02:57 AM

Hi!

I think this is not possible with the blend state alone.
The easiest way to achieve it would be to write a pixel shader. The following line would do the trick:
clip( input.color.a == 0 ? -1 : 1);
Clip discards a pixel if the argument is negative.

Best regards!

#7 eppo   Crossbones+   -  Reputation: 2459

Like
0Likes
Like

Posted 11 September 2012 - 09:02 AM

Under Direct3D 9 you can use fixed function alpha testing to skip pix.w == 0 pixels.
D3D10 and up require you to emulate this functionality by either outputting a zero alpha value or discard()-ing (don't use discard if you don't need to) the pixel.




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