Commit graph

67 commits

Author SHA1 Message Date
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
Rémi Verschelde b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02: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
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 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
lawnjelly e13040b373 Fix bug in normal map decompression
Not clamping the range here leads to dithering artifacts.
2020-12-11 10:34:53 +00:00
lawnjelly e88b4f330e Poly colors fixes
This adds support for custom shaders for polys, and properly handles modulate in the case of large FVF and modulate FVF.

It also fixes poly vertex colors not being sent to OpenGL.
2020-11-13 13:23:28 +00:00
lawnjelly f4cb88e232 Fix transforms in custom shaders using large FVF
In small batches using hardware transform, vertices would be drawn in incorrect positions due to the item transform being applied twice - once in the transform uniform, and once from the transform passed as a vertex attribute.

This PR alters the shader to ignore uniform transforms when using large FVF.
2020-10-25 12:57:42 +00: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 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
Pedro J. Estébanez d8be5a9986 Add MODULATE builtin to canvas item shaders 2020-05-04 00:10:24 +02:00
Rémi Verschelde 2d6586ec78
Merge pull request #34551 from MadEqua/fix-light-with-skeleton
Fix 2D lighting when using skeleton.
2020-01-03 08:32:29 +01:00
Tritium Oxide bb6f04c9f5
Fix wrong return type
`ERROR: _display_error_with_code: CanvasShaderGLES3: Fragment Program Compilation Failed:
0:166(2): error: `return' with wrong type int, in function `map_ninepatch_axis' returning float`  caused by #34704
2020-01-01 19:14:51 +07:00
Rémi Verschelde e4907e50fe GLES3: Fix false positive in ninepatch axis stretch code
See #34704.
2020-01-01 11:49:58 +01:00
Bruno Lourenço f26c9d650b Fix 2D lighting when using skeleton. 2019-12-23 00:00:18 +00:00
clayjohn 676f647c74 Add a default POINT_SIZE 2019-12-10 23:08:20 -08:00
Rémi Verschelde a39aeade5b
Merge pull request #32170 from puthre/ninepatch-fix
GLES2 & GLES3 Fixes ninepatch margins for high resolution textures.
2019-10-09 08:33:56 +02:00
Valentin Zagura 100d05cbec GLES3 Fixes for ninepatch margins when patch size is smaller than the patch texture resolution
Scaled ninepatch margins in screen space to be relative of the ninepatch size when the patch size is smaller than the patch texture resolution.
2019-10-07 13:19:27 +01:00
azagaya b835868067 Create shadow_vec for altering shadow computation
In 2.1 and 3.0, light_vec could be modified for altering shadow_computations.
But it broke shadows when rotating light. shadow_vec would do the same, but without breaking
shadows in rotated lights if not used.

Add inverse light transformation to shadow vec, so it's not affected when rotating lights;

Added usage define for shadow vec.

For shadow vec working properly when rotating a light, it's needed to multiply it by light_matrix normalized. Added usage define in order to don't do that if shadow_vec not used.
2019-09-06 13:55:49 -03:00
RaphaelHunter 47df933c27 update algorithm about paking float to vec4 to fix shadow shift and change rgba_shdow options 2019-07-28 11:43:01 +08:00
clayjohn 2b8b1d7c46 added MultiMeshInstance2D node for using MultiMesh in 2D 2019-06-03 12:11:54 -07:00
clayjohn b804c491b7 fixed pixel snap precision artifact 2019-03-04 07:18:02 -08:00
Hein-Pieter van Braam a83e77fded Explicitly use floating point numbers in the our shaders
We need to be explicit about using floating point numbers in our shaders
for compatibility with mobile GLES drivers.
2019-02-24 23:35:10 +00:00
JFonS 32e7641667 Revert back to ignoring LIGHT_VEC for 2D shadows 2019-02-21 12:16:10 +01:00
JFonS 076a342a4e Make LIGHT_VEC affect 2D shadows again 2019-02-10 21:14:32 +01:00
QbieShay 7c55228f5c fixed uv missing in vertex shader of canvas. 2018-12-13 07:48:30 +01:00
Rémi Verschelde dd06f6ee70 Fix style issues and signature mismatch 2018-11-28 10:21:07 +01:00
Juan Linietsky e6bc152de8 NORMALMAP was not working (no normal being used detected), fixes #9263 2018-11-27 18:05:20 -03:00
JFonS cbfb7bd613 Make 2D particles work OOTB (again) 2018-11-13 23:25:05 +01:00
JFonS 85ce4a67ed Remove animation loop from ParticlesMaterial + improvements to CPUParticles2D
Remove animation loop from ParticlesMaterial and move it to
SpatialMaterial for 3D particles and Particles2D for the 2D case.

Added animation to CPUParticles2D as well as the "Convert to
CPUParticles2D" to the PAarticles2D menu.
2018-11-04 15:58:12 +01:00
Rémi Verschelde ac2a4771d5 GLES2: Implement pixel snap 2D option 2018-10-02 15:53:24 +02:00
JFonS 8f4f79c767 Fix lighting of rotated particles in 2D
Custom instance transform was not taken into account for normal map
calculation. Also renamed `extra_matrix2` to `extra_matrix_instance` for
more clarity.
2018-09-18 22:58:13 +02:00
Rémi Verschelde 4226d56ca9 Style: Enable clang-format on GLSL shaders
As of clang-format 6.0.1, putting the `/* clang-format off */` hint
around our "invalid" `[vertex]` and `[shader]` statements isn't enough
to prevent a bogus indent of the next comments and first valid statement,
so we need to enclose that first valid statement in the unformatted chunk.
2018-08-27 07:34:14 +02:00
Rémi Verschelde 1b6d75a599 Style: Fix code formatting in GLES3 shaders 2018-08-24 13:42:18 +02:00
JFonS 4421a6661d Move light 2D rotation to vertex shader 2018-07-05 11:12:04 +02:00
JFonS ac18444c7e Fix regression of 2D light height 2018-07-04 23:31:27 +02:00
JFonS e9a3cf8feb Fix rotation of 2D lights 2018-06-19 11:24:51 +02:00
Juan Linietsky 3bd0ca2a2d Skeletal deform working 2018-05-04 11:54:21 -03:00
Juan Linietsky b3e4bc562c Skeleton for 2D WIP 2018-05-03 17:29:56 -03:00
Pieter-Jan Briers 25ba49fd88 Fixes canvas light shaders.
Fixes #16904

Restore more out functionality, fix built-ins.

Requested changes, I think?
2018-04-13 15:18:28 +02:00
MrCdK 408f4cb146 Set correct types on a couple variables inside the canvas.glsl 2018-01-12 22:02:28 +01:00
Juan Linietsky 2c226e4edf Some fixes to improve precision and speed on Android. Fixes precision issues on Mali and PowerVR. 2018-01-02 18:45:00 -03:00
Guilherme Silva ffe827ab5a Fix pixel snap not being used in 3.0 2017-12-19 15:18:07 -02:00
Juan Linietsky 7eabbeb5af remove half_texpixel in canvas since no longer used 2017-11-12 08:29:28 -03:00
Nathan Warden 6adaf8f47a Fixed a bug where clamp_uv was clamping one pixel short, stretching the last pixels. 2017-11-11 07:28:48 -05:00
Juan Linietsky d4e20555e8 Ability to set a custom FOV makes it possible to use sky on orthogonal view. Closes #9186 2017-09-29 18:56:52 -03:00
Juan Linietsky ddadc782ba Fix frame selection in 2D particles, closes #10668 2017-09-06 08:31:11 -03:00
Henrik Andersson e0a19a77e5 Don't compare float to int 2017-09-04 22:21:55 +02:00
letheed 3a188015be add shadow_filter variant PCF7 2017-09-01 15:01:24 +02:00
Rémi Verschelde 82208c1e8b Merge pull request #10417 from bojidar-bg/x-fix-tilemap-transpose
Implement texture UV transpose in the gles3 renderer
2017-08-31 13:17:39 +02:00