Away3D 4.0 and Diffuse Lighting!

Software: Away3D 4.x

empend, Member
Posted: 06 October 2011 05:11 AM   Total Posts: 77

After trying to figure it out, I can’t.
I’m loading a model, and trying to apply lighting to its material, but I only get the specular lighting!

Is there any reason why this would happen?

If anyone needs to code I’ll share it.

I hope someone can help.

   

Avatar
theMightyAtom, Sr. Member
Posted: 06 October 2011 07:32 AM   Total Posts: 669   [ # 1 ]

Code would help! wink

 

   

Richard Olsson, Administrator
Posted: 06 October 2011 04:17 PM   Total Posts: 1192   [ # 2 ]

Just modify the material lighting properties. Tweak the specular and diffuse properties to decrease the amount of specular light, and increase the amount of diffuse light. It should work just fine.

Are you sure you’re not referring to ambient light? Because if you need that, tweak the ambient and ambientColor properties. Make sure none of them are 0/black.

 

   

empend, Member
Posted: 06 October 2011 04:22 PM   Total Posts: 77   [ # 3 ]

I got the lighting working!
I just forgot to add the light to the scene.

Now I’m trying to figure out how to get shadows to work!
I’ve left the FLA, and all the other assets in a ZIP attached to this post.

If someone wants to take a look at it, and add shadows, so I can learn from it that’d be awesome.

Unless you would like to just show me how to use shadows another way, because I couldn’t figure out how to get them to work!

Thanks to whoever decides to help me! :D

 

File Attachments
Away3D_Model_Viewer.zip  (File Size: 458KB - Downloads: 222)
   

Richard Olsson, Administrator
Posted: 06 October 2011 04:25 PM   Total Posts: 1192   [ # 4 ]

Please have a look at the examples in the away3d-examples-fp11 repository over on GitHub. You’ll find that the 3DS loading example uses shadows.

 

   

empend, Member
Posted: 06 October 2011 05:18 PM   Total Posts: 77   [ # 5 ]

Still not able to get it to work. :(

This is the code I use to setup the materials, and models.

parser.loadData(event.target.data);
 
 var 
groundMaterial:BitmapMaterial = new BitmapMaterial(new dirtTexture(), truefalsetrue);
 
groundMaterial.ambient 0.2;
 
groundMaterial.specular 0.2;
 
groundMaterial.gloss 30;
 
groundMaterial.lights lightList;
 
groundMaterial.shadowMethod = new FilteredShadowMapMethod(directionalLight);
 
 var 
ground:Plane = new Plane(groundMaterial303011true);
 
ground.= -4;
 
container.addChild(ground);
 
 var 
material:BitmapMaterial = new BitmapMaterial(modelTexture,true,false,false);
 
material.ambient lightAmbient;
 
material.specular 0.6;
 
material.ambientColor 0xFFFFFF;
 
material.lights lightList;
 
material.shadowMethod = new FilteredShadowMapMethod(directionalLight);

 for (var 
i:int 0i<parser.numChildreni+=1{
  
var mesh:Mesh parser.getChildAt(i) as Mesh;
  
mesh.material material;
  
mesh.castsShadows true;
  
container.addChild(mesh);
 

Apparently view.camera.lens.far was too high, and it wouldn’t display shadows…

I’m sorry, but I hate checking my code 20 times to find out something like that ends up being the problem…
You should put a comment in the Basic_Load3DS.as example explaining it.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X