Commit graph

2358 commits

Author SHA1 Message Date
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
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
Pedro J. Estébanez
6d89f675b1 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
8f6a636ae7 Modernize Semaphore
- Based on C++11's `mutex` and `condition_variable`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
b450036120 Modernize RWLock
- Based on C++14's `shared_time_mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:41:07 +01:00