20
2013
Fake Circular Shadow Casters
More fake shadow tests.. (currently works from one direction only)
Info:
– Lets say all of your shadow casting objects are spheres/circular, then we could calculate what area is not visible based on the distance & angle from the player to spheres (or so I hoped, but couldnt find any method of calculating it..so now this is using precalculated values which were recorded by hand, 1 by 1.. : )
– Precalculated SinCos lookup tables and distance tables..
– GL quads for drawing the shadow area
– Demo 1.0 uses only 360 precalculated values..thats why its bit jumpy.
– No rays/raycasting used, currently main function only does: 1 Mathf.RoundToInt, 1 multiplication, 2 vector3 multiplications, getting values from 2 precalculated arrays, 3 vector additions…
Progress:
– Yay! got some help from friends and now can calculate the point/tangent on a circle from another point:
s = transform.position; // player t = target.transform.position; // sphere distance = Vector3.Distance(s,t); var r:float = 0.5; // sphere radius var f:float = Mathf.Sqrt((distance*distance)-(r*r)); var alpha:float = Mathf.Asin(r/distance); var yy:float = Mathf.Sin(alpha)*f; var xx:float = Mathf.Cos(alpha)*f; Debug.DrawRay (transform.position, Vector3(xx*1,0,yy*1), Color.red); Debug.DrawRay (transform.position, Vector3(xx*1,0,-yy*1), Color.green);
Webplayer:
http://unitycoder.com/upload/demos/FakeCircularShadowCasters/ (v1.0 *Note: using only array of 360 pre-calculated values, thats why its bit jumpy..)
Download source:
coming later..
Related Posts
2 Comments + Add Comment
Leave a comment
Recent posts
- Favorites in PackageManager
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
Recent Comments
- on Mesh Exploder (sources)
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by













circle stuff,
“Finding an unknown point of a circle”
http://forum.unity3d.com/threads/207545-Finding-an-unknown-point-of-a-circle?p=1400857&viewfull=1#post1400857
Circle in Sector:
http://bl.ocks.org/mbostock/6a53ca8427a0bc2d4cf1