Shadows with Point Light?

Software: Away3D 4.x

Guido, Member
Posted: 06 November 2013 03:50 PM   Total Posts: 70

Hi,

is there a way to get shadows with PointLight or is it only possible with DirectionalLight?

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 06 November 2013 05:41 PM   Total Posts: 166   [ # 1 ]

PointLight can have only HardShadowMapMethod.
I’ve not remember the result quality, but I could run with the combination.
I hope that PCSS or PCF method come to Away…
http://www.youtube.com/watch?v=QW6Tm_mfOmw

Anyway, try the combo.

Good luck.

 

   

Guido, Member
Posted: 07 November 2013 08:47 AM   Total Posts: 70   [ # 2 ]

If I user HardShadowMapMethod I only get a spot like in TV.

But what I want is a shadow, which is the result from a object that is between a ligth source and a plane, i think its called shadowcasting.

Is this possible with PointLight and HardShadowMapMethod?

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 07 November 2013 10:52 AM   Total Posts: 166   [ # 3 ]

I will test the combination later.
But at this time, I recommend you to tweak “radius” and “fallout” parameter of PointLight.

 

   

Guido, Member
Posted: 07 November 2013 12:18 PM   Total Posts: 70   [ # 4 ]

I tried it now with DirectionalLight. Does DirectionalLight and shadowcasting work with submeshes?

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 07 November 2013 12:43 PM   Total Posts: 166   [ # 5 ]

Here is a demo for PointLight shadow.
See attached swf.

lightPicker = new StaticLightPicker([pt]);   
shadow = new HardShadowMapMethod(pt);
shadow.epsilon 0.001;
shadow.alpha 0.8

But the shadow map’s resolution is bad.
I think that we can modify the resolution, but I give up for now.

For DirectionalLight, see examples of Away3D.
https://github.com/away3d/away3d-examples-fp11/archive/v4.1.4-gold.zip

Good luck.

 

File Attachments
SimpleAwayTest.swf  (File Size: 131KB - Downloads: 271)
   

Guido, Member
Posted: 07 November 2013 01:39 PM   Total Posts: 70   [ # 6 ]

Hi,

with epsilon 0.001 i have no shadow effect.

If i use DirectionalLight all wall are grey in the same colour.

Is it possible that it only works with meshes and not with submeshes?

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 07 November 2013 03:08 PM   Total Posts: 166   [ # 7 ]

What is your goal?
Do you want to change materials for each subMesh?
Can you show your code or screen capture?

 

   

Guido, Member
Posted: 07 November 2013 04:07 PM   Total Posts: 70   [ # 8 ]

I have a different material for each subMesh to increase performance.

Do i have to change to meshes and meshcontainers?

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 07 November 2013 04:23 PM   Total Posts: 166   [ # 9 ]

On GPU, you should reduce num of materials
and subGeometries for performance.
Latest Away run with GPU.

I think that kind of containers is not affect for performance.
Of course, too many nesting is not so good.
But nesting doesn’t affect so big for performance too.

You should marge your materials in one material.
Your subGeometries also.
Try searching about “texture atlas”.

And try to use Point/Directional lights in ordinary way.
You can find the way in Away3d example repo.

Good luck.

 

   

Guido, Member
Posted: 08 November 2013 08:51 AM   Total Posts: 70   [ # 10 ]

Now i worked only with meshes and without submeshes, but when apply the Shadowmapmethod (s.u.), all walls of my room have the same grey color.

mymaterial.shadowMethod = new FilteredShadowMapMethod(light); 

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 08 November 2013 10:55 AM   Total Posts: 166   [ # 11 ]

Maybe you should learn about importing a model to Away3d.
You can use Loader3D class instead of Mesh.
I think that this example can help you.
http://linktale.net/dev/away3d-examples-fp11_4_1_1_Beta/src/?code=Basic_Load3DS&size=1200_800

If you change URLs of model and texture,
your model will be appear on your screen.
(If your model doesn’t have problems.)

lines:70-76:

//solider ant texture
[Embed(source="/yourAssetFolder/yourTexture.jpg")]
public static var AntTexture:Class;

//solider ant model
[Embed(source="/yourAssetFolder/yourModel.obj",mimeType="application/octet-stream")]
public static var AntModel:Class; 

Be aware of scale of your model.
Good luck,

 

   

Guido, Member
Posted: 08 November 2013 12:11 PM   Total Posts: 70   [ # 12 ]

I solved the problem. I had not added the light to the scene. If using lightpicker it was no problem before, but shadowing does only work, if the light is added to the scene.

But there are still two problems:

1) If I move the light, my shadow does not move (see attachment). The light in the attachment comes from the viewer.

2) I have a kind of spotlight that you can see in the 2nd attachment, althought my radius is very big. These problem i had not without using shadowmethod.

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 08 November 2013 12:52 PM   Total Posts: 166   [ # 13 ]

At first, confirm a source light of your shadow.

new YourShadowMapMethod(sourceLight); //here 

If you use DirectionalLight for the source of shadow,
you have to move “direction”.
DirectionalLight does not have “position”.

var dLight:DirectionalLight = new DirectionalLight(0,-1,-1);

//update light vector
var direction:Vector3D dLight.direction;
direction.newXDir;
direction.newYDir;
direction.newZDir

And maybe you do not set your PointLight as the source.
So, even if you move your PointLight, your shadow never move.
If you want to set your PointLight as source light of shadow,

new HardShadowMapMethod(yourPointLight); //here 

And move your PointLight’s “position”.

 

 

   

Guido, Member
Posted: 08 November 2013 01:48 PM   Total Posts: 70   [ # 14 ]

Ok, i had 2 instances of pointlight and that’s why the pointlight was not the source. Now the shadow moves with the lightposition. Thank you.

Now my only problem is this kind of spotlight, that i see now in my shadow too. If i would give my image a shadowMethod, the spot would appear in the image too (see 2nd Attachment in a further post).

My radius is very high, so why do i see spotlight, which i don’t see if i not use shadowcasting?

(I work with PointLight and HardShadowMapMethod)

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 08 November 2013 01:58 PM   Total Posts: 166   [ # 15 ]

I don’t know.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X