4
2012
Fake 2D Realtime Raycast Shadows (for unity free version)
Testing another way of doing realtime 2D shadows, by casting rays from the player position, then create “light” polygon to the area where we can see.
More info later, need to test few things (using setpixels & shader? or using different shader for better light effect with polygon plane)
Webplayer:
http://unitycoder.com/upload/demos/mShadowRayScan1/ (added 10.1.2012)
Download source:
mRayCastShadowTest.unityPackage
More test images:
Rays with 1 bounce (so we get light behind the corners also..red color is bounced light ray, using 512 rays for this image, using Debug.DrawLine)
Related Posts
8 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
Added webplayer demo v1.0
-Interesting method, how is performance/# of rays?
(this would be very useful for me if the ray# can be high. i want to draw a cone of sight with this but for the edges of obstacles in great distances the gap between rays would be to high i guess…)
-is it possible to create this as a cutoutpolygon for a already placed shadowpolygon?
Added source download (had forgotten to upload it)
So you can test it.. (I’ve only tested on this small scene)
Actually, theres no need to triangulate it every frame, for example
if you use this kind of mesh (every triangle connects to the middle always)
http://unitycoder.com/blog/2012/01/06/noob-triangulator-js/
Then all you need to do is,
– Do scan
– Modify vertices
(saves creating: “uv maps”, “triangulation” etc.. from the Update loop)
New test version, much faster: http://unitycoder.com/upload/demos/mShadowRayScan2/
This looks amazing!
Do you have the source for that second much faster version?
Yes, its this one: http://unitycoder.com/blog/2012/02/15/raycast-realtime-visibility-2-0/
thanks! This works so well. Is there a way to limit the raycasting to just one specific object?