Commit graph

23 commits

Author SHA1 Message Date
N8n5h c07de1cc25 Remove the inversion in shader of spot light uv for atlas
With the change in iron, there is no longer a need to do this in the shader.
2021-03-01 18:39:32 -03:00
N8n5h c64b47548e Added support for direct3d-like texture coords uv for shadow atlases
See http://thedev-log.blogspot.com/2012/07/texture-coordinates-tutorial-opengl-and.html,
the "opengl coordinates" where inverted for proper support of direct3d texture coordinate system.
2021-02-10 21:03:10 -03:00
N8n5h 1c3e24a8fd Add support for shadow map atlasing
With this it is now possible to enable atlasing of shadow maps, which solves the existing limitation of 4 lights in a scene. This is done by
grouping the rendering of shadow maps, that currently are drawn into their own images for each light, into one or several big textures. This was
done because the openGL and webGL version Armory targets do not support dynamic indexing of shadowMapSamplers, meaning that the index that
access an array of shadow maps has to be know by the compiler before hand so it can be unrolled into if/else branching. By instead simply
using a big shadow map texture and moving the dynamic part to other types of array that are allowed dynamic indexing like vec4 and mat4, this
limitation was solved.

The premise was simple enough for the shader part, but for the Haxe part, managing and solving where lights shadow maps should go in a shadow map
can be tricky. So to keep track and solve this, ShadowMapAtlas and ShadowMapTile were created. These classes have the minimally required logic
to solve the basic features needed for this problem: defining some kind of abstraction to prevent overlapping of shadowmaps, finding available
space, assigning such space efficiently, locking and freeing this space, etc. This functionality it is used by drawShadowMapAtlas(), which is a
modified version of drawShadowMap().

Shadow map atlases are represented with perfectly balanced 4-ary trees, where each tree of the previous definition represents a "tile" or slice
that results from dividing a square that represents the image into 4 slices or sub-images. The root of this "tile" it's a reference to the
tile-slice, and this tile is divided in 4 slices, and the process is repeated depth-times. If depth is 1, slices are kept at just the initial
4 tiles of max size, which is the default size of the shadow map. #arm_shadowmap_atlas_lod allows controlling if code to support more depth
levels is added or not when compiling.

the tiles that populate atlases tile trees are simply a data structure that contains a reference to the light they are linked to, inner
subtiles in case LOD is enabled, coordinates to where this tile starts in the atlas that go from 0 to Shadow Map Size, and a reference to a
linked tile for LOD. This simple definition allows tiles having a theoretically small memory footprint, but in turn this simplicity might make
some functionality that might be responsibility of tiles (for example knowing if they are overlapping) a responsibility of the ones that
utilizes tiles instead. This decision may complicate maintenance so it is to be revised in future iterations of this feature.
2021-02-04 17:53:59 -03:00
Moritz Brückner dac91efeb1 Fix indentation (spaces -> tabs) 2020-07-13 23:36:49 +02:00
Moritz Brückner 9a47d77594 Implement receive shadow setting for mobile path + all light types 2020-07-13 23:20:58 +02:00
luboslenco 00237fdd42 Fix ssrs 2019-05-30 20:22:57 +02:00
luboslenco 2da0e03d17 Micro shadowing 2019-05-21 21:53:57 +02:00
luboslenco 9a9e433b35 Fix ltc uniforms 2019-04-10 22:08:45 +02:00
luboslenco fc2635e673 Calibrate area light 2019-02-27 21:31:21 +01:00
luboslenco a1da8b0824 Expose cone aperture 2019-02-09 15:34:16 +01:00
luboslenco c9a896845d Attenuate for area light 2019-02-07 21:33:27 +01:00
luboslenco 7b7260d647 Update volumetric 2019-01-28 11:28:21 +01:00
luboslenco 4172e0a2c6 Fix LTC shadow 2019-01-27 23:48:54 +01:00
luboslenco da84a870f1 Fix LTC 2019-01-27 20:13:21 +01:00
luboslenco e17d06225c Expose voxel shadow 2019-01-27 19:12:00 +01:00
unknown 87a895d3b6 Shadowmap size cleanup 2018-12-28 13:31:43 +01:00
luboslenco 71b3d8a555 Packed pos fixes 2018-12-16 22:28:57 +01:00
luboslenco 9c9fd0881e Uniform fixes 2018-12-15 19:03:11 +01:00
luboslenco 7dcb443060 Use shadow samplers, remove arm_dev 2018-12-15 15:07:30 +01:00
luboslenco 975f995796 Faster and smaller vertex data 2018-12-14 15:27:43 +01:00
luboslenco 914030e7f4 Shadowmap arrays 2018-12-11 23:05:18 +01:00
luboslenco d8f78638bd Begin shadow index 2018-12-10 23:29:04 +01:00
luboslenco 6176a26e22 Improved light sampling 2018-12-10 17:25:29 +01:00