Home > Software engineering >  Using Hull shader and Domain shader breaks 2D shader
Using Hull shader and Domain shader breaks 2D shader

Time:08-05

I'm following Rasterteks DirectX11 tutorial at https://www.rastertek.com/tutdx11.html and have been combining them to create and learn.

I just implemented tessellation for my 3D models and noticed that my 2D shader for rendering text stopped working. I have separate shaders for 2D and 3D, which worked fine until I implemented the Hull shader and domain shader for my 3D rendering. Below is some code for when I set the shaders.

Lightshader with tessellation:

void LightShader::RenderShader(ID3D11DeviceContext * immediateContext, int indexBufSize)
{
    immediateContext->IASetInputLayout(layout);

    immediateContext->VSSetShader(vertexShader, NULL, 0);
    immediateContext->PSSetShader(pixelShader, NULL, 0);

    // using these two causes the 2D rendering to stop working
    immediateContext->HSSetShader(hullShader, NULL, 0);
    immediateContext->DSSetShader(domainShader, NULL, 0);

    immediateContext->PSSetSamplers(0, 1, &sampleState);

    immediateContext->DrawIndexed(indexBufSize, 0, 0);
}

Fontshader for rendering 2D text:

void FontShader::RenderShader(ID3D11DeviceContext * immediateContext, int indexBufSize)
{
    immediateContext->IASetInputLayout(layout);

    immediateContext->VSSetShader(vertexShader, NULL, 0);
    immediateContext->PSSetShader(pixelShader, NULL, 0);

    immediateContext->PSSetSamplers(0, 1, &sampleState);

    immediateContext->DrawIndexed(indexBufSize, 0, 0);
}

I could also post the shadercode on request if the issue lies there.

CodePudding user response:

It's probably because you forgot calls for unbinding HS and DS. Such as

immediateContext->HSSetShader(NULL, NULL, 0);
immediateContext->DSSetShader(NULL, NULL, 0);

You should enable debug layer, it's useful for debugging.

  • Related