Commit graph

794 commits

Author SHA1 Message Date
lawnjelly
dc14636e68 BVH templated mask checks and generic NUM_TREES
Refactors the BVH to make it more generic and customizable. Instead of hard coding the system of pairable_mask and pairable_type into the BVH, this information is no longer stored internally, and instead the BVH uses callbacks both for determining whether pairs of objects can pair with each other, and for filtering cull / intersection tests.

In addition, instead of hard coding the number of trees, the BVH now supports up to 32 trees, and each object can supply a tree collision mask to determine which trees it can collide against.

This enables the BVH to scale to either the two or 3 trees needed in physics, and the single tree used without pairing in Godot 4 render tree.
2022-01-21 10:08:29 +00:00
Haoyu Qiu
ac144e7e8c
Fix invalid read when using LightOccluder2D
(cherry picked from commit 7870cf24f2)
2022-01-19 16:02:54 +01:00
Rémi Verschelde
a627cdafc5
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-13 15:54:13 +01:00
Rémi Verschelde
b197de6f5f
Fix typos with codespell
Using codespell 2.1.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
readded
seeked
statics
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2022-01-07 00:14:54 +01:00
Rémi Verschelde
25369acff9
Merge pull request #51708 from Calinou/viewport-add-32bpc-color-depth 2022-01-04 14:30:24 +01:00
Yuri Roubinsky
0c449befbf Allow pass varyings as out param to the function, when it's possible 2022-01-04 10:22:39 +03:00
Bastiaan Olij
4e4de3430e Fix size issue for ARVR managed viewport 2021-12-19 14:51:10 +11:00
Yuri Roubinsky
25e24f2d05 [3.x] Prevent writing incorrect shader hints 2021-12-16 10:22:01 +03:00
lawnjelly
cbb6dc35a1 Fix add_line width being too wide
The line width of thick lines was being applied on both sides of the line, resulting in a line that was twice as thick as requested.

This PR fixes this embarrassing oversight.
2021-12-14 12:35:02 +00:00
Rémi Verschelde
4ebee76370
Merge pull request #55822 from Chaosus/shader_fix_semicolon_3.x 2021-12-12 21:10:38 +01:00
Yuri Roubinsky
933fd6be75 [3.x] Restore shader parsing errors with lack of semicolon in a block 2021-12-11 18:05:49 +03:00
lawnjelly
26e93dc5c6 Fix lighting_dirty flag bug
In rare circumstances, changing the geometry data attached to an instance, there was the opporunity for the lighting_dirty flag to get out of sync, which could lead to access to a stale light RID, and warnings or worse.

This PR fixes the problem by ensuring the lighting is always updated on the instance when first adding GeometryData.
2021-12-11 11:27:21 +00:00
lawnjelly
3d981b8265 Add option to use handles to RID
Adds an option to compile an alternative implementation for RIDs, which allows checks for erroneous usage patterns as well as providing leak tests.
2021-12-06 14:43:34 +00:00
Yuri Roubinsky
de9205f72d Fix ^= operator in shaders 2021-12-03 10:34:56 +03:00
Rémi Verschelde
3be0f85e91
Merge pull request #54377 from lawnjelly/faster_editor_lines 2021-11-30 13:30:02 +01:00
Yuri Roubinsky
5928cc90f8 [3.x] Prevent return statement from using in block in shader main func 2021-11-23 10:40:47 +03:00
Camille Mohr-Daurat
3970f28f67
Merge pull request #55096 from lawnjelly/bvh_expanded_leaf
BVH - add option for expanded AABBs in leaves
2021-11-22 09:37:16 -07:00
lawnjelly
211dc8cd2d BVH - add option for expanded AABBs in leaves
This PR adds a define BVH_EXPAND_LEAF_AABBS which is set, which stores expanded AABBs in the tree instead of exact AABBs.

This makes the logic less error prone when considering reciprocal collisions in the pairing, as all collision detect is now taking place between expanded AABB against expanded AABB, rather than expanded AABB against exact AABB.

The flip side of this is that the intersection tests will now be less exact when expanded margins are set.

All margins are now user customizable via project settings, and take account of collision pairing density to adjust the margin dynamically.
2021-11-20 06:45:12 +00:00
Hugo Locurcio
d7d35e4f73
Add const qualifier support for function arguments in shaders
This prevents the function argument from being reassigned within
the function.

