Difference between revisions of "Field of Vision"

From RogueBasin
Jump to navigation Jump to search
m (Changed 'the' to 'of the')
 
(28 intermediate revisions by 20 users not shown)
Line 1: Line 1:
It's common to check the [[visiblity]] of many objects from one point on the map. For example, you might want to know which parts of map are visible from the place the player character is standing, to draw those parts of map on the screen.
Some of the most important features on roguelikes, including the presentation of the area that surrounds the player character, require to check the visibility of an object from a given point on the map. For example, it may be necessary to know which parts of map are visible from the place the player character is standing to draw those parts of map on the screen.


You might just use the [[Line of Sight]] to check all the map squares in range, but that's pretty slow, and you're repeating most of the calculations mulitple times. It is much better to calculate the [[Field of Vision]] as a whole.
There are basically two ways to achieve this; by using [[Line of Sight]] to check all the map squares in range, which is a slow method as it repeats most of the calculations multiple times, or by calculating the [[Field of Vision]] as a whole.


There are several ways to do it:
== Approaches ==


Some of the most common approaches to field of vision are:
* Light whole level. Just make everything visible, or at least everything close to the player. Many games use this approach and it seems to work.
* Light whole level. Just make everything visible, or at least everything close to the player. Many games use this approach and it seems to work.
* Light whole room. This is the approach used by the original [[Rogue]]. You just make the whole room in which the player character is visible, and all other parts of map not visible. When the character is in a corridor, it can only see one square from where he stands, this doesn't require any sophisticated calculations.
* [[Extremely fast simplified LOS]] -- Take advantage of the way most roguelike maps are drawn (square rooms connected with corridors).
* [[FastLOS]] -- precalculated approximate LOS using a bitwise AND.
* [[Ray casting]]
* [[Shadow casting]]
* [[Restrictive Precise Angle Shadowcasting]]
* [[Permissive Field of View]] (new and uncommon)
* [[Digital field of view]] (new and unheard of)
* [[eligloscode|Very simple line of sight pseudo-code.]]
* [[Quick and dirty FOV/LOS]]
* [[LOS using strict definition]] (new and unheard of)
* [[My Algorithm by Adam Milazzo in Dart]]
* [https://github.com/RIanGillisAlgorithms/shadowcasting_fov_3d ShadowCastingFOV3D by RIanGillis]
== Refinements ==
There are other refinements that can be applied to any approach:
* [[An Efficient Observation Algorithm]] may allow fewer squares to be visited.


* Light whole room. This is the apporach used by the original [[Rogue]]. You just make the whole room in which the player character is visible, and all other parts of map -- not visible. When the character is in a corridor, it can only see one square from where he stands -- this doesn't require any sophisticated calculations.
== Studies ==
* [[Comparative study of field of view algorithms for 2D grid based worlds]]


* [[Ray casting]]
== Available Libraries ==


* [[Shadow casting]]
* [[SquidLib]] is a [[Java]] library made by [[Eben Howard]] which supports several types of FoV, including translucence properties. The shadowcasting implementation is shorter and easier to read than most other implementations.
* [[libfov]] is a [[C]] library made by [[Blue Puyo]], which supports both circular FoV and Beams using [[Shadow casting]]
* [[permissive-fov]] is a library for both C and C++ written by [[duerig|Jonathon Duerig]]. It uses [[Permissive Field of View]], and supports arbitrary shaping of FoV using visitation masks. It does not support Beams.
* [[libtcod]] is a C/C++/python library which, while not dedicated to fov, contains implementations of basic raycasting, los_rays (a.k.a. diamond raycasting), recursive shadowcasting, restrictive precise angle shadowcasting and precise permissive fov.
* [http://rlforj.sourceforge.net/ rlforj] - Java library featuring several FoV algorithms.


* [[Recursive shadow casting]]
== See Also ==


[[libfov]] can do a lot of the work for you.
* [[Discussion:Field_of_Vision]]


[[Category:Algorithms]]
[[Category:Articles]][[Category:FOV]]

Latest revision as of 20:25, 28 November 2024

Some of the most important features on roguelikes, including the presentation of the area that surrounds the player character, require to check the visibility of an object from a given point on the map. For example, it may be necessary to know which parts of map are visible from the place the player character is standing to draw those parts of map on the screen.

There are basically two ways to achieve this; by using Line of Sight to check all the map squares in range, which is a slow method as it repeats most of the calculations multiple times, or by calculating the Field of Vision as a whole.

Approaches

Some of the most common approaches to field of vision are:

Refinements

There are other refinements that can be applied to any approach:

Studies

Available Libraries

  • SquidLib is a Java library made by Eben Howard which supports several types of FoV, including translucence properties. The shadowcasting implementation is shorter and easier to read than most other implementations.
  • libfov is a C library made by Blue Puyo, which supports both circular FoV and Beams using Shadow casting
  • permissive-fov is a library for both C and C++ written by Jonathon Duerig. It uses Permissive Field of View, and supports arbitrary shaping of FoV using visitation masks. It does not support Beams.
  • libtcod is a C/C++/python library which, while not dedicated to fov, contains implementations of basic raycasting, los_rays (a.k.a. diamond raycasting), recursive shadowcasting, restrictive precise angle shadowcasting and precise permissive fov.
  • rlforj - Java library featuring several FoV algorithms.

See Also