Browse Source

add doc workaround textureSize() with gles2 (#2811)

Jérôme GULLY 5 years ago
parent
commit
c3c2a8819b
1 changed files with 21 additions and 2 deletions
  1. 21 2
      tutorials/misc/gles2_gles3_differences.rst

+ 21 - 2
tutorials/misc/gles2_gles3_differences.rst

@@ -167,9 +167,9 @@ For a complete list of built-in GLSL functions see the :ref:`Shading Language do
 +------------------------------------------------------------------------+--------------------------------------------------+
 | mat_type **inverse** ( mat_type )                                      |                                                  |
 +------------------------------------------------------------------------+--------------------------------------------------+
-| ivec2 **textureSize** ( sampler2D_type s, int lod )                    |                                                  |
+| ivec2 **textureSize** ( sampler2D_type s, int lod )                    | See workaround below                                         |
 +------------------------------------------------------------------------+--------------------------------------------------+
-| ivec2 **textureSize** ( samplerCube s, int lod )                       |                                                  |
+| ivec2 **textureSize** ( samplerCube s, int lod )                       | See workaround below                                                 |
 +------------------------------------------------------------------------+--------------------------------------------------+
 | vec4_type **texture** ( sampler2D_type s, vec2 uv [, float bias] )     | **bias** not available in vertex shader          |
 +------------------------------------------------------------------------+--------------------------------------------------+
@@ -196,6 +196,25 @@ For a complete list of built-in GLSL functions see the :ref:`Shading Language do
 | vec_type **fwidth** ( vec_type )                                       |                                                  |
 +------------------------------------------------------------------------+--------------------------------------------------+
 
+``textureSize()`` workaround
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+GLES2 does not support ``textureSize()``. You can get the size of a texture the old fashioned way by passing in a 
+uniform with the texture size yourself.
+
+.. code-block:: glsl
+
+    // In the shader:
+    uniform sampler2D textureName;
+    uniform vec2 textureName_size;
+
+::
+
+    # In GDScript:
+    material_name.set_shader_param("textureName", my_texture)
+    material_name.set_shader_param("textureName_size", my_texture_size)
+
+
 Godot also provides many built-in variables and render modes. Some cannot be supported in GLES2. Below is a list of
 built-in variables and render modes that, when written to, will have no effect or could even cause issues when using 
 the GLES2 backend.