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

Do backface clipping based on triangle normal vector #13

Open
tamara-schmitz opened this issue Sep 25, 2017 · 0 comments
Open

Do backface clipping based on triangle normal vector #13

tamara-schmitz opened this issue Sep 25, 2017 · 0 comments

Comments

@tamara-schmitz
Copy link
Owner

Probably requires #12 first. Comparison has to happen in view space. Eye vector would then be a forward vector.

Possible implementation of backface culling:

bool cullBackFacingTriangle(const Vec3 & eye, const Vec3 & v0,
                            const Vec3 & v1,  const Vec3 & v2)
{
    // Plane equation of the triangle will give us its orientation
    // which can be compared with the viewer's world position.
    //
    const Vec3 d = crossProduct(v2 - v0, v1 - v0);
    const Vec3 c = v0 - eye;
    return dotProduct3(c, d) <= 0.0f; // Returns true if it should be discarded
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant