Commit graph

2382 commits

Author SHA1 Message Date
lawnjelly
f33e22001f Fix 2d software skinning relative transforms
All my earlier test cases for software skinning had the polys parent transform to be identity. This works fine until you had cases where the user had moved the transform of the parent nodes of skinned polys.

This PR fixes this situation by taking into account the final (concatenated) transform of the polys RELATIVE to the skeleton base transform. It does this by applying the inverse skeleton base transform to the poly final transform.
2021-05-03 14:11:41 +01:00
Rémi Verschelde
e94161dada
SCons: Add explicit dependencies on thirdparty code in cloned env
Since we clone the environments to build thirdparty code, we don't get an
explicit dependency on the build objects produced by that environment.

So when we update thirdparty code, Godot code using it is not necessarily
rebuilt (I think it is for changed headers, but not for changed .c/.cpp files),
which can lead to an invalid compilation output (linking old Godot .o files
with a newer, potentially ABI breaking version of thirdparty code).

This was only seen as really problematic with bullet updates (leading to
crashes when rebuilding Godot after a bullet update without cleaning .o files),
but it's safer to fix it everywhere, even if it's a LOT of hacky boilerplate.

(cherry picked from commit c7b53c03ae)
2021-04-29 16:57:00 +02:00
Rémi Verschelde
70ae90e0e8
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.

Backport of #48239.
2021-04-29 12:34:11 +02:00
Fabio Alessandrelli
bfe182f221
[Net] Fix socket poll timeout on Windows.
Now correctly computes the timeout value in milliseconds.

(cherry picked from commit 46f7b0f74b)
2021-04-29 12:28:31 +02:00
Rémi Verschelde
25b170599b
Merge pull request #47129 from mortarroad/3.x-fix-directional-light-order
Fix draw order of transparent materials with multiple directional lights
2021-04-28 19:03:37 +02:00
Rémi Verschelde
135fd8ff8c
Merge pull request #34008 from ricmzn/fix-viewport-texture-flags
GLES3: Allow repeat flag in viewport textures
2021-04-28 17:04:47 +02:00
Rémi Verschelde
e9efc349ac
Merge pull request #47582 from clayjohn/GLES3-fix-multimesh-modulate
Fix multimesh being colored by other nodes GLES3
2021-04-28 17:02:00 +02:00
Rémi Verschelde
6cb61b67e6
Merge pull request #41471 from Calinou/giprobe-deprecate-compress-3.2 2021-04-28 12:01:55 +02:00
Rémi Verschelde
cbd47665ea
Merge pull request #48125 from lawnjelly/ewok_fix_translate_size
Batching - fix number of verts in translation
2021-04-26 11:53:00 +02:00
lawnjelly
35c5ccce9e Batching - GLES3 fix light pass modulates
The final_modulate was incorrectly being set in the uniform on light passes in GLES3 in situations where color was baked in the vertices. This was already correct in GLES2. This PR makes prevents setting final_modulate in this situation.
2021-04-24 10:21:33 +01:00
lawnjelly
d08cf5f434 Batching - fix number of verts in translation
The translation to larger vertex formats was assuming that batches were rects, and not accounting that the num_commands had a different meaning for lines and polys, so the calculation for number of vertices to translate was incorrect in these cases.

Also prevents infinite loop if a single polygon has too many vertices to fit in the batch buffer.
2021-04-23 09:24:15 +01:00
clayjohn
0546c8760a Add setting for shadow cubemap max size 2021-04-20 23:17:45 -07:00
lawnjelly
6c2cc01f73 Batching - Don't join items with invalid shaders
When users create an invalid shader, the shader->valid flag is set to false. Batching previously assumes that shaders are valid, and this can result in primitives with invalid shader being joined, causing visual errors.

This PR prevents joining items that have invalid shaders.
2021-04-18 08:31:59 +01:00
Rémi Verschelde
4a942afb9b
Merge pull request #47864 from lawnjelly/orphan_options
Add buffer orphan / stream options
2021-04-14 13:21:12 +02:00
lawnjelly
2ffdfdfd1a Add buffer orphan / stream options
Allows users to override default API usage, in order to get best performance on different platforms.

Also changes the default legacy flags to use STREAM rather than DYNAMIC.
2021-04-14 12:08:32 +01:00
Rémi Verschelde
d2936ba54c
Merge pull request #47788 from lawnjelly/ewok_dont_multiply_modulate 2021-04-14 10:25:42 +02:00
Rémi Verschelde
81f8b404f2
Merge pull request #47540 from volzhs/ensure-normal-gles2
Make ensure_correct_normals working on GLES2
2021-04-14 10:20:08 +02:00
lawnjelly
e8da16b032 Batching - prevent applying final modulate on CPU when it is sent in FVF
When using modulate_fvf, final_modulate was still being applied on CPU in some circumstances, AS WELL as in the shader. This double application resulted in the wrong color.

