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

Sphere mapping discontinuity may not be handled properly #302

Open
AlcEccentric opened this issue Oct 22, 2020 · 0 comments
Open

Sphere mapping discontinuity may not be handled properly #302

AlcEccentric opened this issue Oct 22, 2020 · 0 comments

Comments

@AlcEccentric
Copy link

AlcEccentric commented Oct 22, 2020

Hi,

The code snippet named "Handle sphere mapping discontinuity for coordinate differentials" in function SphericalMapping2D::Map may not be able to handle the discontinuity of the t texture coordinate in sphere mapping properly.

I think that code snippet assumes the absolute value of (*dstdx)[1] or (*dstdy)[1] is less than 1, but this assumption does not hold as you set delta as 0.1.

Here is the function:

Point2f SphericalMapping2D::Map(const SurfaceInteraction &si, Vector2f *dstdx,
                                Vector2f *dstdy) const {
    Point2f st = sphere(si.p);
    // Compute texture coordinate differentials for sphere $(u,v)$ mapping
    const Float delta = .1f; // **DELTA IS 0.1**
    Point2f stDeltaX = sphere(si.p + delta * si.dpdx);
    *dstdx = (stDeltaX - st) / delta;
    Point2f stDeltaY = sphere(si.p + delta * si.dpdy);
    *dstdy = (stDeltaY - st) / delta;

    // Handle sphere mapping discontinuity for coordinate differentials
    if ((*dstdx)[1] > .5) // **THE VALUE HERE COULD BE CLOSE TO 10.0** 
        (*dstdx)[1] = 1 - (*dstdx)[1];
    else if ((*dstdx)[1] < -.5f)
        (*dstdx)[1] = -((*dstdx)[1] + 1);
    if ((*dstdy)[1] > .5)
        (*dstdy)[1] = 1 - (*dstdy)[1];
    else if ((*dstdy)[1] < -.5f)
        (*dstdy)[1] = -((*dstdy)[1] + 1);
    return st;
}

I tested it with a scene using spherical mapping. The log showed the value of (*dstdx)[1] could be something like 9.999742. In this case, the final value of (*dstdx)[1] was -8.999742 after the code handled the discontinuity. In my opinion, this final value is not desired.

I am a beginner in this field, so I may be wrong here. If I am wrong, hope you could briefly explain why that code snippet could still handle discontinuity properly in the example I mentioned.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant