-1

I want to project a grid on the xz-plane like shown here:

im

To do that, I created a vertex grid with x and z range [-1|1]. In the shader I multiply the xz screen coordinate of a vertex with the inverse of the View-Projection matrix. Then I want to adjust the height, depending on the new world xz coordinates and finally I transform these coordinates back to screenspace by multiplying them with the View-Projection matrix.

I dont know why, but I get a very strange plane shown on the screen. Are the mathematical oprations I use correct?

Community
  • 1
  • 1
Erik
  • 11,944
  • 18
  • 87
  • 126

1 Answers1

0

The grid that you initially create, is that in projection space or actual screen co-ords? It sounds like it is in projection space since you only transform it with the inverse of the view-projection matrix to get into world co-ords. I think you need to include the "Window" matrix too i.e. transform them by the inverse of the View-Projection-Window matrix (and similarly on the way back to screen co-ords).

Edit:

I'm probably not understanding exactly what it is you're trying to do so here's some questions back. :)

Are you trying to take the grid that's shown in the screenshot in your question and project that onto world z-x co-ordinates? If so, then why do you start with a grid of z-x values? Also, if you apply an inverse view matrix to those then surely you would end up with a line since the camera looks along z although your second screenshots show that you are getting a plane. I'm a bit confused.

Troubadour
  • 13,334
  • 2
  • 38
  • 57