6 replies to this topic
#1 Members - Reputation: 230
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.
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 Members - Reputation: 806
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!
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!
Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)
#4 Members - Reputation: 806
Posted 09 September 2012 - 02:06 PM
Hi!
Best regards
Yes, that's correct!what happens there?
Op=(-3,5,1)?
Best regards
Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)
#5 Members - Reputation: 230
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.
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 Members - Reputation: 806
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:
Best regards!
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!
Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)
#7 Members - Reputation: 1184
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.
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.






