1
\$\begingroup\$

I wish to be able to render any Plane (Defined by a Normal and a distance from the origin).

The closest answer state to use 'Direction' (4D vectors with w = 0) with the Lengyel infinite matrix, but unfortunately it does not render anything with my implementation:

const float FOV = glm::radians(55.0f);
const float e   = 1.0f / std::tan(FOV / 2.0f);
const float a   = height / width;
const float n   = 0.1f;

this->projection = glm::mat4{
  e, 0, 0, 0,
  0, e / a, 0, 0,
  0, 0, -1.0f, -2.0f * n,
  0, 0, -1, 0
};

std::vector<Vertex> vertices =
  {
   Vertex{glm::vec4( 0.0f,  0.0f,  0.0f, 1.0f), Vector::Up()}, 
   Vertex{glm::vec4( 1.0f,  0.0f,  0.0f, 0.0f), Vector::Up()}, 
   Vertex{glm::vec4( 0.0f,  1.0f,  0.0f, 0.0f), Vector::Up()}, 
   Vertex{glm::vec4(-1.0f,  0.0f,  0.0f, 0.0f), Vector::Up()},
   Vertex{glm::vec4( 0.0f, -1.0f,  0.0f, 0.0f), Vector::Up()}
  };

std::vector<GLuint> indices = {0, 1, 2,   0, 2, 3,   0, 3, 4,   0, 4, 1};
// Render by indices
...
\$\endgroup\$
2
  • 2
    \$\begingroup\$ Does it have to be infinite? Could you not just set it to a very large number, and if you must, offset it by the camera's position? \$\endgroup\$
    – J4S
    Apr 5, 2018 at 20:54
  • \$\begingroup\$ Looks you're using geometry. I'll point out you can use a fullscreen shader for this. Iq on shadertoy has shadertoy.com/view/XtBfzz and shadertoy.com/view/llffWs Different costs though even with discard. \$\endgroup\$
    – Sirisian
    Apr 5, 2018 at 21:36

0

You must log in to answer this question.

Browse other questions tagged .