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

Inward facing cylinder wall has normals pointing the wrong way #1734

Open
SteveGreatApe opened this issue Feb 9, 2018 · 7 comments
Open
Assignees
Labels

Comments

@SteveGreatApe
Copy link

I'm using a GVRCylinderSceneObject with FacingOut set to false to use as a circular room. Inside the cylinder I've placed a GVRPointLight to light the walls. I find if I set the light to mainly diffuse then the walls are very poorly lit.

If I run this function to reverse the normals then walls are lit up properly.

    public static void mirrorNormals(GVRSceneObject sceneObject) {
        GVRMesh mesh = sceneObject.getRenderData().getMesh();
        float[] norms = mesh.getNormals();
        for(int index = 0; index < norms.length; index ++) {
            norms[index] = -norms[index];
        }
        mesh.setNormals(norms);
    }
@bohuang3d
Copy link

Which constructor are you using? The one with signature

public GVRCylinderSceneObject(GVRContext gvrContext, boolean facingOut,
        ArrayList<GVRTexture> textureList) 

is not assigning its facingOut parameter to anything

@bohuang3d
Copy link

bohuang3d commented Feb 9, 2018

Add
params.FacingOut = facingOut;
to after the line
CylinderParams params = new CylinderParams();

to the definition of this constructor should fix

Or you can use the other constructors

@SteveGreatApe
Copy link
Author

I'm using this signature:

public GVRCylinderSceneObject(GVRContext gvrContext, GVRCylinderSceneObject.CylinderParams params)

The FacingOut field is working okay with this function except for the normals. It looks like what you've found is a different bug.

@bohuang3d
Copy link

ok. In
private void createBody(CylinderParams params)

the normals are actually not conditionally generated. We should add something like

if (params.FacingOut) {
nx0 = -nx0;
nx1 = -nx1;
...
...
//so on and so forth before copying to the normal buffer
}

@bohuang3d bohuang3d added the bug label Feb 9, 2018
@mwitchwilliams
Copy link
Contributor

mwitchwilliams commented Feb 9, 2018 via email

@mwitchwilliams
Copy link
Contributor

mwitchwilliams commented Feb 9, 2018 via email

@NolaDonato
Copy link
Contributor

NolaDonato commented Feb 10, 2018

PR #1741 should fix this issue for you.

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

No branches or pull requests

4 participants