Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture coordinate geenration for sphere map #84

Merged
merged 4 commits into from
Nov 25, 2024

Commits on Nov 24, 2024

  1. texture: primitive implementation of GL_SPHERE_MAP and GL_REFLECTION_MAP

    This implementation comes with a big simplification: while the OpenGL
    specifications say that the texture coordinates should be computed as a
    reflection from the point of view of the camera, we do it as if the
    camera rays were all parallel to each other (that is, as if the camera
    was located infinitely far away). This approximation is acceptable for
    objects like spheres or with other curved surfaces, it works pretty
    badly with flat surfaces where all the normals have the same value,
    because in that case the same texel from the reflection texture gets
    applied over to the whole object.
    
    Also, GL_SPHERE_MAP should not be the same as GL_REFLECTION_MAP, because
    the resulting reflection vector should also be scaled down according to
    the distance from the viewer.
    mardy committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    01fbae2 View commit details
    Browse the repository at this point in the history
  2. texture: implement GL_SPHERE_MAP in software

    This implementation complies with the OpenGL specification. In a
    follow-up commit we will give the client the possibility to choose
    between this software implementation and the faster (but wrong) GPU
    implementation.
    mardy committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    956ea73 View commit details
    Browse the repository at this point in the history
  3. Add environment variable to select accuracy vs speed

    We might have more cases in the future, where we can choose between an
    accurate software implemenation and a faster but non-standard GPU
    implementation. Let's create a mechanism through which the client can
    select the features which can be sped up at the cost of correct
    rendering.
    
    This is currently exposed as an environment variable, and not as an API,
    because if it turns out to be a bad idea we can remove it without
    breaking the public API.
    mardy committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    e357336 View commit details
    Browse the repository at this point in the history
  4. arrays: make texture coordinate generation work with vertex buffers

    Implement the read_{pos,norm}() functions for the DirectVboReader class
    too, because they are needed when generating texture coordinates.
    mardy committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    0f79b0f View commit details
    Browse the repository at this point in the history