|
f2sm, Newbie
Posted: 27 September 2011 02:47 PM Total Posts: 2
Dynamic shadow, projected shadow ? Is it possible ? How ?
I need to simulate moving sun and shadow projections on a 3D house roof
(See attached picture for an example).
Some flash 3D engines only feature poor shadow simulation.
Is possible to do such thing with Away3D v3 ? with v4 ?
Any global advice for this specific need ?
Thanx, and Anyway, I started to play with Away3D, and it seems great !
|
Matse, Sr. Member
Posted: 27 September 2011 02:58 PM Total Posts: 149
[ # 1 ]
Hi, I can only tell about away3D 4.x and yes it’s possible, and pretty easy to do.
You have to create a DirectionnalLight first, tell it to cast shadows and add it to your view’s scene
var dirLight:DirectionalLight = new DirectionalLight(); dirLight.y = 1000; dirLight.castsShadows = true; view.scene.addChild(dirLight);
Then you have to setup the material(s) of the objects you want shadows to be projected on, for example :
var ground:Plane = new Plane(null, 20000, 20000, 1, 1, true); var material:ColorMaterial = new ColorMaterial(0x1e233d); material.lights = [dirLight]; material.shadowMethod = new FilteredShadowMapMethod(dirLight); //material.shadowMethod = new SoftShadowMapMethod(dirLight, 0.000025); ground.material = material; view.scene.addChild(ground);
It won’t work with PointLight though.
Also, make sure you have objects/Meshes with castShadows property set to true (I think it’s true as default but didn’t check)
|
f2sm, Newbie
Posted: 27 September 2011 03:07 PM Total Posts: 2
[ # 2 ]
Incredibly fast and positive answer
Since I am new to Away3D (A friend of mine tested with success an old 3.x release and recommended this product) and since Away3D v4 seems to answer my need…
Any advice about the learning curve/path ?
I saw there are two books for the 3.6 release, are they still usable for the v4 ?
How did you/people learn to use Away3D v4 ?
(by the way, the “tutorial” section of the official website seems empty :( )
et si une partie de la réponse est en français ça ne me dérangera pas non plus (after a quick look on “matse” profile)
|
Matse, Sr. Member
Posted: 27 September 2011 06:23 PM Total Posts: 149
[ # 3 ]
I’m pretty new to away3D : started about 10 days ago since flash player 11 is about to go live. I have quite some experience using shockwave3D (Director, not Flash) so that helped much, I can’t really comment on the learning curve. The path is a bit harsh for now since there’s no real quickstart guide but it’s well worth it as the results are flat out amazing
Not sure 3.6 books are a good idea : I have a feeling that the away3d team tried to keep the framework about the same for the developper using it but there also seems to be major differences.
Here are a few things to get you started :
setting up FlashDevelop to compile with away3d for flash 11
http://www.mclelun.com/blog/2011/08/flashdevelop-stage3d-away3d/
latest away3d sources
https://github.com/away3d/away3d-core-fp11 (click the “downloads” button)
latest away3d examples (those are the best way to get you started in my opinion)
https://github.com/away3d/away3d-examples-fp11
[ french ]Je préfère éviter de parler français sur un forum anglophone, ou alors par mp : l’intérêt c’est que tout le monde puisse lire/comprendre
Pour l’instant c’est un peu galère d’arriver à ne serait-ce que compiler mais en suivant le lien que je t’ai donné si tu suis *tout* pas à pas normalement t’y arrives. En tout cas c’est comme ça que j’ai fait, bien galéré avant de trouver ce lien d’ailleurs.
Si tu n’utilises pas FlashDevelop je ne saurai pas te dire par contre.[ / french ]
|
Choons, Sr. Member
Posted: 27 September 2011 07:14 PM Total Posts: 281
[ # 4 ]
unfortunately 4.0 is so different than 3.6 the books aren’t really helpful. The best way I found to learn how to use 4.0 was to compile & study all the broomstick examples at https://github.com/away3d
Also the admins & developers here have put some very nice examples online with source code. Search around and you’ll come up with them. The learning curve is a bit steep at first since there’s no books yet and the documentation is spotty, but it gets easier quickly.
|
Baush, Sr. Member
Posted: 27 September 2011 08:48 PM Total Posts: 135
[ # 5 ]
Quick question: Would the shadow work fine on meshes other than planes? All examples I see uses planes.
|
Matse, Sr. Member
Posted: 27 September 2011 09:38 PM Total Posts: 149
[ # 6 ]
Yes it works fine : tested on walls, columns… I also tested projecting shadows from an animated character on himself and it works.
Only trouble I have with shadows so far is I can’t seem to find a way to change their color to something else than pure black, unless I play with material.ambient but it kinda kills lighting / normal mapping etc
I didn’t mess much with SoftShadowMapMethod so far though so that could be the reason I guess but my first tries with it didn’t look very good.
|
Matse, Sr. Member
Posted: 28 September 2011 09:00 AM Total Posts: 149
[ # 7 ]
Matse - 27 September 2011 09:38 PM Only trouble I have with shadows so far is I can’t seem to find a way to change their color to something else than pure black, unless I play with material.ambient but it kinda kills lighting / normal mapping etc
Actually, scratch that
Did some testing on this yesterday and I was able to get really nice looking results, just with an ambient value that is the same for every material in the scene and playing with directionnal and point light settings.
Not sure if it’s “the way” it’s supposed to be done, but works pretty good.
|
Baush, Sr. Member
Posted: 28 September 2011 11:32 AM Total Posts: 135
[ # 8 ]
I keep getting this error when I put light.castShadows = true;
Error: Error #3611: Stream 4 is read by the current vertex program but not set.
at flash.display3D::Context3D/drawTriangles()
at away3d.materials.passes::MaterialPassBase/render()
at away3d.materials.passes::DefaultScreenPass/render()
at away3d.materials::MaterialBase/renderPass()
at away3d.core.render::DefaultRenderer/drawRenderables()
at away3d.core.render::DefaultRenderer/draw()
at away3d.core.render::RendererBase/executeRender()
at away3d.core.render::RendererBase/render()
at away3d.containers::View3D/render()
at SimpleTerrainTest/_handleEnterFrame()
Any ideas? Oh and I use bitmap materials instead of color material, could it be it?
|
Matse, Sr. Member
Posted: 28 September 2011 12:11 PM Total Posts: 149
[ # 9 ]
Make sure light is a DirectionnalLight : it won’t work with PointLight.
I have it working with both BitmapMaterial and ColorMaterial, no problem here.
|
TheSillyOne, Newbie
Posted: 01 November 2011 08:35 PM Total Posts: 28
[ # 10 ]
Baush - 28 September 2011 11:32 AM I keep getting this error when I put light.castShadows = true;
Error: Error #3611: Stream 4 is read by the current vertex program but not set.
Any ideas? Oh and I use bitmap materials instead of color material, could it be it?
So far I get this error for shadow and outline methods exclusively in combination with skeletal animation during the second frame (so I see the result of the first frame on screen). Although it’s stream 1 in my case. Seems a vertex stream isn’t set for skinning or reset / overwritten by the “skinned” material.
Will check GitHub tomorrow and report it, if necessary.
Best regards.
|