Commit graph

348 commits

Author SHA1 Message Date
N8n5h ddc3da7799 Fix artifact with point light soft shadow in sm atlas 2021-04-26 16:45:20 -03:00
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
Lubos Lenco 7d78e01bb4
Merge pull request #2128 from N8n5h/light-fix-2
Fix shadows not working when there are lights present with cast_shadow=false
2021-03-16 08:28:19 +01:00
N8n5h 7463de6140 Add cast_shadow to lightArray data
This was done to undo the hardcoded nature of "receiveShadows", which
doesn't play nice when you have multiple lights of the same type and
one or several have cast_shadow set to false.

By simply "passing" the cast_shadow parameter within the lightArray it
was possible to detect lights that don't cast shadows before actually
wasting gpu cycles to render shadows with garbage data.

Support for deferred desktop and mobile, and forward was added.
2021-03-14 23:20:57 -03:00
N8n5h efcef7dd25 Fix shadow rendering for deferred and forward mobile 2021-03-14 22:04:47 -03:00
N8n5h 8e972f75fd Fix light visual artifact when close to the camera
This fixes a current problem with lights that occurs when getting too
close to the camera. The issue is related to the clustering algorithm
and cluster near.

Cluster near explanation:

Because of the logarithmic nature of how the Z slice is calculated,
clusters slices get "burned" too quickly at the start of the frustum,
which is not ideal. To aid this, and offset is applied to the start of
the cluster frustum, and that is clusterNear.

Cluster near solves that problem but creates another one: There is a gap
between the near plane and the cluster near offset that gets completely
ignored when calculating. And this results in the visual artifact of
slices not being affected by light whatsoever.

The proposed solution is make the gap resolve to the first slice of Z
clusters.
2021-03-13 13:30:19 -03:00
N8n5h cf99e5a382 Fixed point lights breaking for Krom Windows with shadow map atlas
https://github.com/armory3d/armory/issues/2110#issuecomment-787913813
2021-03-01 18:39:32 -03:00
N8n5h 5f8b92f9c3 Applied flip workaround for point light too for html5 and atlas
The same concept for spot lights was applied for point lights;
the difference is that because point lights require to do the projection in the shader, the first inversion was applied in sampleCube() when returning the uv coordinates.
"_FlipY" was added to replace "_InvY" in "PCFFakeCube()" because the inversion is only necessary for shaders and not anything else, otherwise it would break rendering of other parts.
2021-03-01 18:39:32 -03:00
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
Alexander Kleemann aec10274f4 Add option to ignore irradiance for baked environments 2021-02-20 15:30:18 +01:00
Lubos Lenco 49a599dc66
Merge pull request #2102 from N8n5h/light-fix-2
Add support for shadow map atlasing
2021-02-14 16:32:59 +01:00
Moritz Brückner b4d5afd561 Remove unused fragment shader input 2021-02-12 20:54:02 +01:00
Moritz Brückner b70a60078b Fix and improve comments 2021-02-12 20:24:42 +01:00
Moritz Brückner 52e4aaa21c Add button to create a new custom material 2021-02-12 20:12:55 +01: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
N8n5h b05f719392 Solve artifact for deferred mobile too 2020-12-27 16:45:27 -03:00
N8n5h 893b313643 Solve artifact with clustering of lights
Changed how a spot light is detected when sampling light, which caused false positives and produced
that visual artifact when a cluster/pixel was detected incorrectly as being lit with a spot light when maybe none were there.
This issue seems somewhat related to that issue that prevents rendering spotlights and point lights shadow at the same time.
2020-12-27 16:02:35 -03:00
onelsonic a89e3923e7
Update math.glsl
fixing the float
2020-12-16 18:57:25 +01:00
Moritz Brückner bfdcc1f1bd Fix tabs and spaces shenanigans 2020-11-29 13:40:49 +01:00
Moritz Brückner 4cef68c818 Cleanup chromatic aberration shader 2020-11-28 23:13:32 +01:00
Moritz Brückner 1505f94b2b Fix spaces/tabs 2020-10-21 16:18:30 +02:00
Moritz Brückner 93f0bcba78 Fix volumetric light for different lamp combinations 2020-10-21 15:30:11 +02:00
luboslenco fbe144decc Fix material id access in deferred light 2020-07-20 23:15:36 +02:00
Moritz Brückner dac91efeb1 Fix indentation (spaces -> tabs) 2020-07-13 23:36:49 +02:00
Moritz Brückner 3654d34997 Update more shaders for receive shadow option 2020-07-13 23:28:43 +02:00
Moritz Brückner 9a47d77594 Implement receive shadow setting for mobile path + all light types 2020-07-13 23:20:58 +02:00
Moritz Brückner 068fe0fada Remove replaced world_pass 2020-07-06 17:10:29 +02:00
Lubos Lenco e30a8c7f46 Metal fixes 2020-05-11 09:03:13 +02:00
Lubos Lenco c970c5db6c Pass irradiance uniform as argument 2020-05-10 19:43:02 +02: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
Lubos Lenco 967f69b24a Color attachment format 2020-05-06 18:11:02 +02:00
Lubos Lenco 9a71b5b664 World pass cleanup 2020-05-05 21:33:15 +02:00
Lubos Lenco 66e9572554 Add clear pass for metal 2020-05-04 23:08:47 +02:00
Lubos Lenco 61ff96786f Metal fixes 2020-05-04 00:19:11 +02:00
N8n5h decf89305c Fix support for box/triplanar mapping
I modified the shader parser so that triplanar mapping of textures is supported.
Normals are supported.
Currently tested with Armory PBR and Principled BSDF.
2020-03-14 23:44:15 -03:00
Alexander 60f72e7e0e Merge in PPM
Redone and ready to be merged with Armory
2020-03-04 17:45:19 +01:00
N8n5h afdc54bc35 Fixed DebugDraw line drawing method
Now lines should always face the camera.
2020-01-05 11:48:29 -03:00
luboslenco 1c4df223cc Add denoise shader 2019-12-02 14:34:56 +01:00
Alexander 000ec17e3d Chromatic aberration 2019-08-08 20:02:42 +02:00
Alexander f521828edc Lens dirt masking 2019-08-08 18:56:56 +02:00
unknown 8e2f037d9b Fix packing inline 2019-07-14 16:45:34 +02:00
luboslenco f82be5bc64 Improve packing 2019-07-07 22:02:07 +02:00
luboslenco 17a11473c5 Add packing helpers 2019-07-03 09:28:33 +02:00
indokan1945 9cdd8a4bab
Motion Blur Pattern Fix
Same fix as the camera motion blur
2019-06-06 09:22:49 +07:00
indokan1945 c488ea6a90
Blur Pattern Fix
When you flip the y coordinate of coord in getVelocity() function, the y of the velocity vector will also get flipped. If we let this on, the result of the motion blur will be weird, creating X pattern blur rather than O pattern blur, noticeable especially when looking down/up and rotating around camera front axis. To fix this, negative the y of velocity vector manually and problem solved.
2019-06-06 09:05:44 +07: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 9802016556 Cleanup 2019-05-19 15:23:56 +02:00