GearVRf
GearVRf copied to clipboard
Inward facing cylinder wall has normals pointing the wrong way
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);
}
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
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
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.
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 }
I ran a similar test using X3D which calls the same Cylinder object and Cylinder Params.
It looks like the Normals inside the Cylinder are not flipping, except on the top and bottom of the Cylinder. The left Cylinder has a texture map (same texture applied to a plane in the background) and a blue Cylinder on the right.
I attached screen shot as well as the X3D file plus texture map.
mitch
Mitch Williams Samsung GearVR X3D development 310-809-4836 (outside line)
From: Bo Huang [mailto:[email protected]] Sent: Friday, February 9, 2018 11:59 AM To: Samsung/GearVRf [email protected] Cc: Subscribed [email protected] Subject: Re: [Samsung/GearVRf] Inward facing cylinder wall has normals pointing the wrong way (#1734)
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 }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Samsung/GearVRf/issues/1734#issuecomment-364546752, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARSfvmx656z6MytDcjGk_LyVW3OEuoZlks5tTKN3gaJpZM4SAQa1.
Just another screen shot. I rotated both cylinders to show the texture mapping on the inner top of Cylinder, but not on the sides.
Mitch Williams Samsung GearVR X3D development 310-809-4836 (outside line)
From: Bo Huang [mailto:[email protected]] Sent: Friday, February 9, 2018 11:59 AM To: Samsung/GearVRf [email protected] Cc: Subscribed [email protected] Subject: Re: [Samsung/GearVRf] Inward facing cylinder wall has normals pointing the wrong way (#1734)
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 }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Samsung/GearVRf/issues/1734#issuecomment-364546752, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARSfvmx656z6MytDcjGk_LyVW3OEuoZlks5tTKN3gaJpZM4SAQa1.
PR #1741 should fix this issue for you.