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
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
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