Any code examples on how to use SoftShadowMapMethod and SlowFilteredShadowMapMethod

Software: Away3D 4.x

julespong, Member
Posted: 20 July 2011 12:26 AM   Total Posts: 53

Looking for some examples on how to use the shadow mapping methods. Or how to create dynamic shadows in general. Any help?

   

Somokon, Member
Posted: 20 July 2011 04:14 PM   Total Posts: 75   [ # 1 ]

For every material that you want the shadow to appear on

material.shadowMethod SlowFilteredShadowMapMethod(lightSource

or

material.shadowMethod SoftShadowMapMethod(lightSourcestepSize=0.00025

Also ensure your light source is added to the material as well

material.lights [lightSource1lightSource2, ...
   

julespong, Member
Posted: 20 July 2011 06:03 PM   Total Posts: 53   [ # 2 ]

ok, here’s my code:

Mesh(event.asset).castsShadows = true;
material.shadowMethod = SlowFilteredShadowMapMethod(__lights[2]);


Here’s the error it throws:
TypeError: Error #1034: Type Coercion failed: cannot convert away3d.lights::PointLight@c9a20d1 to away3d.materials.methods.SlowFilteredShadowMapMethod.

Can someone tell me why it’s trying to convert my lightsource to a shadowmap method?

FYI: I’m using the nightly build of Away 4

   

julespong, Member
Posted: 20 July 2011 06:25 PM   Total Posts: 53   [ # 3 ]

Additionally, I’ve attempted to instantiate a new shadowmapping method:

material.shadowMethod = new SlowFilteredShadowMapMethod(__lights[2]);


But, I’m receiving this error:

Error: An abstract method was called! Either an instance of an abstract class was created, or an abstract method was not overridden by the subclass.

So… either I’m supposed to instantiate a ShadowMapMethod and I’m getting an abstract method error. Or I’m supposed to use the ShadowMapMethod statically and I’m getting a type conversion error. Any pointers?

   

Somokon, Member
Posted: 21 July 2011 06:37 AM   Total Posts: 75   [ # 4 ]
julespong - 20 July 2011 06:03 PM

ok, here’s my code:

Mesh(event.asset).castsShadows = true;
material.shadowMethod = SlowFilteredShadowMapMethod(__lights[2]);

...

Can someone tell me why it’s trying to convert my lightsource to a shadowmap method?

That would be because you forgot the ‘new’ operator in front of SlowFilteredShadowMapMethod.  Without it, your code attempts to cast _lights[2] into SlowFilteredShadowMapMethod object.


Try using FilteredShadowMapMethod instead, as SlowFilteredShadowMapMethod is broken with the current flash player on Windows.

If you are still having trouble can you paste the rest of your code?

   

Avatar
David Lenaerts, Administrator
Posted: 21 July 2011 09:44 AM   Total Posts: 80   [ # 5 ]

Julespong: Is _lights[2] perhaps a Point Light? Shadow mapping for point lights isn’t supported. Only Directional Lights work.

Also, something very important concerning SlowFilteredShadowMapMethod: with the latest FP11 beta, this is broken and will complain about not being able to compile the shader programme. This is because of some new limitations on programme length. We’re still hoping for some update in the player, tho.

   

julespong, Member
Posted: 21 July 2011 06:32 PM   Total Posts: 53   [ # 6 ]

Ahh… that makes sense then. Yes, I’m using the FP11 beta and yes, I was attempting to use a PointLight for my light source. I’ll try to use the SoftShadowMapMethod instead of the SlowFilteredShadowMapMethod also. Thanks for the info.

   

julespong, Member
Posted: 21 July 2011 08:33 PM   Total Posts: 53   [ # 7 ]

Well, I got it working with a DirectionalLight and a SoftShadowMapMethod. What range does the stepsize argument take? Also, how do I control the opacity of the shadow? The shadow I’m getting using the default stepsize seems very pixelated and fragmented. Any advice on how to clean that up?

What can we expect in terms of shading capabilities when 4.0 releases?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X