Question

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)

  • Some areas seem to get drawn over (polys in the back get drawn over front ones) You can see what this looks like here : https://www.dropbox.com/s/hy4k20ay1g77rky/Drawing%20issue.png
  • Another completely undescribable thing happens, not sure if i can convey it with words but if unclear let me know and i'll try to capture video : past a certain rotation points it's as if a ray came over the screen and "progressively" remodeled the surface from left to right leaving weird artifacts within the ray and lowered geometry past the ray

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);
}
Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top