This PR prevents CPU multiplication of final_modulate when modulate_fvf is in use.

It also applies an OR to the joined item flags with each item joined. This fixes a bug where a smaller FVF is used than required, resulting in incorrect colors.
2021-04-12 17:41:48 +01:00
lawnjelly
40a267cf25 Batching - store parent items in default batches
In rare cases default batches could occur which were containing commands that were not owned by the first item referenced by the joined item. This had assumed to be the case, and would read the wrong command, or crash.

Instead for safety in this PR we now store a pointer to the parent item in default batches, and use this to determine the correct command list instead of assuming.
2021-04-12 16:55:59 +01:00
lawnjelly
8348c97a8d Batching - flip normal map polarity for rects
An earlier PR #46898 had flipped the rotation basis polarity. This turns out to also need a corresponding flip for the light angles for the lighting to make sense.
2021-04-03 10:53:20 +01:00
clayjohn
92bf493821 Fix multimesh being colored by other nodes GLES3 2021-04-02 14:01:47 -07:00
volzhs
da4cec620e Make ensure_correct_normals working on GLES2 2021-04-01 16:33:35 +09:00
Morris Tabor
63b7b7773c Fix draw order of transparent materials with multiple directional lights 2021-03-26 12:31:40 +01:00
Rémi Verschelde
acbd1e8b02
Merge pull request #46781 from BastiaanOlij/gdn_set_interface
Add set_interface for access by GDNative
2021-03-26 11:27:27 +01:00
Rémi Verschelde
f31523a99e
Merge pull request #47187 from lawnjelly/ewok_poly_protection
Batching - add protection against invalid polys
2021-03-26 11:20:46 +01:00
Bastiaan Olij
717f3227ec ARVR GDNative enhancements:
- add set_interface function
- add access to depth buffer
- add supplying a depth buffer from an ARVR plugin
2021-03-25 22:37:47 +11:00
Rémi Verschelde
a58523407f
Merge pull request #47102 from lawnjelly/large_fvf_revamp
Batching - separate single item from large fvf logic
2021-03-23 22:24:36 +01:00
Rémi Verschelde
1ed0280de7
Merge pull request #47160 from puchik/shadow-filter-resolution
[3.x] Take resolution into account when setting the max shadow cubemap size (omni light shadow jaggies fix)
2021-03-23 09:45:14 +01:00
Arman
8d156d9e5c Take resolution into account when setting the max shadow cubemap size
Co-authored-by: Clay John <clayjohn@gmail.com>
2021-03-22 23:11:38 -07:00
Rémi Verschelde
a2dd77867e
Merge pull request #47038 from JFonS/fix_renderer_rid_crash
[3.3] Fix crash in GLES3 renderer on release builds
2021-03-22 17:51:41 +01:00
Rémi Verschelde
c0b3ad2f7b
Merge pull request #45087 from hoontee/3.2
[3.2] Fix empty RIDs in VisualServer.texture_debug_usage()
2021-03-22 10:13:15 +01:00
lawnjelly
ae1c45329d Batching - add protection against invalid polys
The editor under certain circumstances is passing invalid polys to the renderer. This should be fixed upstream but just in case this PR adds fault tolerance for invalid indices.
2021-03-20 10:36:59 +00:00
lawnjelly
7f3a19789c Batching - separate single item from large fvf logic
Trying to use the old `hardware_transform` flag to combine the new large_fvf has lead to several bugs. So here the logic is broken out into 2 separate components, single item and large_fvf.

The old `hardware_transform` name also no longer makes sense, as there are now 3 transform paths:

Software (CPU)
Hardware (uniform)
Hardware (attribute)
2021-03-17 15:38:21 +00:00
Alex Hirsch
0b541af8a1
Allow nullptr with zero length in FileAccess get_buffer
fix #47071

(cherry picked from commit c28428fe4d)
2021-03-17 15:17:02 +01:00
lawnjelly
0d80385687 Batching - prevent CPU transform for non-rects using large FVF
Large FVF which encodes the transform in a vertex attribute is triggered by reading from VERTEX in a custom shader. This means that the local vertex position must be available in the shader, so the only way to batch is to also pass the transform as an attribute.

The large FVF path already disabled CPU transform in the case of rects, but not in other primitives, which this PR fixes.

Note that large FVF is incompatible with 2d software skinning. So reading from VERTEX in a custom shader when using skinning will not work.
2021-03-17 12:04:59 +00:00
Rémi Verschelde
76b375e6a3
Thread: Re-add pthread_np.h include for FreeBSD/OpenBSD
Was a regression from #45315.

