What you are looking at is just a single 8x8 textured quad drawn multiple times on a non-overlapping grid, the original texture source is a 2 pixel wide vertical line. The artifacts only appear when scaling up (resizing the render target), and each time I resize the ticks sort of randomly appear and disappear. Perhaps significant, the artifacts seem to always appear at where the quads adjoin each other.
Multisampling is off, not using depth or alpha blending. Vertices in the Pre-vs mesh look correct.
The strangeness starts when I debug one of the culprit pixels with PIX - it reports the pixel shader ouput and framebuffer as 1,1,1,1 which is what I am seeing on the screen. But, when I debug pixel & step through the actual shader, the output shows 0,0,0,1 (which would be what I want to see on the screen). I do not understand what could happen between the pixel shader output and the framebuffer that can change the color of the pixel.
To add to the strangeness, I cannot reproduce the issue on a different computer. I've updated my drivers on my development machine to the latest, no change. My best guess at this point is that I am doing something a bit off that is compounded by a particular quirk of my GPU (Nvidia, btw).
Here is some code (using SharpDX, Direct3D11):
Swapchain and Rasterizer options:
swapDesc = new SwapChainDescription()
{
ModeDescription = new ModeDescription(ParentForm.ClientSize.Width,
ParentForm.ClientSize.Height,
new Rational(60, 1), Format.R8G8B8A8_UNorm),
SampleDescription = MultiSampling,
Usage = Usage.RenderTargetOutput,
BufferCount = 1,
OutputHandle = ParentForm.Handle,
IsWindowed = true,
SwapEffect = SwapEffect.Discard,
Flags = SwapChainFlags.None
};
var rasterDesc = new RasterizerStateDescription()
{
IsAntialiasedLineEnabled = false,
CullMode = CullMode.None,
DepthBias = 0,
DepthBiasClamp = 0.0f,
IsDepthClipEnabled = false,
FillMode = FillMode.Solid,
IsFrontCounterClockwise = false,
IsMultisampleEnabled = enableMultiSample,
IsScissorEnabled = false,
SlopeScaledDepthBias = 0.0f
};
This gets called when the window is resized, width and height are directly from Form.ClientSize:
renderTargetView.Dispose();
swapChain.ResizeBuffers(1, width,
height,
Format.R8G8B8A8_UNorm, SwapChainFlags.None);
using (Texture2D backBuffer = swapChain.GetBackBuffer<Texture2D>(0))
{
renderTargetView = ToDispose(new RenderTargetView(device, backBuffer));
}
device.ImmediateContext.OutputMerger.SetTargets(renderTargetView);
device.ImmediateContext.Rasterizer.SetViewport(0, 0, width, height, 0, 1);
The sampler state used by the pixel shader, (which btw I have tried randomly tweaking settings out of desperation):
SamplerStateDescription samplerDesc = new SamplerStateDescription()
{
AddressU = TextureAddressMode.Border,
AddressV = TextureAddressMode.Border,
AddressW = TextureAddressMode.Border,
MipLodBias = 0,
MaximumAnisotropy = 1,
Filter = Filter.MinMagMipPoint,
ComparisonFunction = Comparison.NotEqual,
BorderColor = new Color4(0,0,0,0),
MinimumLod = 0,
MaximumLod = float.MaxValue
};
Finally, here is the pixel shader. This is maybe a bit unusual, but basically it is just using the alpha from a texture to lerp between 2 colors:
Texture2D shaderTexture;
SamplerState sampleType;
struct PixelIn
{
float4 PosH : SV_POSITION;
float3 BColor : COLOR0;
float3 FColor : COLOR1;
float2 Tex : TEXCOORD;
};
float4 PS(PixelIn pin) : SV_TARGET
{
float4 textureColor;
float3 finalColor;
textureColor = shaderTexture.Sample(sampleType, pin.Tex);
finalColor = lerp(pin.BColor, pin.FColor, textureColor.a);
return float4(finalColor, 1.0f);
}
Anyone have any ideas, even a longshot, or has anyone seen anything like this before?