Newbie shadowMethod problem

Software: Away3D 4.x

steros, Newbie
Posted: 27 November 2011 09:26 PM   Total Posts: 19

Hey guys,

I’m running in to a little error with shading and lighting. If anyone can redirect me to a basic tutorial for this in Away4.x , my problem will be solved but because I can’t find one I’ll post my question here.

This is how far I got

light = new DirectionalLight(-1, -11);
light.color 0xFFFFFF;
light.castsShadows true;
   
light.= -1500;
light.= -1500;
light.= -1500;

myBitmapMaterial.lights [light];
myBitmapMaterial.shadowMethod = new SoftShadowMapMethod(light); 

It all goes well until the last line :|. Adding the shadowMethod somehow spoils all the fun and leaves me with the following error:
Error: Error #3663: Sampler 0 binds an undefined texture.
at flash.display3D::Context3D/drawTriangles()

I hope things sounds familiar to someone here:). I’d love to know how this shading thing works in 4.x… Let me know!
Thanks in advance

Stefan

   

Marcos Neves, Newbie
Posted: 28 November 2011 06:56 PM   Total Posts: 6   [ # 1 ]

You need to add this light within the scene before set your shadowMap… try this:

light = new DirectionalLight(-1, -11);
light.color 0xFFFFFF;
light.castsShadows true;
   
light.= -1500;
light.= -1500;
light.= -1500;

view.scene.addChild(light); // addChild before creating shadowMethod 

myBitmapMaterial.lights [light];
myBitmapMaterial.shadowMethod = new SoftShadowMapMethod(light); 

 

   

steros, Newbie
Posted: 30 November 2011 10:09 AM   Total Posts: 19   [ # 2 ]

That was my first thought! I tried that but it result in the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

The moment I add the light to the scene. The above error occurs. I use the code like following

light = new DirectionalLight(-1, -11);
light.color 0xFFFFFF;
light.castsShadows true;
   
light.= -1500;
light.= -1500;
light.= -1500;

view.scene.addChild(light); // addChild before creating shadowMethod 

myBitmapMaterial.lights [light];
myBitmapMaterial.shadowMethod = new SoftShadowMapMethod(light); 

What is wrong? such a basic thing… hmmmm

Thanks for the reply!
Stefan

 

 

   

Marcos Neves, Newbie
Posted: 30 November 2011 10:36 AM   Total Posts: 6   [ # 3 ]

You have a object null. Already you created a view?? and a myBitmapMaterial?? Try this:

var view = new View3D(); // You need to create and addChild a View
addChild(view);
   
var 
light = new DirectionalLight(-1, -11);
light.color 0xFFFFFF;
light.castsShadows true;
      
light.= -1500;
light.= -1500;
light.= -1500;

view.scene.addChild(light); // addChild before creating shadowMethod 
   
var myBitmapMaterial:BitmapMaterial = new BitmapMaterial(new BitmapData(500500));
myBitmapMaterial.lights [light];
myBitmapMaterial.shadowMethod = new SoftShadowMapMethod(light); 

Thanks,
Marcos Neves

 

   

Marcos Neves, Newbie
Posted: 30 November 2011 10:38 AM   Total Posts: 6   [ # 4 ]

You have a object null. Already you created a view?? and a myBitmapMaterial?? Try this:

var view = new View3D(); // You need to create and addChild a View
addChild(view);
   
var 
light = new DirectionalLight(-1, -11);
light.color 0xFFFFFF;
light.castsShadows true;
      
light.= -1500;
light.= -1500;
light.= -1500;

view.scene.addChild(light); // addChild before creating shadowMethod 
   
var myBitmapMaterial:BitmapMaterial = new BitmapMaterial(new BitmapData(500500));
myBitmapMaterial.lights [light];
myBitmapMaterial.shadowMethod = new SoftShadowMapMethod(light); 

Thanks,
Marcos Neves

 

   

steros, Newbie
Posted: 01 December 2011 09:25 AM   Total Posts: 19   [ # 5 ]

I think I have that pretty much covered. Shall I just give you the code?
It’s already quite long but yeah… than you’ll have a better idea of where the problem could be.

If you can’t see what the problem is I’m gonna reconstruct. As is; I’ll make a very easy class in which the only thing I’ll do is add a plane and apply lighting on it.

But first: I’ll attach the code.

PS: the code is not going to work because I won’t include all the assets.

 

File Attachments
myCode.zip  (File Size: 10KB - Downloads: 204)
   

Marcos Neves, Newbie
Posted: 01 December 2011 10:52 AM   Total Posts: 6   [ # 6 ]

Maybe your Away3D package is out of date. I tryed with my package and a different jpg. Works ! See the attach zip.

 

File Attachments
src.zip  (File Size: 623KB - Downloads: 207)
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X