Commit graph

1577 commits

Author SHA1 Message Date
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
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
clayjohn 8ac85e6a9e Normalize the results of octahedral decompression 2021-08-16 22:17:38 -07:00
Rémi Verschelde 4032d26dd5
Merge pull request #51268 from RevoluPowered/fix-nan-data-from-compression
Prevent division by zero and warn about invalid normal/tangent information
2021-08-16 22:54:50 +02:00
Gordon MacPherson 6883d55da8 Octahedral compression fix division by zero and warn
This was reported by UBSAN.

Many methods were discussed, in the end this has the least evils and will use a 0,0,1 default on decompress.

Please see the PR for more info https://github.com/godotengine/godot/pull/51268
2021-08-16 21:18:57 +01:00
LoipesMas 32965aa0ab Epsilon check for angular velocity in BodySW 2021-08-16 20:11:46 +02: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
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
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
Rémi Verschelde 03c41fa34c
Merge pull request #51458 from nekomatata/moving-platforms-3d-3.x
[3.x] Fix 3D moving platform logic
2021-08-10 14:12:47 +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
PouleyKetchoupp da159cd258 Fix 3D moving platform logic
Same thing that was already done in 2D, applies moving platform motion
by using a call to move_and_collide that excludes the platform itself,
instead of making it part of the body motion.

Helps with handling walls and slopes correctly when the character walks
on the moving platform.

Also made some minor adjustments to the 2D version and documentation.

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-08-09 18:55:49 -07:00
Rémi Verschelde 0403cb8ad5
Merge pull request #51447 from nekomatata/fix-moving-platform-rotation-3.x
[3.x] Fix applied rotation from moving platforms in move_and_slide
2021-08-09 23:20:35 +02:00
PouleyKetchoupp f101349225 Fix applied rotation from moving platforms in move_and_slide
When synchronizing KinematicBody motion with moving the platform using
direct body state, only the linear velocity was taken into account.

This change exposes velocity at local point in direct body state and
uses it in move_and_slide to get the proper velocity that includes
rotations.
2021-08-09 12:04:57 -07: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
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
lawnjelly 69cc759b65 Portals - improve PVS tracing
The existing tracing routine for building the PVS was rather simple compared to the main portal tracing, and could not correctly cope with paths that went through multiple portals from room A to B, and as a result would sometimes miss room entries in the PVS resulting in too many culled rooms in these circumstances.

This PR adds an improved function that can cope with entering a room multiple times during a trace. As a result it has to take care of portal directions (to prevent going back on itself) in a similar, but not identical way to the main portal tracing routine, and internal rooms, to prevent recursive loops.
2021-08-07 17:57:30 +01:00
lawnjelly 37f20e1d78 Fix Transform::xform(Plane) functions, add Transform unit tests
The Transform::xform and xform_inv are made safe for Planes when using non-uniform scaling.

Basic unit tests for Transform.

Optimization of calling sites to prevent loss of performance from the changes to xform(Plane).
2021-08-07 08:05:39 +01:00
Ellen Poe 999159c12c
Fix Godot's cubic resampling algorithm
(cherry picked from commit 2d450c6f61)
2021-08-06 11:45:08 +02:00
Ellen Poe 840c0e57fb
Revert "Implement a new resampling algorithm in AudioStreamPlaybackResampled"
This reverts commit b2264cb48b.

(cherry picked from commit 57ccfab5fb)
2021-08-06 11:45:08 +02:00
Rémi Verschelde a96519fa69
Merge pull request #51274 from lawnjelly/portals_recursive_loop
Portals - fix recursive loop looking out from internal rooms
2021-08-05 15:45:47 +02:00
lawnjelly 2c88517a7b Portals - fix recursive loop looking out from internal rooms
In some situations looking out from an internal room it was possible to look back into the portal into the internal room.

This PR fixes this by keeping a single item 'stack' record of the last external room, and preventing recursing into this room. This also makes tracing significantly more efficient out of internal rooms, as there is no need to trace the external room multiple times.
2021-08-05 12:37:05 +01: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
PouleyKetchoupp 6fdffacb4e Fix GodotPhysics solver with kinematic body set to report contacts
In 3D, collision is disabled between kinematic/static bodies when
contacts are generated only to report them.

