- Home /
How to accomplish Monaco-style line-of-sight in Unity Free?
See http://www.facebook.com/notes/monaco/vector-lighting-explained/395139091995 for a description of what I mean.
In 2D graphics I would accomplish this using a mask like the first image shown in the link above, but being new to 3D game development, I'm not sure what the correct approach is. The literal 3D equivalent, generating a black mesh for the non-visible area and rendering it to a camera at a lower (higher?) level than the main camera, seems like it would work, but also like it could be very inefficient.
Is there a better way? Perhaps with shaders? I don't need it all spelled out for me, just a rough description of the approach and the tools involved.
Edit: I should add, that as a hobbyist Unity Pro is currently not in my price range, so I'm looking for solutions that do not involve RenderTextures or other Pro-only features.
Were you ever able to figure this out? I am currently facing a similar problem.
Answer by tanoshimi · Oct 24, 2013 at 11:59 AM
Actually, if you look at the following post you'll see the Monaco line-of-sight algorithm explained better : https://www.facebook.com/notes/monaco/line-of-sight-in-a-tile-based-world/411301481995 (the one you linked is more about lighting)
It's not a straightforward implementation, but I don't see why you couldn't use this approach in Unity Free without technical issues - it doesn't require rendertextures, full screen effects or any other Pro features - it's all just done in code based on the scene geometry.
I'm a bit unclear whether you want to calculate genuine 3D LoS (i.e. a 3D viewshed from a given position), or if you want to just create the top-down view of a 3D scene with areas lit based on whether they have unobstructed view to the point in the given 2d plane? If you just want to create a graphical effect (and if you had Unity Pro), you could just place a strong light at the observer's location and let Unity calculate shadows for those obstructed areas. You could use a custom shader to modify the appearance of those areas in shade. However, this would require Unity Pro, and also this won't you help you if you want to apply game logic, like enemies reacting when the player enters their range of vision - it could only be used for graphical effect.
$$anonymous$$y problem is not how to compute the line-of-sight polygon (as described in the link you provided), but how to use it. The problem is, given such a polygon, how to render what is within it (in a 2D sense) and not render everything else (so that another camera can be used to show a texture in this area).
In the link I provided, the author renders to a texture. As such, I'm sure the fancy lighting effects he does are largely infeasible with Unity Free. I'm wondering if the line-of-sight functionality can be accomplished without rendering to a texture.
Your answer
Follow this Question
Related Questions
Reflection Probes: only cull mask anchored object 0 Answers
How to get masked sprite? 1 Answer
How to implement Layering in Timeline Animations? 2 Answers
Have a shader with have a limited effectiveness 0 Answers
About masking animation on import 0 Answers