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

This commit is contained in:
Jérôme GULLY
2019-10-29 08:56:35 +01:00
committed by Rémi Verschelde
parent 8eff390ddd
commit c3c2a8819b

View File

@@ -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.