Commit graph

862 commits

Author SHA1 Message Date
Rémi Verschelde 123942f61f
Merge pull request #42119 from lawnjelly/ewok3
Unified GLES3 / GLES2 Batching
2020-10-19 15:01:10 +02:00
Rémi Verschelde 4a92d2111b
Merge pull request #38954 from puchik/ssr-far-clip
Check if screen space reflection has passed far clip
2020-10-18 20:48:44 +02:00
Juan Linietsky 8ca98dd1a0
Merge pull request #41892 from puchik/ssr-edge-fade
Fade screen-space reflection towards inner margin
2020-10-18 14:50:20 -03:00
lawnjelly 74c460fb67 Reduce glBufferSubData calls in legacy renderer
This is part of effort to make more efficient use of the API for devices with poor drivers. This eliminates multiple calls to glBufferSubData per update.
2020-10-18 11:27:08 +01:00
lawnjelly c2290dbedd Unified GLES2 / GLES3 Batching
Batching is mostly separated into a common template which can be used with multiple backends (GLES2 and GLES3 here). Only necessary specifics are in the backend files.

Batching is extended to cover more primitives.
2020-10-16 10:34:47 +01:00
lawnjelly 42bca1a4a9 Fix buffer orphaning on desktop
Vertex / Index Buffer orphaning was previously turned off on desktop, which was causing performance problems on some platforms, especially Mac.
2020-10-12 10:32:35 +01:00
PouleyKetchoupp f9544716f4 Option for software skinning in MeshInstance
Option in MeshInstance to enable software skinning, in order to test
against the current USE_SKELETON_SOFTWARE path which causes problems
with bad performance.

Co-authored-by: lawnjelly <lawnjelly@gmail.com>
2020-10-08 16:14:55 +02:00
Rémi Verschelde cd05197fb3
Merge pull request #41254 from lawnjelly/gles3_nvidia_normalrotation
GLES3 fix normal map flipping with nvidia workaround
2020-09-28 10:40:22 +02:00
Arman cf7bb2c51f Fade screen-space reflection towards inner margin
- Fade reflection towards inner margin and clip it at screen edges instead of external margin.
- Round edges of the fade margin if both are being cut off to prevent sharp corners.
2020-09-08 15:29:36 -07:00
Fredia Huya-Kouadio 0af5cded1e Fix the update logic for user-added custom defines.
The previous logic was causing the (unintentional) removal of custom defines automatically added by the engine.
2020-09-06 21:31:09 -07:00
lawnjelly 674327b78f GLES3 fix normal map flipping with nvidia workaround
When not using TEXTURE_RECT path, flips have to sent via another method to the shader, to ensure that normal maps are correctly adjusted for direction. This PR adds an extra vertex attribute, LIGHT_ANGLE.

For nvidia workarounds, where the shader still has access to the final transform and extra matrix, the LIGHT_ANGLE can be 0 (no adjustment), 180 degrees for a horizontal flip, and negative indicates a vertical flip.

For batching path, the LIGHT_ANGLE can be used to directly specify the light angle for normal mapping, even when the final transform and extra matrix have been baked into vertex positions, so the same shader can be used for both.
2020-08-23 07:54:58 +01:00
clayjohn 2534e28918 Fix OpenGL error when generating radiance 2020-07-21 10:40:49 -07:00
clayjohn e5cc4d4f87 Allow nearest neighbor lookup when using mipmaps 2020-07-19 14:44:42 -07:00
azagaya d539627be2 Fixed white image in margins when using same image in scene 2020-07-06 15:54:45 -03:00
Rémi Verschelde 22863363a7
Merge pull request #37475 from azagaya/3.2
Fixed images in black margins
2020-07-03 13:09:22 +02:00
clayjohn 95f93b5f0f force depth prepass when using alpha prepass 2020-06-26 15:16:20 -07:00
Pedro J. Estébanez c15e5af60e Fix wrong internal format for half-float textures 2020-06-15 13:03:13 +02:00
Rémi Verschelde 7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Pedro J. Estébanez 1ff7b0a0a9 Add shader time scaling
Shaders' `TIME` will be affected by the new shader time scale, that is set via the also new `VisualServer::set_time_scale()`.
2020-06-06 23:59:48 +02:00
Arman 48ffd3d157 Check if screen space reflection has passed far clip
Before "accepting" the reflection, check if it's within our view (prevent tracing environment and creating artifacts).
2020-06-04 00:52:16 -07:00
azagaya 3305783bac Fixed images in black margins 2020-06-03 18:33:33 -03:00
Yuri Roubinsky 371d48aea1 [3.2] Fix shader's length() function parsing in expressions 2020-06-03 19:43:47 +03:00
Technohacker 9584f24be5
Use DWMEnableBlurBehindWindow instead of WS_EX_LAYERED
Affects per-pixel transparency

The current method renders to the screen by copying the GLES output to a
DIB for transparency using the CPU instead of rendering directly to the
window via the GPU. This is slower and also forces the window to be borderless
as WS_EX_LAYERED affects the non-client region as well.