In 2D, this case was already fixed but the code is cleaned to make
it easier to follow.
2021-08-04 10:41:58 -07:00
lawnjelly 776623d56b Portals - Improve UI and add shortcuts
This PR makes the 'convert rooms' button permanently on the toolbar and accessible whichever node is selected, so you can convert rooms without having to select the RoomManager first.

It also adds a togglable item 'view portal culling' to the 'View' menu which is a simple way of setting the RoomManager 'active' setting without the RoomManager being the selected node.

Both of these have keyboard shortcuts, which should make it much faster to reconvert rooms and edit.

In addition there the string in the 'Perspective' Listbox is modified to show [portals active] when portal culling is operational, for visual feedback. This is updated when you change modes, and when the rooms are invalidated.
2021-08-01 19:54:16 +01:00
Rémi Verschelde 3875cdaec4
Merge pull request #51092 from lawnjelly/portals_preview_globals
Portals - disable frustum culling gizmos with preview camera
2021-07-31 10:53:45 +02:00
lawnjelly 93c78af488 Portals - disable frustum culling gizmos with preview camera
When using the preview camera feature it turns out as well as culling the game objects, this also culls the editor gizmos from the preview camera, which makes the editor hard to use in this mode.

To get around this problem we simply disable frustum culling for GLOBAL portal_mode objects when in preview camera mode. This could be a bit slower in an editor scene with lots of gizmos but is the simplest way of solving the problem.
2021-07-31 07:58:47 +01: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
lawnjelly 8287d9e9bc Portals - Fix sending portal margins to VisualServer
Portal margins were not being correctly sent to the PortalRenderer from the SceneTree, so all margins were being used as default (1.0). This PR fixes this.
2021-07-29 11:57:32 +01:00
Yuri Roubinsky 8b6d9ab956 Fix varying usage in custom functions [3.x] 2021-07-28 08:11:35 +03:00
Rémi Verschelde 940ca74ccf
Merge pull request #50889 from Chaosus/shader_const_array_3.x
[3.x] Implemented global const array to shaders
2021-07-27 13:05:32 +02:00
Yuri Roubinsky 1e191847c7 [3.x] Implemented global const array to shaders 2021-07-26 16:29:39 +03:00
Yuri Roubinsky 0a99613e53 Backport latest varying fixes to 3.x (2) 2021-07-26 15:40:42 +03:00
Rémi Verschelde 801205b2c1
Merge pull request #48892 from lawnjelly/bvh_robust
BVH - thread safety option
2021-07-22 12:41:42 +02:00
Rémi Verschelde 8cb25a581d
Merge pull request #50724 from Chaosus/varying_fixes_3.x
Backport latest varying fixes to 3.x
2021-07-22 09:29:43 +02:00
Yuri Roubinsky 1e128c80c6 Backport latest varying fixes to 3.x 2021-07-22 08:43:12 +03:00
Cory Petkovsek 096417905b Calculate instance depth after shadow calculation in VisualServer 2021-07-22 08:06:02 +08: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
PouleyKetchoupp beeebb4c2f More accurate unsafe motion calculation
* Safe and unsafe motion are calculated by dichotomy with a limited
number of steps. It's good for performance, but on long motions that
either collide near the beginning or near the end, the result can be
very imprecise.
* Now a factor 0.25 or 0.75 is used to converge faster when this case
happens, which allows longer motions to get more accurate collision
detection.
* Makes snap collision more precise, and helps with cases where diagonal collision on the border of a platform can lead to the character being stuck.

Additional improvements to move_and_slide:
* Handle slide canceling in move_and_collide with 0 velocity instead of
not applying it.
* Better handling of snap with custom logic to cancel sliding.
* Remove small jittering when using stop on slope, by canceling the
motion completely when the resulting motion is less than margin instead
of always projecting to the up direction (in both body motion and snap).

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-07-19 08:09:17 -07:00