Skip to content

Commit

Permalink
Fix GLSL 4.0 mistake
Browse files Browse the repository at this point in the history
Should have stated functions are based on GLSL ES 3.0 (GLSL != GLSL ES)
  • Loading branch information
AshbyGeek authored Sep 25, 2024
1 parent 9e39260 commit 4363a07
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions tutorials/shaders/shader_reference/shader_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Built-in functions
==================

Godot supports a large number of built-in functions, conforming roughly to the
GLSL 4.00 specification.
GLSL ES 3.0 specification.

.. note::
The following type aliases only used in documentation to reduce repetitive function declarations.
Expand Down Expand Up @@ -40,19 +40,23 @@ GLSL 4.00 specification.
Many functions that accept one or more vectors or matrices perform the described function on each component of the vector/matrix.
Some examples:

+-----------------------------------+-----------------------------------------------------+
| Operation | Equivalent Scalar Operation |
+===================================+=====================================================+
| ``sqrt(vec2(4,64))`` | ``vec2(sqrt(4),sqrt(64))`` |
+-----------------------------------+-----------------------------------------------------+
| ``min(vec2(3,4),1)`` | ``vec2(min(3,1),min(4,1))`` |
+-----------------------------------+-----------------------------------------------------+
| ``min(vec3(1,2,3),vec3(5,1,3))`` | ``vec3(min(1,5),min(2,1),min(3,3))`` |
+-----------------------------------+-----------------------------------------------------+
| ``pow(vec3(3,8,5),2)`` | ``vec3(pow(3,2),pow(8,2),pow(5,2))`` |
+-----------------------------------+-----------------------------------------------------+
| ``pow(vec3(3,8,5),vec3(1,2,4))`` | ``vec3(pow(3,1),pow(8,2),pow(5,4))`` |
+-----------------------------------+-----------------------------------------------------+
.. table::
:class: nowrap-col2 nowrap-col1
:widths: auto

+---------------------------------------+-----------------------------------------------------+
| Operation | Equivalent Scalar Operation |
+=======================================+=====================================================+
| ``sqrt(vec2(4, 64))`` | ``vec2(sqrt(4), sqrt(64))`` |
+---------------------------------------+-----------------------------------------------------+
| ``min(vec2(3, 4), 1)`` | ``vec2(min(3, 1), min(4, 1))`` |
+---------------------------------------+-----------------------------------------------------+
| ``min(vec3(1, 2, 3),vec3(5, 1, 3))`` | ``vec3(min(1, 5), min(2, 1), min(3, 3))`` |
+---------------------------------------+-----------------------------------------------------+
| ``pow(vec3(3, 8, 5 ), 2)`` | ``vec3(pow(3, 2), pow(8, 2), pow(5, 2))`` |
+---------------------------------------+-----------------------------------------------------+
| ``pow(vec3(3, 8, 5), vec3(1, 2, 4))`` | ``vec3(pow(3, 1), pow(8, 2), pow(5, 4))`` |
+---------------------------------------+-----------------------------------------------------+

The `GLSL Language Specification <http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf>`_ says under section 5.10 Vector and Matrix Operations:

Expand Down

0 comments on commit 4363a07

Please sign in to comment.