Commit graph

2564 commits

Author SHA1 Message Date
Bartłomiej T. Listwon
350573a4df Fix buffer creation in light_internal_create() 2021-08-31 08:33:43 +02:00
Clay John
46ad2560a1
Merge pull request #51780 from BastiaanOlij/output_linear_gles2
Convert output of GLES2 to linear color space
2021-08-25 22:22:05 -03:00
Bastiaan Olij
73722f3c65 Convert output of GLES2 to linear color space if keep_3d_linear is enabled 2021-08-23 15:59:56 +10:00
clayjohn
987aef4e0d Properly clear cubemap filter state when texture array environment disabled 2021-08-20 19:12:38 -07:00
20kdc
324c487c63 Fix issue #51897 (horizon occlusion causing black blob), fix ver. SP1
No, not service pack 1. Removes comments from the original fix commit.
2021-08-20 19:04:27 +01:00
Hugo Locurcio
663af7ff03
Fix tonemap exposure not being taken into account by sharpening
The same fix as FXAA was applied to the CAS filter.
2021-08-18 16:44:41 +02:00
Rémi Verschelde
1de8f31448
CI: Upgrade Emscripten to 2.0.25
That's the version used by current containers for Godot 3.4.

Fixes a couple stray warnings that new Emscripten/LLVM catches.
2021-08-18 11:13:34 +02:00
Rémi Verschelde
92a7ae022d
Merge pull request #51769 from The-O-King/oct_split_stream_fix
Fix Octahedral/Split Stream Options
2021-08-18 08:01:56 +02:00
Omar El Sheikh
a63028e172 Fix Octahedral/Split Stream Options
Update mesh_surface_get_format_stride and
mesh_surface_make_offsets_from_format to return an array of offsets and
an array of strides in order to support vertex stream splitting

Update _get_array_from_surface to also support vertex stream splitting

Add a condition on split stream usage to ensure it does not get used on
dynamic meshes

Handle case when Tangent is compressed but Normal is not compressed

Make stream splitting option require a restart in the settings

Update SoftBody and Sprite3D to support and use strides and offsets
returned by updated visual_server functions

Update Sprite3D to use the dynamic mesh flag
2021-08-17 16:11:47 -04:00
clayjohn
8ac85e6a9e Normalize the results of octahedral decompression 2021-08-16 22:17:38 -07:00
Rémi Verschelde
51dd4d0c6c
Merge pull request #49509 from Chaosus/shader_time_3.x 2021-08-16 19:42:55 +02:00
Rémi Verschelde
33c9dd8845
Merge pull request #51363 from parulina/gles2-blendshapes-perf 2021-08-16 08:42:14 +02:00
paru
ab21a3b8fb Performance improvements for GLES2 CPU blendshapes 2021-08-16 08:22:45 +02:00
clayjohn
81dc6a7688 Define normal_attrib when not using octahedral compression in GLES3 2021-08-15 22:27:46 -07: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
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
d2a70532e8
FileAccessWindows: Add missing share.h include
Follow-up to #51430.

(cherry picked from commit cb52f2c9c0)
2021-08-12 16:42:17 +02:00
Max Hilbrunner
8dcc764e5a
Fix Windows platform file access
This restores Windows platform file handling back to open files non-exlusively by default, as was the case before October 2018. (See b902a2f2a7)
Back then, while fixing warnings for MSVC, the function used for opening files was changed from _wfopen() to _wfopen_s() as suggsted by the warning C4996. ("This function may be unsafe, consider using _wfopen_s instead.")

This new function
1. did parameter validation and thus avoided some possible security issues due to nil pointers or wrongly terminated strings
2. it also changed the default file sharing for opened files from _SH_DENYNO (which was the implicit default for the previous _wfopen()) to _SH_SECURE.

_SH_DENYNO means every opened file could be opened by other calls (like is the default on other operating systems).
_SH_SECURE means if the file is opened with READ access, others can still read the same file, but if it is opened with WRITE access, others can't open it at all, not even to read.