Example:

    void test(const int t) {}
2021-11-19 21:20:23 +01:00
Rémi Verschelde
4103b0b7d8
Merge pull request #50823 from fbcosentino/3d-material-overlay 2021-11-16 08:21:18 +01:00
Fernando Cosentino
cc8846bef6 Added material_overlay property to MeshInstance
Applying overlay materials into multi-surface meshes currently
requires adding a next pass material to all the surfaces, which
might be cumbersome when the material is to be applied to a range
of different geometries. This also makes it not trivial to use
AnimationPlayer to control the material in case of visual effects.
The material_override property is not an option as it works
replacing the active material for the surfaces, not adding a new pass.

This commit adds the material_overlay property to GeometryInstance
(and therefore MeshInstance), having the same reach as
material_override (that is, all surfaces) but adding a new material
pass on top of the active materials, instead of replacing them.

Implemented in rasterizer of both GLES2 and GLES3.
2021-11-15 23:50:34 +00:00
Rémi Verschelde
89792e5c49
Merge pull request #54921 from lawnjelly/portals_roaming_margin 2021-11-15 22:45:46 +01:00
Yuri Roubinsky
824183854c
Removed incorrect autocompletion of matrixes in shader
(cherry picked from commit 04a2053f9b)
2021-11-15 16:30:00 +01:00
lawnjelly
788f075b44 Portals - Allow user to set roaming expansion margin
Previously a crude metric was used to decide on the roaming expansion margin, but it created unexpected results in some scenarios. Instead this setting is exposed to the user via the RoomManager, allowing them to tailor it to the world size, room sizes, roaming objects sizes and the speeds of movement.
2021-11-12 15:46:04 +00:00
Rémi Verschelde
1f8497d281
Merge pull request #53411 from RandomShaper/ubershaders_3.x 2021-11-09 13:12:44 +01:00
Pedro J. Estébanez
4c710780d4 Implement async shader compilation plus caching for GL ES 3
Async. compilation via ubershader is currently available in the scene and particles shaders only.

Bonus:
- Use `#if defined()` syntax for not true conditionals, so they don't unnecessarily take a bit in the version flagset.
- Remove unused `ENABLE_CLIP_ALPHA` from scene shader.
- Remove unused `PARTICLES_COPY` from the particles shader.
- Remove unused uniform related code.
- Shader language/compiler: use ordered hash maps for deterministic code generation (needed for caching).
2021-11-09 12:19:12 +01:00
NHodgesVFX
237f7eeabe Add more OpenGL Attributes
Co-Authored-By: Johann Meyer <25986904+johannmeyer@users.noreply.github.com>
Co-Authored-By: Clay John <claynjohn@gmail.com>
2021-11-08 01:22:40 -05:00
lawnjelly
ab76cd6ff2 Faster editor line drawing - Path2D and draw_line
Changes the Path2D drawing to use POLYLINE instead of thick lines.
Add a path to translate thick lines (that are not using anti-aliasing) to draw as polygons instead. This should be faster because polygons can be batched.
2021-10-29 12:40:24 +01:00
Rémi Verschelde
42d385b312
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 13:23:38 +02:00
Bastiaan Olij
3bd6088663 Only update render target directly if ARVR mode is off 2021-10-26 21:40:25 +11:00
Rémi Verschelde
06fc2378de
Merge pull request #51491 from Calinou/glow-add-high-quality-mode-3.x
Add high quality glow mode (3.x)
2021-10-08 07:47:07 +02:00
Rémi Verschelde
69437eb746
Merge pull request #53012 from lawnjelly/portals_unload_reason 2021-10-05 12:00:43 +02:00
lawnjelly
c835f1f3c5 Add DEV_ASSERT and DEV_CHECK macros
Change the existing DEV_ASSERT function to be switched on and off by the DEV_ENABLED define. DEV_ASSERT breaks into the debugger as soon as hit.
Add error macros DEV_CHECK and DEV_CHECK_ONCE to add an alternative check that ERR_PRINT when a condition fails, again only enabled in DEV_ENABLED builds.
2021-10-04 14:57:54 +01:00
lawnjelly
279e6f65cd Portals - add reason string to unload message
To help users identify conditions that are causing room system invalidation, a reason message is passed to the unload function and logged.
2021-09-24 14:00:24 +01:00
lawnjelly
d878fe7b90 Sphere occluders - self occlusion and improvements
Sphere occluders are now tested for self occlusion. Spheres that are behind another sphere in the current view are superfluous so can be removed, cutting down on the runtime calculations.

