Commit graph

32 commits

Author SHA1 Message Date
N8n5h ead7dc9d32 Moved biasLWVP matrix uniform reference to a new one for sun
This was done because the original "_biasLightWorldViewProjectionMatrix"
relies on renderpath.light, which is problematic when rendering the
deferred light pass and there is a sun and other lights of different
type on the scene. Which would result on the wrong light being picked up
for the calculation of the uniform value.
2021-03-29 10:55:58 -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
luboslenco b0cd02d68e Allow multiple color attachment formats 2020-05-10 10:46:12 +02:00
Lubos Lenco df6346c1d1 Color attachment format 2020-05-06 21:30:59 +02:00
luboslenco aa5c4f7e73 Link to embedded data 2019-04-26 11:12:09 +02:00
luboslenco 4172e0a2c6 Fix LTC shadow 2019-01-27 23:48:54 +01:00
luboslenco 2eab2c1adb Shadow fixes 2019-01-09 21:25:09 +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
luboslenco 0cc0915e44 Need for speed 2018-12-05 17:47:45 +01:00
luboslenco 7f261b4365 Save gbuffer slot 2018-11-22 18:07:32 +01:00
luboslenco 850dade8a5 Merge clustered rendeder - wip, unstable 2018-11-22 11:08:03 +01:00
luboslenco ac38825cef Cleanup 2018-11-19 15:41:26 +01:00
luboslenco 4904b50f1a Cleanup 2018-11-19 14:28:04 +01:00
luboslenco e6c1f2dccc Pass shadowmap size 2018-11-07 13:11:38 +01:00
luboslenco fe9fa0eea9 Apply reflection plane 2018-10-03 13:59:34 +02:00
luboslenco d2a96abcde Rename Lamp to Light to keep in sync with Blender2.8 2018-08-28 15:10:28 +02:00
Lubos Lenco 42b4185187 Reduce shader count 2017-12-20 15:37:58 +01:00
Lubos Lenco c67ff89361 LTC and hosek defines 2017-11-27 14:29:21 +01:00
Lubos Lenco 71929bd32f Shaders clean up 2017-11-20 12:38:35 +01:00
Lubos Lenco 0c7d488a1a Fix sss uniforms 2017-11-17 16:15:35 +01:00
Lubos Lenco c3bdf0efda Reduce point lamp noise 2017-11-15 16:43:46 +01:00
Lubos Lenco af2bd70e52 Crude ies lamp support 2017-08-17 14:37:04 +02:00
Lubos Lenco fc27d9afc1 More sdf 2017-06-06 18:29:33 +02:00
Lubos Lenco 391fea23d2 Normal maps for deferred+ 2017-04-01 10:06:49 +02:00
Lubos Lenco 9afaaabbcb Capture cubemap shadows 2017-03-18 18:44:21 +01:00
Lubos Lenco 7c28d2e140 Dir light as quad 2017-03-15 15:49:13 +01:00
Lubos Lenco 359bb45871 Renderer speedup round 2 2017-03-12 17:29:22 +01:00
Lubos Lenco fc167d2885 Renderer speedup round 1 2017-03-11 01:50:47 +01:00
Lubos Lenco 6f6eb066c6 Ray-traced shadows 2017-01-17 14:48:47 +01:00
Lubos Lenco f4898a130c Begin true material builder 2016-12-13 01:09:17 +01:00
Renamed from Shaders/deferred_light/deferred_light.shader.json (Browse further)