Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Basic impostors for distant objects

  1. #1
    Newbie Newbie
    Join Date
    Jul 2018
    Posts
    2

    Basic impostors for distant objects

    I want to create simple impostors for low-resolution distant objects. Each impostor is a set of faces, each with a texture representing the object as seen from a different direction. Only the face most directly facing the camera should be rendered.

    Can such face selection be done in a shader? If so, how?

    (This seems so basic that an answer should be online, but I'm not finding it.)

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,513
    Envision the object a axis-aligned cube centered around its own local origin. Construct a vector from that origin to the eyepoint. The signs of the vector components identify which face you want to render.

    For other objects, just adapt this. The face with the maximum dot( eye_vector, face_normal ) wins.

  3. #3
    Newbie Newbie
    Join Date
    Jul 2018
    Posts
    2
    Yes, I know that the biggest dot product indicates the face to render. But I don't know how to do that in shader language, or even if it's possible. The idea is to do this on the graphics card, for large numbers of background impostors.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,962
    Quote Originally Posted by animats View Post
    Yes, I know that the biggest dot product indicates the face to render. But I don't know how to do that in shader language, or even if it's possible. The idea is to do this on the graphics card, for large numbers of background impostors.
    It's certainly possible. It's really just a question of whether to do it in the vertex shader (which requires performing the same calculations for each vertex of a quad) or a geometry shader (which requires using a geometry shader), or whether to do it in a separate pass using either a compute shader or a vertex shader with transform-feedback. And also whether to pass per-impostor data by duplicating it for each vertex, or using instancing, or using fake instancing (uniform arrays, SSBO array or textures, indexed using gl_VertexID).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •