RESOLVED: Directional light behaving oddly

Software: Away3D 4.x

wagster, Member
Posted: 20 September 2011 09:16 PM   Total Posts: 68

The attached shows a bunch of cylinders being lit purely by a single DirectionalLight which is directly above - specular = 0; diffuse = 1;.  They seem to be a bit translucent as the light is illuminating the top half of the sides.  Any ideas why?

It’s giving me grief as this constant bending of light around the top edges makes it very hard to discern the flat surface on top from most angles.

 

   

Avatar
Alejandro Santander, Administrator
Posted: 21 September 2011 12:18 AM   Total Posts: 414   [ # 1 ]

I think I saw this weird kind of lighting on cylinder primitives with point lights as well, so this might be a bug in the cylinder primitive rather than on directional lights.

Can you have a quick check if this is right (by testing your scene primitives other than cylinders).

If so, we need to fix that.

 

   

Richard Olsson, Administrator
Posted: 21 September 2011 07:49 AM   Total Posts: 1192   [ # 2 ]

Are you using the Away3D cylinders? I can see from the image that the vertex normals are not right, and if you are using the Away3D primitives then that’s obviously an issue we need to fix. Please file a bug!

 

   

wagster, Member
Posted: 21 September 2011 08:08 AM   Total Posts: 68   [ # 3 ]

Hi RIchard, no I’m figuring out a Blender > Away3D workflow.  Those are Blender cylinders exported as a 3ds file and loaded into the AssetLibrary. 

I might try Away3D cylinders, or maybe go via Prefab if I can figure it out - I believe Prefab sorts out dodgy normals.

Having said that, I had similar problems with Away3D cylinders before.  I’ll post again here before filing a bug - it may just be that I’m not using the lights correctly.

 

   

Richard Olsson, Administrator
Posted: 21 September 2011 08:15 AM   Total Posts: 1192   [ # 4 ]

The problem in the image is clearly that the vertex normals are slanting upwards, leaving the shader to believe that the surface on the sides is not entirely vertical. This likely stems from the cap of the cylinder and it’s sides sharing the same vertices. Try in Blender to break off the cap (select all the top vertices and hit p, then choose “selected”.) You will then have two separate meshes. Go to object mode and select both and press Ctrl+J to join them back into one. The new, joined cylinder mesh will look the same in Blender, but actually the vertices are no longer shared between cap and sides, which will cause Away3D to calculate better vertex normals for it.

 

   

wagster, Member
Posted: 21 September 2011 08:20 AM   Total Posts: 68   [ # 5 ]

Thanks, I’ll get on to that this eve.

 

   

John Brookes, Moderator
Posted: 21 September 2011 09:41 AM   Total Posts: 732   [ # 6 ]

Away cylinders do the same

 

   

wagster, Member
Posted: 21 September 2011 10:10 AM   Total Posts: 68   [ # 7 ]

Is that also a vertex normals problem do you think?

 

   

Richard Olsson, Administrator
Posted: 21 September 2011 10:12 AM   Total Posts: 1192   [ # 8 ]

What JohnBrookes posted seems to have the same kind of vertex normal problems, yes. Please if one of you can file an issue report that would be greatly appreciated! You can reference this thread in the forums.

 

   

Avatar
Alejandro Santander, Administrator
Posted: 21 September 2011 03:03 PM   Total Posts: 414   [ # 9 ]

I can confirm that the Away3D cylinder primitive is having the same lighting problems, I will attempt a fix now…

The image below is a cylinder on 0, 0, 0 with a point light straight on top of it.

 

   

wagster, Member
Posted: 21 September 2011 04:03 PM   Total Posts: 68   [ # 10 ]

Thanks Alejandro - all my furniture is made of cylinders until I can get my head around moddeling in Blender!

 

   

Avatar
Alejandro Santander, Administrator
Posted: 22 September 2011 07:57 PM   Total Posts: 414   [ # 11 ]

The cylinder primitive has been refactored to look like this: http://www.lidev.com.ar/tests/away3d/cylinder_test/

Please sync to the latest away3d-core-fp11 github repo to use the new cylinder.

The problem was that the previous primitive was sharing vertices between the lateral surface and the flat ends, causing ugly illumination. If you want to use imported primitives, make sure that you know that sharing vertices on edges can cause this sort of illumination problems, so it is an important design decision to share or not vertices when you want to use lights.

 

   

Avatar
80prozent, Sr. Member
Posted: 22 September 2011 08:25 PM   Total Posts: 430   [ # 12 ]

hi alejandro

thank you for fixing the cylinder and for making me aware of this “shared-verticles-issue”.

i am porting objects from c4d to away3d, and in c4d (phyton) i minimized my verticles-count, by checking if a vert has its own unique uvs or not.

all my tests was done without using lights (stupid mistake i guess), so if i export a cylinder-like mesh without any uv, i end up with the same shared-verticles like the previous away-cylinder.

is there a method to get rid off shared-verticles on meshes ?

would really help me out…..

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

wagster, Member
Posted: 22 September 2011 09:00 PM   Total Posts: 68   [ # 13 ]

Fantastic. 

Richard has explained to me how to fix this in Blender (80prozent - try Richards Blender tip in c4d if you can) and Alejandro has fixed the primitive.

I only asked for one fix - I got two!

 

   

Avatar
Alejandro Santander, Administrator
Posted: 22 September 2011 09:10 PM   Total Posts: 414   [ # 14 ]

80, perhaps Fabrice Closier knows of ways to weld vertices, he’s the expert on that with all the Prefab3D work he has done.

Anyway, that’s another topic, this on is resolved =)

 

   

Avatar
80prozent, Sr. Member
Posted: 22 September 2011 09:21 PM   Total Posts: 430   [ # 15 ]

@wagster: ive kept thinking about this for a while now and i think your right: the only way is do choose in c4d which verts should be shared and which not. its really a pain for me, since i spend some hours writing a function in c4d that prepares my objects for away3d with as less verticles as possible (and as much shared verts as possible too).

kind of sucks

but a method in away3d that gets rit of all shared verts as i suggested in my previous post wouldnt be practical too, since after calling such a method on a mesh, all shared verts off this mesh would be made to unique ones and verticles count would raise up high.

BTW the meshHelper.as contains a method called build, that creates a mesh out of some given buffers and has a parameter that defines if shared-verts should be used or not.

only way i see (for me and my c4d exporter) is to define per uv if they should be shared or not. so in the case of the cylinder i just would have to make shure that the caps of the cylinder are using other uv points than the sides. when exporting my script will than not create shared verticles for the edges, while still create shared verticles for the rest of the mesh.

 

 

 Signature 

sorry…i hope my actionscript is better than my english…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X