AABBs are now maintained for Occluders as well as individual spheres, meaning a bunch of occluder spheres can be frustum rejected as a block.
2021-09-14 11:31:14 +01:00
Rémi Verschelde
c0fc475078
Merge pull request #51521 from lawnjelly/portals_occluders
Sphere occluders (portals and general use)
2021-08-17 13:55:34 +02:00
lawnjelly
115f4dce55 Sphere occluders (portals and general use)
Add framework for supporting geometrical occluders within rooms, and add support for sphere occluders.
Includes gizmos for editing.

They also work outside the portal system.
2021-08-17 09:02:06 +01:00
Rémi Verschelde
51dd4d0c6c
Merge pull request #49509 from Chaosus/shader_time_3.x 2021-08-16 19:42:55 +02:00
paru
ab21a3b8fb Performance improvements for GLES2 CPU blendshapes 2021-08-16 08:22:45 +02:00
Hugo Locurcio
5335a0368c
Add a Viewport property to use full floating-point precision in HDR
This is only available on the GLES3 backend.

This can be useful for advanced shaders, but it should generally
not be enabled otherwise as full precision has a performance cost.
For general-purpose rendering, the built-in debanding filter should
be used to reduce banding instead.
2021-08-16 03:16:01 +02:00
lawnjelly
546e207d8f Portals - Fix cull roaming through multiple portals
Small bug in the logic, the roaming objects only should be set to done when they have been marked as visible, rather than the first time they are examined. This is because they can be seen in a room through multiple portals, and each needs to be tested until there is either a visible result or all the portals in are visited.
2021-08-15 10:22:27 +01:00
Yuri Roubinsky
8a1c986455 [3.x] Fix shader crash when using local var with the same name as varying 2021-08-13 09:30:35 +03:00
Rémi Verschelde
dc1fc97836
Merge pull request #50397 from JestemStefan/41756_issue_fix
[3.x] Skip rendering of `Light2D` with zero size texture
2021-08-12 20:30:52 +02:00
JestemStefan
9bf47923a5 Skip rendering of lights with zero size 2021-08-12 17:25:58 +02:00
Yuri Roubinsky
34f7ceefe0
Allow using more assignment operators on matrixes in shaders
(cherry picked from commit 0f42a29864)
2021-08-12 16:42:17 +02:00
Yuri Roubinsky
144e0856a4
Fix shader crash when using varying array in fragment->light context
(cherry picked from commit fead1595f9)
2021-08-12 16:42:17 +02:00
Hugo Locurcio
0e0af7fa83
Add high quality glow mode
This backports the high quality glow mode from the `master` branch.

Previously, during downsample, every second row was ignored.
Now, when high-quality is used, we sample two rows at once to ensure
that no pixel is missed. It is slower, but looks much better and has
a much high stability while moving.

High quality also takes an additional horizontal sample the width of the
horizontal blur matches the height of the vertical blur.
2021-08-11 17:00:41 +02:00
Rémi Verschelde
7c6bdea33c
Merge pull request #47416 from Calinou/add-contrast-adaptive-sharpening-3.x
Add support for contrast-adaptive sharpening in 3D (GLES3 only)
2021-08-10 10:08:24 +02:00
lawnjelly
f3e6547a99 Portals - fix PVS generation and move settings
Fixed a bug in the complex PVS generation which was causing recursive loop.
Move some of the settings out of RoomManager into Project Settings.
Allow PVS generation method to be selected from Project Settings, and control PVS logging.
2021-08-08 19:57:27 +01:00
lawnjelly
cfe806a929 Portals - Fix secondary PVS bug
Fixes a bug whereby it read from the primary PVS in the gameplay monitor, using the size from the secondary PVS. This would read out of bounds and crash.

Removed debug code to update the gameplay monitor from the preview camera - this is no longer required.

Temporarily revert to the simple PVS generation method, because I've noticed a bug in the complex version, and the simple version is safer while I fix this.
2021-08-08 14:02:38 +01:00