Fixes #46998.

(cherry picked from commit 7a64819c2f)
2021-03-16 11:33:55 +01:00
JFonS
8eb03064d1 Fix crash in GLES3 renderer on release builds
Make sure the `first_directional_light` RID is properly invalidated when
freed.
2021-03-15 20:48:13 +01:00
Alex Hirsch
5a882a659a
Add parameter checkes to FileAccess get_buffer functions
fix #46540

(cherry picked from commit cdf3099c68)
2021-03-14 12:03:22 +01:00
Ev1lbl0w
a586f9daae
Replace malloc's with Godot's memalloc macro
(cherry picked from commit 838e7d0a8d)
2021-03-13 22:01:27 +01:00
Rémi Verschelde
3f246ebeed
Merge pull request #46932 from JFonS/fix_lm_capture_env
[3.2] Batch of lightmapper fixes and minor improvements
2021-03-12 12:30:36 +01:00
JFonS
e2c28675ef Batch of lightmapper fixes and minor improvements
- Fix objects with no material being considered as fully transparent by the lightmapper.
- Added "environment_min_light" property: gives artistic control over the shadow color.
- Fixed "Custom Color" environment mode, it was ignored before.
- Added "interior" property to BakedLightmapData: controls whether dynamic capture objects receive environment light or not.
- Automatically update dynamic capture objects when the capture data changes (also works for "energy" which used to require object movement to trigger the update).
- Added "use_in_baked_light" property to GridMap: controls whether the GridMap will be included in BakedLightmap bakes.
- Set "flush zero" and "denormal zero" mode for SSE2 instructions in the Embree raycaster. According to Embree docs it should give a performance improvement.
2021-03-12 12:00:53 +01:00
Rémi Verschelde
a550260404
Merge pull request #46865 from lawnjelly/ninepatch_shader_option
Support ninepatch mode in GLES3 shader
2021-03-12 10:05:44 +01:00
Rémi Verschelde
b3e605ab13
Merge pull request #46901 from lawnjelly/ewok_large_fvf_soft_xform
Batching - large FVF forces non-hardware transform
2021-03-12 10:04:57 +01:00
Rémi Verschelde
80d75b966c
Merge pull request #46904 from lawnjelly/ewok_diagnose_more
Batching - more frame diagnose information
2021-03-11 21:13:09 +01:00
Rémi Verschelde
d3dd28ba57
Merge pull request #46896 from lawnjelly/ewok_read_modulate_attribute
Batching - use FINAL_MODULATE_ALIAS in shaders
2021-03-11 21:11:50 +01:00
Rémi Verschelde
8e1c92a365
Merge pull request #46892 from lawnjelly/ewok_scissor_boost
Batching - fix off by one error in light scissoring
2021-03-11 21:11:06 +01:00
lawnjelly
5ed0fd067d Batching - use FINAL_MODULATE_ALIAS in shaders
As part of the improvements to batch more cases, batching can store final_modulate as an attribute in the vertex format rather than sending as a uniform. This allows draw calls with different final_modulate to be batched together.

However custom shader code was reading from only the final_modulate uniform, and not the attribute when it was in use. This was leading to visual errors.

This is tricky to solve, because we cannot use the same name for the attribute in the vertex and fragment shaders, because one is an attribute and one a varying, whereas a uniform is accessible anywhere. To get around this, a macro is used which can translate to the most appropriate variable depending on whether uniform or attribute or varying is required.
2021-03-11 17:07:19 +00:00
lawnjelly
d226cf83d1 Batching - more frame diagnose information
Added slightly more detail to diagnose_frame option. This is helpful for debugging issues.
2021-03-11 16:32:59 +00:00
lawnjelly
b590f5ff52 Batching - large FVF forces non-hardware transform
This is something that I missed from the initial implementation of large FVF. In large FVF the transform is sent per vertex in an attribute, and the vertex position is the original vertex position. This is so that the original vertex position can be read and modified in a custom shader.

This whole system is therefore incompatible with the legacy hardware transform method, whereby the transform is sent in a uniform. The shader already correctly ignores the uniform transform, but there are some parts of the CPU side logic that can be confused treating large FVF batches as if they were hardware transform.

This PR completes the logic by making the CPU treat large FVF as though it was software transform.
2021-03-11 15:53:43 +00:00
lawnjelly
f723fa6db9 Batching - fix basis polarity in large fvf
Slight technical hitch, the basis was reversed that was sent to the shader, so rotations were opposite. This PR reverses polarity of the basis to be correct.
2021-03-11 14:26:54 +00:00