I'm using sharpdx to access directX 11 and running this very simple displacement shader i wrote on a single plane
No multiple places, no other objects on the scene, just a high poly flat plane with the displacement shader in a single draw call
While it renders fine at first i rotate it over time and i get "really weird" artifacts X2 past a certain angle (it's not a backface issue, i'm only rotating it on the up axis and the way it is angled no backfaces are visible when the issue arises)
The shader i'm using :
struct VS_IN
{
float4 pos : POSITION;
float2 tex : TEXCOORD;
};
struct PS_IN
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD;
};
float4x4 worldViewProj;
Texture2D<float4> diffuse: register(t0);
Texture2D<float4> height: register(t1);
Texture2D<float4> lightmap: register(t2);
SamplerState pictureSampler;
PS_IN VS( VS_IN input )
{
PS_IN output = (PS_IN) 0;
input.pos.z += height.SampleLevel(pictureSampler, input.tex, 0).r /2;
output.pos = mul(input.pos, worldViewProj);
output.tex = input.tex;
return output;
}
float4 PS( PS_IN input ) : SV_Target
{
return diffuse.Sample(pictureSampler, input.tex) * lightmap.Sample(pictureSampler, input.tex);
}
It looks like you haven't set up depth testing properly. That would explain why it looks correct from some angles and not from others since it would be dependent on the draw order of the triangles as to which appeared on top.
Have you created a depth buffer, set it, cleared it and set a DepthStencilState to match?