Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Apr 2011
Offline Last Active Today, 05:22 AM

Posts I've Made

In Topic: Drawing fullscreen triangle without vertex buffers

28 July 2014 - 09:19 AM

As for the viewport, I think it is no problem. Like this:

D3D11_VIEWPORT viewport;
ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<float>(swapChainDesc.BufferDesc.Width);
viewport.Height = static_cast<float>(swapChainDesc.BufferDesc.Height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
mContext->RSSetViewports(1, &viewport);

EDIT: I fixed it, the vertex shader math was slightly wrong. Heres the more condensed version for CCW frontface rendering

float4 main(uint VertexID: SV_VertexID) : SV_POSITION
    return float4(float2(((VertexID << 1) & 2) * 2.0f, (VertexID == 0) * -4.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);

In Topic: Drawing fullscreen triangle without vertex buffers

28 July 2014 - 08:22 AM

Come to think of it, I am using frontface = CCW, that might be the cause of it?


        D3D11_RASTERIZER_DESC rasterizerDesc;
        ZeroMemory(&rasterizerDesc, sizeof(D3D11_RASTERIZER_DESC));
        rasterizerDesc.FillMode = D3D11_FILL_SOLID;
        rasterizerDesc.CullMode = D3D11_CULL_BACK;
        rasterizerDesc.FrontCounterClockwise = true;
        rasterizerDesc.DepthClipEnable = true;
        rasterizerDesc.ScissorEnable = false;
        rasterizerDesc.MultisampleEnable = false;
        rasterizerDesc.AntialiasedLineEnable = false;
        DXCALL(mDevice->CreateRasterizerState(&rasterizerDesc, &mRasterizerState));

EDIT: I altered the vertex shader as follows:

FullscreenTriangleVSOut main(uint VertexID: SV_VertexID)
    FullscreenTriangleVSOut output;

    output.mTexcoord = float2((VertexID << 1) & 2, VertexID == 0);
    output.mPosition = float4(output.mTexcoord * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);

    return output;

The positions should now be:


[-1, -3]

[3, -1]

[-1, 1]


However, not the whole screen is red... this is how it looks:



In Topic: Drawing fullscreen triangle without vertex buffers

28 July 2014 - 06:57 AM

I experimented abit and it turns out I can draw it fine if I set D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST and draw 6 vertices. But surely 3 should suffice?

In Topic: SamplerState in code or HLSL?

24 July 2014 - 05:39 PM

Sorry for all the persistant questions, there are just a couple of things left I need to clear up.


1) So there really is no way to achieve better visuals than the 16x anisotropic filtering when sampling textures? The image I posted still looks really muddled.


2) I create the textures with the usage flag D3D11_USAGE_DEFAULT. This dosn't feel optimal considering its a static texture, but I need it due to mipmap generation. Is there any performance issues with that usage versus D3D11_USAGE_IMMUTABLE, and is there any easy way of fixing it?

In Topic: SamplerState in code or HLSL?

24 July 2014 - 11:43 AM

Since you're using a second vertex stream, the input layout should reflect that:

  inputDescription[1].InputSlot = 1;
  inputDescription[1].AlignedByteOffset = 0;
Such troubles are better analyzed with a graphics debugger where you can see if your texture upload succeeded and if your vertices are correct.



Thats it. Thanks.


The result is not as good as I hoped it to be, even with anisotropic filtering set to 16. Here's an example:





In the background you see its very blurry. Is there any way to get better visuals?