Hello,
I have started playing around with ROV and order independent transparency.
I have a very simple app with two transparent triangles intersecting.
The documentation does not mention anything how you could specify the ordering for them: either back-to-front or front-to-back.
I thought that I should be able to figure this out from the rendered result. So I am overwriting always ROV with the last received color in pixel shader.
struct PSInput
{
float4 screenSpacePos : SV_Position;
float4 color : COLOR;
};
RasterizerOrderedTexture2D<float4> BlendTexture : register(u0);
void Main(PSInput input)
{
int2 texCoord = int2(input.screenSpacePos.xy);
BlendTexture[texCoord] = input.color;
}
I specify the data for two triangles in one vertex buffer and then render them with one draw call.
Thr red triangle goes first and the blue triangle after.
struct Vertex
{
Vector4f position;
Vector4f color;
};
const Vertex vertices[] =
{
// Red triangle
{Vector4f( 0.5f, 0.75f, 0.8f, 1.0f), Vector4f(1.0f, 0.0f, 0.0f, 1.0f)},
{Vector4f( 0.5f, -0.75f, 0.8f, 1.0f), Vector4f(1.0f, 0.0f, 0.0f, 1.0f)},
{Vector4f(-0.4f, 0.0f, 0.2f, 1.0f), Vector4f(1.0f, 0.0f, 0.0f, 1.0f)},
// Blue triangle
{Vector4f(-0.5f, 0.75f, 0.8f, 1.0f), Vector4f(0.0f, 0.0f, 1.0f, 1.0f)},
{Vector4f( 0.4f, 0.0f, 0.2f, 1.0f), Vector4f(0.0f, 0.0f, 1.0f, 1.0f)},
{Vector4f(-0.5f, -0.75f, 0.8f, 1.0f), Vector4f(0.0f, 0.0f, 1.0f, 1.0f)},
};
In the result below, you can see that the red triangle indeed was rendered first and the blue triangle after.
I expect the blue triangle to be overwritten by red triangle as it is located closer to the viewer for some parts. However, this does not happen.
I was assuming pixel sync to work in a similar fashion as it works with per-pixel lists for OIT.
It seems that ROV only ensures that primitives are rendered in the order they are submitted in, not in the order of pixels as if they are in a per-pixel list.
MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/dn914601(v=vs.85).aspx) states that
The order in which overlapping ROV accesses of pixel shader invocations are executed is identical to the order in which the geometry is submitted
I would like to ask you these questions:
1. How do we specify the ordering for ROV?
2. Is the ordering on per-primitive or per-pixel level (like with per-pixel lists for OIT)?
Many thanks