Skip to main content
GameDev.net gamedev.net
🔒 Locked

Creating a plane in screen space coordinates?

Started by VanillaSnake21 Jan 24, 2023 at 1:22 AM 1 replies 3.7k views
Original Post
VanillaSnake21
VanillaSnake21

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
VanillaSnake21
VanillaSnake21

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.