Advertisement

Creating a plane in screen space coordinates?

Started by January 24, 2023 01:22 AM
1 comment, last by VanillaSnake21 1 year, 10 months ago

I'm trying to define a plane in screen space coordinates but for some reason am not getting anything on screen.

My definition:

// Vertex layout semantics are { SV_POSITION, COLOR}

Vertex v[4] =

{

{DirectX::XMFLOAT3(-1.0f, -1.0f, -1.0f), DirectX::XMFLOAT4(1.0f, 0.0f, 0.0f, 1.0f)},

{DirectX::XMFLOAT3(-1.0f, 1.0f, -1.0f), DirectX::XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f)},

{DirectX::XMFLOAT3( 1.0f, 1.0f, -1.0f), DirectX::XMFLOAT4(0.0f, 0.0f, 1.0f, 1.0f)},

{DirectX::XMFLOAT3( 1.0f, -1.0f, -1.0f), DirectX::XMFLOAT4(1.0f, 0.0f, 0.0f, 1.0f)}

};

I thought I have to define the plane in NDC without any need for the usual View and Projection matrices, and the vertex shader would just be a pass through without modifying the vertices, but for some reason the plane is not showing up on screen. Am I setting it up wrong or is the issue elsewhere?

Thanks.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Solution: The main issue was that I had the wrong winding order on the vertices, disabling culling fixed the initial issue (or better yet, fix the winding order). The second issue is that the semantics were incorrect. The semantic in the vertex layout should be POSITION, not SVPOSITION, also in the vertex shader the incoming vertex should have a semantic of POSITION, and only on the output vertex should the semantic read SV_POSITION.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

This topic is closed to new replies.

Advertisement