From a8bde75c88d6fa27019a6e8ea04fbf28aac3e402 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 24 Feb 2025 23:05:32 +0100 Subject: [PATCH 1/3] Update instructions on setting Full Rect anchor in Custom post-processing This now contains a screenshot that shows how to set the anchor preset. This also renames the `half` variable in the example shader to avoid highlighting `half` as a GLSL language keyword. --- tutorials/shaders/custom_postprocessing.rst | 14 ++++++++++---- ..._postprocessing_anchors_preset_full_rect.webp | Bin 0 -> 2848 bytes 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tutorials/shaders/img/custom_postprocessing_anchors_preset_full_rect.webp diff --git a/tutorials/shaders/custom_postprocessing.rst b/tutorials/shaders/custom_postprocessing.rst index 8fd8a953c9c..d01766d0ea5 100644 --- a/tutorials/shaders/custom_postprocessing.rst +++ b/tutorials/shaders/custom_postprocessing.rst @@ -23,7 +23,13 @@ Post-processing effects are shaders applied to a frame after Godot has rendered it. To apply a shader to a frame, create a :ref:`CanvasLayer `, and give it a :ref:`ColorRect `. Assign a new :ref:`ShaderMaterial ` to the newly created -``ColorRect``, and set the ``ColorRect``'s layout to "Full Rect". +``ColorRect``, and set the ``ColorRect``'s anchors preset to Full Rect: + +.. figure:: img/custom_postprocessing_anchors_preset_full_rect.webp + :align: center + :alt: Setting the anchors preset to Full Rect on the ColorRect node + + Setting the anchors preset to Full Rect on the ColorRect node Your scene tree will look something like this: @@ -67,8 +73,8 @@ shader by `arlez80 `_, void fragment() { vec2 norm_size = size * SCREEN_PIXEL_SIZE; - bool half = mod(SCREEN_UV.y / 2.0, norm_size.y) / norm_size.y < 0.5; - vec2 uv = SCREEN_UV + vec2(norm_size.x * 0.5 * float(half), 0.0); + bool less_than_half = mod(SCREEN_UV.y / 2.0, norm_size.y) / norm_size.y < 0.5; + vec2 uv = SCREEN_UV + vec2(norm_size.x * 0.5 * float(less_than_half), 0.0); vec2 center_uv = floor(uv / norm_size) * norm_size; vec2 norm_uv = mod(uv, norm_size) / norm_size; center_uv += mix(vec2(0.0, 0.0), @@ -78,7 +84,7 @@ shader by `arlez80 `_, mix(vec2(0.0, -norm_size.y), vec2(-norm_size.x, -norm_size.y), float(norm_uv.x < 0.5)), - float(half)), + float(less_than_half)), float(norm_uv.y < 0.3333333) * float(norm_uv.y / 0.3333333 < (abs(norm_uv.x - 0.5) * 2.0))); COLOR = textureLod(screen_texture, center_uv, 0.0); diff --git a/tutorials/shaders/img/custom_postprocessing_anchors_preset_full_rect.webp b/tutorials/shaders/img/custom_postprocessing_anchors_preset_full_rect.webp new file mode 100644 index 0000000000000000000000000000000000000000..fc4a209fcc87a9f84ee770acc5e7906966089797 GIT binary patch literal 2848 zcmV+*3*YooNk&E(3jhFDMM6+kP&iBs3jhEws6a&k6^G)sZ5(O;v9Be$_Kk=Mpu9nV zfB|I73fOtt$63`5TAm?vY1w zCppm_k~Y70oGVX`8{66wC7wTX_%kQj0u?o-_iU7UWIryryPWOAH^yN3Z;=Uz{%hDDD>;mQT|>#TBe$9DD9GqQo8rci z2wg`AlTHexT2qYdLhP%wSaAZz1ZvVRwMzOF@xSgD#>ww|Kw?Ek2WlG%M`tA-2v*t(pYTd~ZiguFs?PDamsfc}L$ghFmyeP? z1YgPj-J93`aWZ{pn(4S*g?IM`#!* zA%qzX&NezwlO67uNy;l96km}Mp_V_#tQu%1gt9V#s|a03$aq7P+79yjZEI@ipm*lVTPxs1F zs=&gKt$yWvjWC(&$$xA_QW$C$=r?sJa^Lg@0shNEoi0uIDlKNRvXqv;ToqZowB=p@ ziw~dww2gq)EK~-}saC{Dx`r@3&)^GdQfuz+Zgwhm=sTStayp%WayT3yayT67Q58&S z9@GCX|4sBHL|G2D_l|aWAW3818=e2eq-e<}7G)U-*}GRmX%g579M^ zn|zxK-CLw3w6IMT1aYFVzwAlOZsSGX=dP`~|Ko12Cc}YuDj!k9{~Kot*$$DFp&fos z2+{pdjPXd)1#Fn_M)!^-qB6WSy6qEEBL>uIg7rNUyO1hl(EJZ?N_Diin%YKHPnJWw ztH2pGzC9<;O>68c2%`Bq{?UE2v`!#BQtLl@68*azjTdsrF7GC{6dm%i-89tqS0dRF zaYi2ttch)CC9QeCj{UKsf8BGp7?UUt#TVXnZCPd_I^u0YZU4`6V{H$yTq!O8@TRt` z$9yY(1^>3%Z=YnB#Y&+oTmTd=xM(pzL4o) zk0&-ZMAye6hS8_8j7GG^dl${KM9Y4*-L`p%n*I^f+uhS_@+i(}`hb0tL}b?!5u+*p zhMwd#LAJxY@8)a-sBf3hsNyh{zmz7T^v5mKyJv3xh;dUrx%dyma+LNJCB zGqIa-IyLD3hxpgwzS3*yRQ z>`BaQZ7tmg06-shqM;{IN&!rg z0|1#D$7J!t^|OM*!HEQ}BebA}~h z0D#rJMvWRB;L$^PN?{^1LdXzj3P8bfu}>K(W;_rDD?9GA(N=Q^b@ZY08Apg zyXQHWBmi)_q7??Q%{dNRf*&vGil`2z1iPi<+2@bra*Z}}~{>mg`VBFvy z4i!P|LaGA%NEyVw;Zagr8nT-y5l(K-(A;eV+eaA>R|0hU(;|MIe3#J0sio)(lwQz zHADa!{E+L$0iv;h>q>K{JT>mX0JaMO$i@gOvfPA_ivU0`iGSpcZO;L$AKOvdTl$|# yi{V3lWh(ojI(NMk?*?i{>x=fzTE~-lH}3&jYE$=vvlS80mTvVG2(#CvDSH851a%Vt literal 0 HcmV?d00001 From df8498bb7d7a507f1e28c2afcbb0c2d00b9dc5d3 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 24 Feb 2025 21:39:42 -0500 Subject: [PATCH 2/3] Update tutorials/shaders/custom_postprocessing.rst --- tutorials/shaders/custom_postprocessing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/shaders/custom_postprocessing.rst b/tutorials/shaders/custom_postprocessing.rst index d01766d0ea5..9177af9e1f0 100644 --- a/tutorials/shaders/custom_postprocessing.rst +++ b/tutorials/shaders/custom_postprocessing.rst @@ -23,7 +23,7 @@ Post-processing effects are shaders applied to a frame after Godot has rendered it. To apply a shader to a frame, create a :ref:`CanvasLayer `, and give it a :ref:`ColorRect `. Assign a new :ref:`ShaderMaterial ` to the newly created -``ColorRect``, and set the ``ColorRect``'s anchors preset to Full Rect: +``ColorRect``, and set the ``ColorRect``'s anchor preset to Full Rect: .. figure:: img/custom_postprocessing_anchors_preset_full_rect.webp :align: center From d8f60ffd58ef6ba74ee0b37cf5543caa9f72a99c Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 26 Feb 2025 21:23:48 -0500 Subject: [PATCH 3/3] Update tutorials/shaders/custom_postprocessing.rst Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- tutorials/shaders/custom_postprocessing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/shaders/custom_postprocessing.rst b/tutorials/shaders/custom_postprocessing.rst index 9177af9e1f0..2fce2cff470 100644 --- a/tutorials/shaders/custom_postprocessing.rst +++ b/tutorials/shaders/custom_postprocessing.rst @@ -27,9 +27,9 @@ new :ref:`ShaderMaterial ` to the newly created .. figure:: img/custom_postprocessing_anchors_preset_full_rect.webp :align: center - :alt: Setting the anchors preset to Full Rect on the ColorRect node + :alt: Setting the anchor preset to Full Rect on the ColorRect node - Setting the anchors preset to Full Rect on the ColorRect node + Setting the anchor preset to Full Rect on the ColorRect node Your scene tree will look something like this: