shaunlebron / blinky

Exploring peripheral vision in games (using Quake)
MIT License
687 stars 26 forks source link

[enhancement] Generic environment maps #46

Closed shaunlebron closed 13 years ago

shaunlebron commented 13 years ago

I'm starting to question the validity of using a cubemap in this project. I think that cubes are used as environment maps in the context of skyboxes and reflection maps because they're simple to implement and are great for static images. But in a dynamic context like Quake Lenses, the overhead of generating six 90x90 degree views every frame is very significant to performance.

The "fast mode" in this project is my first cubemap alternative that was created as a fast way get most of the front half of the environment map. This is done by creating a 160x160 projection, and composing it with a 90x90 projection to make up for the center compression from the 160x160 view. Quality varies noticeably in the periphery. This raises the question of whether there are other ways to create an environment map.

One possibility is a triangular prism, a 360x120 degree map if you consider only the rectangle faces. This can be created by rendering three 120x120 degree sides. Of course the aspect ratio of these views can vary, corresponding to an increase in height of the prism but a loss in quality.

Since there will inevitably be many ways to construct an environment map, I would like to make it extendable like with the lens scripts. We will call them map scripts.

A map script will need to define each view to be rendered. A view will have an aspect ratio, fov, and orientation. This introduces the possibility of overlap, so we need a ray_to_map function in the script, and possibly a map_to_ray function also. The map coordinates used by these two functions will be euclidean coordinates in the view plane, along with the index of that view.

shaunlebron commented 13 years ago

The name "map" scripts might be confusing in the context of Quake since they are associated with level geometry. I renamed them to "globe" scripts since you can imagine an environment map as plates nailed to a globe. The globe script has a "plates" array with forward vector, up vector, and fov. It also has "ray_to_plate" and "plate_to_ray" functions for mapping a ray of light to a point on the globe.