Commit Graph

371 Commits

Author SHA1 Message Date
QuantumCoderQC 3c0f580f69 fix morph weights lookup 2021-11-02 13:42:09 +01:00
QuantumCoderQC 4522055fac use vec4 uniform array instead of float array 2021-11-02 13:42:07 +01:00
QuantumCoderQC 8c034655be implement morph_target.glsl 2021-11-02 13:42:05 +01:00
QuantumCoderQC 09433f2a19 init morph target glsl 2021-11-02 13:42:05 +01:00
Moritz Brückner b7024a5854 Whitespace cleanup 2021-09-02 17:18:59 +02:00
Moritz Brückner 44d8325001 Fix "Uniform PPCompXX not found" warnings 2021-09-02 17:14:18 +02:00
Moritz Brückner 1de97e1898 Minor cleanup 2021-08-15 00:30:41 +02:00
Moritz Brückner ca96174b6b Fix nishita sky artifacts on some GPUs
It could happen that values returned by dot() were slightly larger than 1 or less than -1 due to precision errors, but acos() is undefined outside of [-1, 1]. This would lead to NaN values on some GPUs, causing visible artifacts.
2021-08-14 23:45:33 +02:00
Moritz Brückner d610cc6a2f Fix value range in Nishita LUT 2021-08-09 16:51:26 +02:00
N8n5h 5509096158 fix volumetric lights not working with shadow map atlas enabled
Added missing code so the shader refers to the correct variable when
using shadow map atlasing.
2021-08-06 18:34:39 -03:00
Moritz Brückner b3162d8f6e Fix visual artifacts caused by invalid gbuffer2 on OpenGL 2021-07-10 22:41:19 +02:00
Moritz Brückner ccc427c04a Cleanup 2021-05-27 22:57:53 +02:00
Lubos Lenco 98eeccd71d
Merge pull request #2082 from armory3d/blender2.9
Blender 2.9 LTS support
2021-05-10 11:14:39 +02:00
N8n5h ddc3da7799 Fix artifact with point light soft shadow in sm atlas 2021-04-26 16:45:20 -03:00
Moritz Brückner f64419dd06 Merge branch 'master' into blender2.9
# Conflicts:
#	blender/arm/material/shader.py
#	blender/arm/props_collision_filter_mask.py
#	blender/arm/props_ui.py
2021-04-03 14:12:54 +02:00
Moritz Brückner c5be90d0b0 Cleanup 2021-03-31 20:33:52 +02: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
Moritz Brückner 420033c86d Add API to set Nishita density parameters 2021-03-26 20:59:26 +01:00
Moritz Brückner 8d812548c4 Use 2D LUT for Nishita skies 2021-03-25 23:29:34 +01: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
Moritz Brückner 5f55b00710 Begin with Nishita LUT implementation for better performance 2021-03-11 23:16:44 +01: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
Moritz Brückner 742b9ce1e1 Nishita sky: add support for ozone density 2021-02-22 18:52:56 +01: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 28011bcc00 Nishita sky: add sun disk drawing 2021-02-13 18:23:37 +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
Moritz Brückner 288ead64dc Nishita sky: implement air and dust density 2021-01-21 21:14:05 +01:00
Moritz Brückner 396e60574a Optimize Nishita sky shader 2021-01-21 20:36:03 +01:00
Moritz Brückner 22d3530863 Blender 2.9: Add Nishita sky model implementation 2021-01-21 16:12:32 +01: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