This change uses DWMEnableBlurBehindWindow which allows using the standard
glClearColor() background alpha and is also performed through the GPU,
eliminating CPU bottlenecks
2020-05-10 21:05:37 +05:30
lawnjelly dcb19ed735 Add Nvidia Workaround for GLES3
Ported GLES2 workaround code to GLES3.
2020-05-07 14:54:14 +01:00
lawnjelly 17bb7af425 GLES3 - add counts for 2d drawcall and 2d items to performance monitor
This had already been implemented for GLES2 but not GLES3.
2020-05-07 11:31:43 +01:00
Pedro J. Estébanez d8be5a9986 Add MODULATE builtin to canvas item shaders 2020-05-04 00:10:24 +02:00
Pedro J. Estébanez 7cc0f181c9 Improve shader time roll over
- Resurrect it for GL ES 2
- Apply roll over with `fmod()` instead of resetting it to 0
- Expose the setting from the `VisualServer`, since it does not belong in any specific rasterizer
2020-04-29 22:33:03 +02:00
Rémi Verschelde f2150d1766
Merge pull request #37462 from Chaosus/shader_fix_const_order
[3.2] Fix shader constant sorting
2020-04-29 09:41:49 +02:00
Fredia Huya-Kouadio 7c559afe29 Restrict GL_TEXTURE_EXTERNAL_OES to Android platform 2020-04-27 10:18:31 -07:00
clayjohn 193b0bf1e3 Reset texture flags after radiance map generation 2020-04-11 16:10:34 -07:00
Yuri Roubinsky ee93c85ef1 Fix shader constant sorting 2020-03-31 14:32:33 +03:00
fhuya 30d738eda7 Add support for opengl external textures as defined by https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt 2020-03-05 13:09:49 -08:00
Yuri Roubinsky 786b1cc7ff Fix shader crash if using multiple underscores in identifier names
(cherry picked from commit 15358b808b)
2020-02-06 13:02:07 +01:00
clayjohn eb5cb5d016 Add project setting for max irradiance size 2020-01-25 13:27:13 -08:00
clayjohn 3631a3cc9e Fix recently introduced crash in viewport size 2020-01-23 08:11:01 -08:00
Rémi Verschelde 37897dba80
Merge pull request #35406 from lawnjelly/ortho-shadow
Replace CameraMatrix::get_viewport_size with get_viewport_half_extents, shadow culling with ortho camera and other affected issues
2020-01-22 22:02:09 +01:00
lawnjelly eaf8e5ce52 Change CameraMatrix::get_viewport_size to get_viewport_half_extents
Fixes #26637.
Fixes #19900.

The viewport_size returned by get_viewport_size was previously incorrect, being half the correct value. The function is renamed to get_viewport_half_extents, and now returns a Vector2.

Code which called this function has also been modified accordingly.

This PR also fixes shadow culling when using ortho cameras, because the correct input for CameraMatrix::set_orthogonal should be the full HEIGHT from get_viewport_half_extents, and not half the width.

It also fixes state.ubo_data.viewport_size in rasterizer_scene_gles3.cpp to be the width and the height of the viewport in pixels as stated in the documentation, rather than the current value which is half the viewport extents in worldspace, presumed to be a bug.
2020-01-22 18:22:00 +00:00
Rémi Verschelde 00284a75e8 GLES3: Fix invalid value for GL_TEXTURE_MAG_FILTER parameter
`GL_LINEAR_MIPMAP_LINEAR` can be used for `GL_TEXTURE_MIN_FILTER`,
but not for `GL_TEXTURE_MAG_FILTER`.

Cf. https://www.khronos.org/opengl/wiki/GLAPI/glTexParameter

Fixes #35436.
2020-01-22 15:18:56 +01:00
Rémi Verschelde 4faaf6089a Remove unused #if 0'ed code 2020-01-21 21:41:54 +01:00
Rémi Verschelde 90a224c6eb
Merge pull request #35310 from akien-mga/gles3-irradiance-small-optimization
GLES3: Slight optimization to irradiance compute
2020-01-19 18:55:51 +01:00
Rémi Verschelde dc4db4ab45 GLES3: Slight optimization to irradiance compute
All the calculations leading up to `mipLevel` are only relevant for
Panorama mode. Similarly, the `source_resolution` uniform is only
needed for that mode.
2020-01-19 11:03:11 +01:00
clayjohn 0979411cad reduce complexity of irradiance map generation 2020-01-18 16:51:52 -08:00
clayjohn 041fa57a88 Add multimesh format max for proper error checking 2020-01-16 13:31:17 -08:00
clayjohn f1d0c391c7 fix light related crashes 2020-01-15 21:40:05 -08:00
Rémi Verschelde 8130decfe4
Merge pull request #35064 from clayjohn/rendering_crashes
Fix light and multimesh crashes
2020-01-13 09:13:18 +01:00
clayjohn 179193775b Fix light and multimesh crashes 2020-01-12 17:45:06 -08:00
clayjohn 796d35d8b3 Fix generation of irradiance map 2020-01-12 14:45:31 -08:00
Rémi Verschelde 815bf761a5 RasterizerCanvas: Use getornull to fetch light occluder polygon
Fixes #21286 when the occluder is not fully configured.
2020-01-08 11:29:15 +01:00
Hugo Locurcio 0cad2c0cd1
Add VisualServer methods to get the video adapter name and vendor
These methods can be used in scripts to retrieve the OpenGL
`GL_RENDERER` and `GL_VENDOR` strings (respectively).

This closes #28404.
2020-01-06 00:37:56 +01:00
Rémi Verschelde fa82664419
Merge pull request #34726 from nekomatata/polygon2d-antialiasing-fix
Fixed antialiasing option for Polygon2D with concave/hollow shapes
2020-01-03 14:17:05 +01:00