Commit graph

2370 commits

Author SHA1 Message Date
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
volzhs
da4cec620e Make ensure_correct_normals working on GLES2 2021-04-01 16:33:35 +09: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