Changelog 13 In Which A Tradition Is Upheld
Another changelog is out, showing off the new stealth system and the new rendering pipeline/effects system.
- Basic Stealth Mechanics
- Effects System
- Nightvision -Sonar Vision
Under The Hood
The light based stealth system was actually surprisingly easy to implement. All lights in the system derive from the same interface (ILightEmitter) and so the first thing was to modify this interface to let me ask it appropriate questions:
Ray? LightingRayToPoint(Vector3 point, out float length); float Brightness(Vector3 direction, float distance);
The first method gets the ray from the light to the point in question, and also the length along the ray from the light to the point. This means that if, for example, the player is standing in the sunlight you get a ray pointing from the sky to the player (as well as distance infinity). If the player is standing outside of the cone of a spot light then the method returns null, which indicates that this light cannot possibly be lighting that point. The second method gets how bright the light is at the given distance, this is rather different for different light types:
- Sunlight: Always returns sun brightness
- Pointligjt: Dimmer with distance from light
- Spotlight: Dimmer with distance from light and angle from center of light
The final part of the whole thing is to determine if the point is in shadow. This isn’t actually done with the rendering system at all, instead the ray is passed into the physics engine - if the ray gets all the way from the light to the player then the player must be lit and if they ray hits something else first then the player must be in shadow.
blog comments powered by Disqus