This led to rarely occuring bugs on Windows, i.e. due to random access by Antivirus processes, or Godot/Windows not closing a file handle fast enough while trying to open it again elsewhere (i.e. project.godot, instead showing the Project manager, or saving shaders/debugging the game).

What this PR does it change the file access to a third method, _wfsopen(). This is still secure, doing parameter validation and thus avoids the warning, but it allows us to actually SET the file sharing parameter. And we set it to _SH_DENYNO, as it was implicitely before the change. (And as it currently is on all non-Windows platforms, where file sharing restrictions don't exist by default.)

Warning C4996 should really have been pointing this out. It should've been _wfsopen() all along. Let's hope this banishes those annoying, rare errors for all eternity.

Fixes #28036.

(cherry picked from commit b48cbb5da9)
2021-08-12 16:42:17 +02:00
Rémi Verschelde
9e3e7b03e4
Merge pull request #51376 from The-O-King/vertex_buffer_alignment
Align Vertex Buffer to 4 Bytes
2021-08-12 07:13:45 +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
Rémi Verschelde
5116855637
Merge pull request #51439 from Calinou/tonemap-clamp-negative-colors-3.x
Clamp negative colors regardless of the tonemapper to avoid artifacts
2021-08-10 09:56:18 +02:00
Rémi Verschelde
dad5d09d1b
Merge pull request #51416 from clayjohn/GLES-horizon-occlusion
[3.x] Add horizon specular occlusion
2021-08-10 09:55:46 +02:00
Rémi Verschelde
6518a61bd4
Merge pull request #51410 from clayjohn/GLES-blinn-phong 2021-08-10 09:52:28 +02:00
clayjohn
f92a600d5c Make blinn and phong specular use full pbr 2021-08-09 20:45:14 -07:00
Hugo Locurcio
313527b3fa
Clamp negative colors regardless of the tonemapper to avoid artifacts
Color artifacts could be visible when using negative lights with the
Filmic and ACES tonemapping operators, as these did not clamp negative
colors.
2021-08-09 17:16:27 +02:00
clayjohn
1065f8dc86 Add horizon specular occlusion 2021-08-08 19:29:02 -07:00
Yuri Roubinsky
0f817e127d [3.x] Fix a default shader specular render mode to (SCHLICK_GGX) 2021-08-08 19:26:00 +03:00
Omar El Sheikh
f0de7ec2b6 Align Vertex Buffer to 4 Bytes
With the octahedral compression, we had attributes of a size of 2 bytes
which potentially caused performance regressions on iOS/Mac

Now add padding to the normal/tangent buffer

For octahedral, normal will always be oct32 encoded
UNLESS tangent exists and is also compressed
then both will be oct16 encoded and packed into a vec4<GL_BYTE>
attribute
2021-08-07 15:42:03 -04:00
Bastiaan Olij
cc1f7f2edc Revert "Combined the DOF far and DOF near passes"
This reverts commit 39658b4e07.
2021-08-05 23:22:31 +10:00
Omar El Sheikh
6c643af6a7 Fix Bugs w/ Octahedral Compression Implementation
Initial octahedral compression incorrectly wrote tangent to the buffer
using an offset of 3 rather than 4, losing the sign of the tangent
vector needed for things like tangent space for texturing mapping

GLES3 renderer used remove_custom_define rather than set_conditional to
change back to the default conditional state the scene shader should be
in
2021-08-04 21:48:56 -04:00
Rémi Verschelde
9735f2803c
Merge pull request #46800 from The-O-King/normal_compression
[3.x] Implement Octahedral Map Normal/Tangent Attribute Compression
2021-07-30 17:34:47 +02:00
Omar El Sheikh
d274284069 Octahedral Normal/Tangent Compression
Implement Octahedral Compression for normal/tangent vectors
*Oct32 for uncompressed vectors
*Oct16 for compressed vectors

Reduces vertex size for each attribute by
*Uncompressed: 12 bytes, vec4<float32> -> vec2<unorm16>
*Compressed: 2 bytes, vec4<unorm8> -> vec2<unorm8>

Binormal sign is encoded in the y coordinate of the encoded tangent

Added conversion functions to go from octahedral mapping to cartesian
for normal and tangent vectors

sprite_3d and soft_body meshes write to their vertex buffer memory
directly and need to convert their normals and tangents to the new oct
format before writing

Created a new mesh flag to specify whether a mesh is using octahedral
compression or not
Updated documentation to discuss new flag/defaults

Created shader flags to specify whether octahedral or cartesian vectors
are being used

Updated importers to use octahedral representation as the default format
for importing meshes

Updated ShaderGLES2 to support 64 bit version codes as we hit the limit
of the 32-bit integer that was previously used as a bitset to store
enabled/disabled flags
2021-07-30 10:29:09 -04:00
Yuri Roubinsky
1e191847c7 [3.x] Implemented global const array to shaders 2021-07-26 16:29:39 +03:00
Bastiaan Olij
39658b4e07 Combined the DOF far and DOF near passes 2021-07-22 13:45:57 +10:00
Rémi Verschelde
f131a77f46
Merge pull request #46574 from The-O-King/split_stream_3.2
[3.4] Split Vertex Buffer Stream in Positions and Attributes
2021-07-20 10:48:37 +02:00
Omar El Sheikh
7f8487a900 Split Vertex Position and Attribute Streams
Implemented splitting of vertex positions and attributes in the vertex
buffer

Positions are sequential at the start of the buffer, followed by the
additional attributes which are interleaved

Made a project setting which enables/disabled the buffer formatting
throughout the project

Implemented in both GLES2 and GLES3

This improves performance particularly on tile-based GPUs as well as
cache performance for something like shadow mapping which only needs
position data

Updated Docs and Project Setting
2021-07-19 13:23:46 -07:00
Hugo Locurcio
43d7b62cb0
Improve the shader error console output
This makes the line gutter look more like an actual line gutter,
which makes it less confusing.
2021-07-17 03:00:46 +02:00
Rémi Verschelde
aa3a5c9f6a
Merge pull request #50184 from JFonS/cpu_lightmapper_soft_shadows
[3.x] Add soft shadows to the CPU lightmapper
2021-07-14 12:18:08 +02:00
uuuuuup
0dc0a4a523 fix 3D scene not rendered on GLES3 HTML5 export
fix pad size of SceneDataUBO
2021-07-08 22:03:03 +09:00
Bastiaan Olij
34d9b6140b Add precision to view_index 2021-07-08 10:47:07 +10:00
Hugo Locurcio
3b11b1022d
Remove unused code related to Travis CI
(cherry picked from commit 257a8a337e)
2021-07-06 11:19:56 +02:00
JFonS
a2ba7910ba Add soft shadows to the CPU lightmapper
Adds the "light_size" property to Lights. It's only considered in baked
lightmaps for soft shadowing purposes.
2021-07-05 19:02:35 +02:00
Hugo Locurcio
a28a4ef98a
Decrease opacity of the overdraw debug draw mode
This allows distinguishing higher amounts of overlapping objects.
2021-07-04 00:23:06 +02:00
Marcel Admiraal
8788472b8c Clear glErrors instead of crashing when initializing GLES3 2021-06-21 17:53:24 +01:00
Hugo Locurcio
a9c0c5484f
Add support for contrast-adaptive sharpening in 3D (GLES3 only)
This is an older, easier to implement variant of CAS as a pure
fragment shader. It doesn't support upscaling, but we won't make
use of it (at least for now).

The sharpening intensity can be adjusted on a per-Viewport basis.
For the root viewport, it can be adjusted in the Project Settings.

Since `textureLodOffset()` isn't available in GLES2, there is no
way to support contrast-adaptive sharpening in GLES2.
2021-06-21 15:37:31 +02:00
Marcel Admiraal
7e03bd1671 Remove duplicate WARN_PRINTS macro 2021-06-18 12:57:59 +01:00
Rémi Verschelde
465ab36ddf
Merge pull request #49653 from madmiraal/remove-err_prints-3.x
[3.x] Remove duplicate ERR_PRINTS macro
2021-06-16 17:33:22 +02:00
Marcel Admiraal
5a58516231 Remove duplicate ERR_PRINTS macro 2021-06-16 11:56:25 +01:00
Hugo Locurcio
9be9304238
Improve the console error logging appearance
This makes secondary information less visually prominent to improve
overall readability.

Various loggers were also tweaked for consistency.
2021-06-13 19:18:09 +02:00
Rémi Verschelde
c45ce768b1
Merge pull request #47854 from mortarroad/3.x-lossless-webp
[3.x] Implement lossless WebP encoding
2021-06-11 19:35:47 +02:00
Morris Tabor
5de08ef1d6 Implement lossless WebP encoding 2021-06-11 18:48:04 +02:00
Yuri Roubinsky
2d7c9f1ef1 [3.x] Makes shader 'TIME' available in custom functions by default 2021-06-11 15:23:24 +03:00
Chuck
17ee8ff0d9 Support multiple address resolution in DNS requests
Add two new functions to the IP class that returns all addresses/aliases associated with a given address.

This is a cherry-pick merge from 010a3433df which was merged in 2.1, and has been updated to build with the latest code.

This merge adds two new methods IP.resolve_hostname_addresses and IP.get_resolve_item_addresses that returns a List of all addresses returned from the DNS request.
2021-06-09 12:06:46 +07:00
Rémi Verschelde
32047ffd9c
FileAccess: Don't err in store_buffer with buffer of size 0
The error check was added for `FileAccessUnix` but it's not an error when both
`p_src` and `p_length` are zero.

Added correct error checks to all implementations to prevent the actual
erroneous case: `p_src` is nullptr but `p_length > 0` (risk of null pointer
indexing).

Fixes #33564.

(cherry picked from commit 01d5c463be)
2021-06-07 22:36:07 +02:00
Pedro J. Estébanez
612986ab0a
Fix crash when using ALSA MIDI with PulseAudio
(cherry picked from commit 958d79828b)
2021-06-03 12:24:57 +02:00
bruvzg
462e57f5e6
Fix Directory::get_space_left() result on macOS and Linux.
(cherry picked from commit 1d7a63fb8f)
2021-06-01 12:53:31 +02:00
Rémi Verschelde
b94b09cd19
Merge pull request #46860 from bruvzg/symlinks_and_macos_gdn_framework_export 2021-05-24 15:15:10 +02:00
bruvzg
53f05c9167
Add GDNative Framework loading and export support. 2021-05-24 12:50:18 +03:00
lawnjelly
17a51b3a9e Batching - fix item_batch_flags stale state
Fixes bdata.joined_item_batch_flags not being kept up to date during the rendering pass.
2021-05-23 12:39:15 +01:00
bruvzg
6aa8f7d85b
Add symlink API to the DirAccess (on macOS and Linux). 2021-05-22 17:36:16 +03:00
Rémi Verschelde
eb78f80f03
Fix typos with codespell
Using codespell 2.0.0.

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

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:56:56 +02:00
Rémi Verschelde
330ddc37b6
Merge pull request #48075 from lyuma/varying_fragment_to_light_3.4 2021-05-18 10:53:34 +02:00
Pedro J. Estébanez
817ffc01e1
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-16 17:52:31 +02:00
Lyuma
fba6b62054 Backport dd0874e "Allow passing varying from fragment to light shader function" to 3.4 2021-05-14 11:28:48 -07:00
Lyuma
0c028ad96e Backport bc0e8e7 "Fix using post-init shader array constructors" to 3.4 2021-05-14 11:28:48 -07:00
Lyuma
25016bf715 Backport 6b99bda "Added support for arrays as shader struct members" to 3.4 2021-05-14 11:28:48 -07:00
Lyuma
fc6bee0750 Backport 6f16239 "Implementation of struct for shaders" to 3.4 2021-05-14 11:28:48 -07:00
R. Alex Hofer
5eff9569c6
Handle having no sinks in the PulseAudio driver.
Also make PulseAudio errors more verbose.

(cherry picked from commit 65a10f4db5)
2021-05-14 10:16:32 +02:00
lawnjelly
3c68a6d37f Batching - fallback for 2d skinning with unrigged polys.
In the legacy renderer unrigged polys would display with no transform applied, whereas the software skinning didn't deal with these at all (outputted them with position zero). This PR simply copies the source to destination verts and replicates the legacy behaviour.
2021-05-11 17:34:14 +01:00
paru
eed4655644 Fixed usage of proxy textures on GLES2 sky 2021-05-07 18:33:35 +02:00
paru
8b0d3657e5 Added CPU blendshapes for GLES2 2021-05-06 20:52:34 +02:00
Rémi Verschelde
140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Bastiaan Olij
8f8c9c2f57 Add VIEW_INDEX variable in shader so we know which eye/view we're rendering for 2021-05-05 16:22:03 +10:00
Rémi Verschelde
de3168ffa3
Merge pull request #48457 from briansemrau/fix-polygon-rotation-batched
Fix polygon rotation with batching
2021-05-04 18:12:03 +02:00
Brian Semrau
57e3f357dc Batching fix polygon basis polarity
Changes based on fix in #46898
2021-05-04 10:48:58 -04:00
Rémi Verschelde
b4af1eba0a
Style: Enforce use of bool literals instead of integers
Using clang-tidy's `modernize-use-bool-literals`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
2021-05-04 16:39:13 +02:00
Rémi Verschelde
a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde
b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde
64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde
3d15f04668
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde
6e600cb3f0
Style: Set clang-format Standard to c++14 2021-05-04 14:45:15 +02:00
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
lawnjelly
9b6742346b Batching - fix off by one error in light scissoring
There have been a couple of reports of pixel lines when using light scissoring. These seem to be an off by one error caused by either rounding or pixel snapping.

This PR adds a single pixel boost to light scissor rects to protect against this. This should make little difference to performance.
2021-03-11 10:30:21 +00:00
lawnjelly
e70d7294e2 Support ninepatch mode in GLES3 shader
Although batching supported both ninepatch modes (fixed and scaling) when using ninepatch stretch mode, the ninepatch tiling modes (in GLES3) could only run through the shader.

The shader only supported one of the ninepatch modes. This PR uses the hack method of #if defined in the shader to prevent the use of a conditional. The define is set at startup according to the project setting.
2021-03-10 11:05:59 +00:00
Ev1lbl0w
bae4b0c952
Fix negative VRAM values 2021-03-09 09:51:17 +00:00
JFonS
f24f582ba5 Various light culling fixes
GLES3 changes:
This commit makes it possible to disable 3D directional lights by using
the light's cull mask. It also automatically disables directionals when
the object has baked lighting and the light is set to "bake all".

GLES2 changes:
Added a check for the light cull mask, since it was previously ignored.
2021-03-08 15:10:55 +01:00
lawnjelly
c401960634 Batching - fix custom MODULATE shader applying modulate twice
One of the new fvf types (FVF_MODULATED) allows batching custom shaders that use modulate. The only slight oversight is that there is a special define when MODULATE is used in a custom shader, called MODULATE_USED, that is checked, and if set it does NOT apply final_modulate as part of canvas.glsl.

This MODULATE_USED define wasn't checked when the new FVF was used and modulate was passed in an attribute.

This PR moves the application of the final_modulate into the #ifndef MODULATE_USED section.
2021-03-04 20:28:57 +00:00
lawnjelly
b1e24597e7 Renaming rendering/2d project settings.
The rendering/quality/2d section of project settings is becoming considerably expanded in 3.2.4, and arguably was not the correct place for settings that were not really to do with quality.

3.2.4 is the last sensible opportunity we will have to move these settings, as the only existing one likely to break compatibility in a small way is `pixel_snap`, and given that the whole snapping area is being overhauled we can draw attention to the fact it has changed in the release notes.

Class reference is also updated and slightly improved.

`pixel_snap` is renamed to `gpu_pixel_snap` in the project settings and code to help differentiate from CPU side transform snapping.
2021-03-01 11:38:46 +00:00
lawnjelly
7d5cf60149 Disallow antialiasing for software skinned 2d polys
Antialiasing is not supported for batched polys. Currently due to the fallback mechanism, skinned antialiased polys will be rendered without applying animation.

This PR simply treats such polys as if antialiasing had not been selected. The class reference is updated to reflect this.
2021-03-01 08:26:59 +00:00
lawnjelly
3aaefb957b GLES2 fix for consistent light ordering with BVH
Due to multi pass approach to lighting in GLES2, in some situations the rendered result can look different if lights are presented in a different order.

The order (aside from directional lights) seems to be simply copied from the culling routine (octree or bvh) which is essentially arbitrary. While octree is usually consistent with order, bvh uses a trickle optimize which may result in lights occurring in different order from frame to frame.

This PR adds an extra layer of sorting on GLES2 lights in order to get some kind of order consistency.
2021-02-24 17:25:28 +00:00
Hein-Pieter van Braam-Stewart
65528a63fb Omit some functions in alsa wrapper
These functions don't yet exist on ubuntu 14.04 so this leads to build
problems there. Omitting these symbols in the generated wrappers fixes
this. If we want to start using these symbols at a later date we should
just regenerate the wrapper.

(cherry picked from commit f42a7f9849)
2021-02-22 21:39:22 +01:00
Hugo Locurcio
83eec8f7db
Improve PCF13 shadow rendering in GLES2 by using a soft PCF filter
This suppresses the blocky shadow appearance, bringing the shadow rendering
much closer to GLES3. This soft filter is more demanding as it requires
more lookups, but it makes PCF13 shadows more usable.

The soft PCF filter was adapted from three.js.
2021-02-22 13:36:15 +01:00
Hein-Pieter van Braam-Stewart
6e9cea9fd2 An update to the dylibloader for older inttypes
This #define's older inttypes to their newer versions and #includes
<stdint.h> in the generated files. This will help with older
glibc/compiler versions using headers generated on newer systems.

cherry picked from 5233d78f49
2021-02-20 01:25:19 +01:00
Rémi Verschelde
e6c1c1b300
Merge pull request #46198 from RandomShaper/volatile_robustness_3.2
Improve robustness of atomics (3.2)
2021-02-19 12:53:26 +01:00
Pedro J. Estébanez
76d5ab8b9a Restore needed null check in OS_Unix::execute() 2021-02-19 11:48:30 +01:00
clayjohn
c29ade28af Multiply vertex lit DirectionalLights by albedo in GLES3 2021-02-18 20:56:45 -08:00
Hein-Pieter van Braam
220f24c191
Merge pull request #45618 from RandomShaper/modernize_mt_3.2
Backport of all the multi-threading modernization (3.2)
2021-02-18 20:47:24 +01:00
Rémi Verschelde
418a08d678
Merge pull request #46175 from lawnjelly/gles_sanitizer_fixes
GLES - fix some sanitizer warnings
2021-02-18 20:36:56 +01:00
lawnjelly
e7d1735bff GLES - fix some sanitizer warnings
These are benign but worth fixing as it clears the log to find more important errors.

A common problem with the sanitizer is that enums are often used to represent bits (e.g. 1, 2, 4, 8 etc) but without specifying the enum type, the compiler is free to use unsigned or signed int. In this case it uses int, and when it performs bitwise operations on the int type, the sanitizer complains.

This is probably because a bitshift with negative signed value can give undefined behaviour - the sanitizer can't know ahead of time that you are using the enum for sensible bitflags.
2021-02-18 15:45:38 +00:00
hoontee
bb36823589 Fix empty RIDs in VisualServer.texture_debug_usage() 2021-02-18 05:46:11 -06:00