bothsides and lights

Software: Away3D 4.x

YG, Newbie
Posted: 29 November 2011 07:03 PM   Total Posts: 18

hello,

i did a test with a plane and 2 lights.
the plane material bothsides = true.

but seems that the light only affect one side of the plane
when the other side remains black.

is it a bug?

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 November 2011 09:03 PM   Total Posts: 669   [ # 1 ]

I think you’d call it a “known limitation”. The lights use the normals of an object, so when you look at the reverse side of a plane the normals are pointing away, thus no light. The only workaround I’m aware of is using double geometry, ie. 2 planes back to back. That way you can also have different materials on both sides, as in a playing card, for example.

Good Luck!

   

inSertCodE, Sr. Member
Posted: 29 November 2011 10:57 PM   Total Posts: 105   [ # 2 ]

theMightyAtom is right. Clone the subGeometry of the plane, flip it (I think it can be done with scale - 1 ?) or better, edit the normals of the second sub geometry with -1 values everywhere were you have 1 and you’re good to go.

   

inSertCodE, Sr. Member
Posted: 30 November 2011 12:06 AM   Total Posts: 105   [ # 3 ]

Here, non-tested code as a hint. Assuming you have a plane called _Plane.

private var _subG:SubGeometry;

_subG _Plane.subMeshes[0].subGeometry.clone();
_Plane.geometry.addSubGeometry(_subG); 

or directly

_Plane.geometry.addSubGeometry(_Plane.subMeshes[0].subGeometry.clone()); 

after that

for (var i:int 0_Plane.subMeshes[1].subGeometry.numVertices 3; ++i{
   
if(_Plane.subMeshes[1].subGeometry.vertexNormalData[i] == 1){
      _Plane
.subMeshes[1].subGeometry.vertexNormalData[i] = -1;
   
}

...or…

for (var i:int 0_Plane.subMeshes[1].subGeometry.numVertices 3; ++i{
   _Plane
.subMeshes[1].subGeometry.vertexNormalData[i] = -(_Plane.subMeshes[1].subGeometry.vertexNormalData[i]);
   

Avatar
theMightyAtom, Sr. Member
Posted: 30 November 2011 07:50 AM   Total Posts: 669   [ # 4 ]

For a simple plane, I would either just rotate your second plane 180, or just use the MeshHelper

MeshHelper.invertFaces(yourMesh

It’s a bit easier than doing it “by hand” and doesn’t rely on having a normal that is exactly “1” in some direction.

   

YG, Newbie
Posted: 30 November 2011 12:10 PM   Total Posts: 18   [ # 5 ]

thanks guys.
i will use that technic.

but i like to know more about the vertex normal and what they do?
can someone point me to a good reference about this subject.

thanks again.

   

Avatar
theMightyAtom, Sr. Member
Posted: 30 November 2011 02:16 PM   Total Posts: 669   [ # 6 ]

The normal is the direction it is facing, as a vector.
The light is calculated by the angle of the light to the angle of the surface, to the angle of the camera. The face normal (i.e. direction it is facing) is the average of the 3 vertex normals at each of it’s corners.

When you are looking at the back of the plane, all the normals are facing away. If they are to build 2 sided materials in Away3D 4, the normals must face in both directions, or the light must know to use negative and positive normal directions in it’s output calculation.

So far this hasn’t been implemented, but I remember Fabrice talking about including it.

   

YG, Newbie
Posted: 02 December 2011 12:43 AM   Total Posts: 18   [ # 7 ]

thank you! now it’s clear!

i am in a discovering process of how 3d with away3d and stage3d works…

now i understood how lighting works.
i got more stuff to learn but i starting to get it..

   

Avatar
theMightyAtom, Sr. Member
Posted: 02 December 2011 09:02 AM   Total Posts: 669   [ # 8 ]

There’s a good primer here about the way most 3d technologies, including Away3D/Stage3D function, in the form of a slideshow.
http://www.inear.se/2011/04/a-brief-introduction-to-3d/

Happy exploring smile

   

YG, Newbie
Posted: 04 December 2011 01:59 AM   Total Posts: 18   [ # 9 ]

wow!! thank you!
hot stuff!!!

   
   
‹‹ autoDeriveVertexNormals

X

Away3D Forum

Member Login

Username

Password

Remember_me



X