

Interactive Real Time 2D / Pseudo-3D Ray Caster written from scratch in C++ and can run on either a CPU or a GPU.
Tile Map can be Edited dynamically at Runtime through the Viewport with Collision Detection updating accordingly.
Portals that are dynamically placed on walls by shooting portal-projectiles can be traversed by the Player and all Projectiles.
All Ray Casting is done in 2D but Lighting & Shading is done with 3D positions and directions.
A single row of pixels cast 2D horizontal rays against a Tile Grid (for Walls) and Circles (for Columns) and results are reused across the screen height.
A single column of pixels casts 2D vertical rays against the Floor & Ceiling with depth perspective and results are reused across the screen width.
Vertical and Horizontal results are combined per-pixel to form 3D positions and directions, used for Lighting & Shading and other 3D effects.
Looking Up & Down is done without accounting for proper perspective by simply offsetting the horizon line, to maintain screen invariants.
Point Lights with Shadows for Player Torch Light and Projectile Flares are positioned and moved in 3D.
Physically based shading uses a microfacet BRDF model (Cook-Torrance, Schlick/Smith GGX).
Silhouette Parallax Occlusion Mapping with soft shadows using Normal + Height maps wrapping around implicit rounded corners.
Refractive Blobs with Spherically Emitted Volumetric Fog of dynamic density using animated 3D Perlin Noise.
Atmospheric Exponential Ground Fog of layered densities using animated 3D Perlin Noise.
All Texturing is done in software with mipmapping and bi-linear filtering (on either CPU or GPU).



As in the well-loved Portals games from Valve, special projectiles can be shot at walls to form entry and exit portals on the walls.
They can be traversed through seamlessly and all projectiles, lighting and shadowing account for them properly.
This is all accomplished by "teleporting" rays from hit points on the entered portal to corresponding positions and orientations on the exit portal.
This applies uniformly to all directions including movement of player and projectiles as well as rays of light and shadows.
Projectiles teleport through portals, including light flares as well as new portal projectiles.
Portals may be placed in front of each other, creating an "infinite hall of mirrors" that both the player and projectiles may teleport through.
Portals:








Silhouette Parallax Occlusion Mapping with Shadows:


3D view directions trace into virtual volumes in tangent space against implicit surfaces formed from height maps.
Closest intersections are queried to find 2D offsets into the texture UVs to displace the sampling of Color and Normal maps for shading.
Intersections points are also used to trace back through the volumes towards the point lights in the scene for lighting and shadows.
Columns and rounded corners inversely-bend the ray directions as they travel through the volumes checking for misses to form the Silhouettes.


Atmospheric Exponential Fog:


Atmospheric exponential fog accumulates density through animated 3D noise across 2 layers of varying densities and movement directions.


Refractive Volumetric Blobs:


Blobs of dynamically warped implicit surfaces are ray casted against.
Dynamically offset rays emulate refraction through the blobs.
Volumetric god rays project spherically through animated 3D noise.
Implicit Rounded Corners:
Implicit rounding of the corners of the regular grid 2D tile map with seamless wrapping of tiling textures.


Columns and Blobs can be placed and moved dynamically with collision detection and resolution based on 2D ray casting against the scene.
Ray Cast Object Placement:


CPU / GPU (Toggle):
Depending on the compiler and render settings, frame rates may be low.
Rendering may be toggled between CPU or GPU dynamically at runtime.


Tile Map Walls and Columns can be Edited at Runtime in the Viewport.
Collision Detection for Player and Projectiles update dynamically.
