Browse Source

Shading language: Formatting

Max Hilbrunner 7 years ago
parent
commit
2247096a08
1 changed files with 8 additions and 30 deletions
  1. 8 30
      tutorials/shading/shading_language.rst

+ 8 - 30
tutorials/shading/shading_language.rst

@@ -7,7 +7,7 @@ Introduction
 ------------
 ------------
 
 
 Godot uses a shading language very similar to GLSL ES 3.0. Most datatypes and functions are supported,
 Godot uses a shading language very similar to GLSL ES 3.0. Most datatypes and functions are supported,
-and the remaining will likely be added over time.
+and the few remaining ones will likely be added over time.
 
 
 Unlike the shader language in Godot 2.x, this implementation is much closer to the original.
 Unlike the shader language in Godot 2.x, this implementation is much closer to the original.
 
 
@@ -15,7 +15,7 @@ Shader Types
 ------------
 ------------
 
 
 Instead of supplying a general purpose configuration, Godot Shading Language must
 Instead of supplying a general purpose configuration, Godot Shading Language must
-specify what shader is intended for. Depending on the type, different render
+specify what a shader is intended for. Depending on the type, different render
 modes, built-in variables and processing functions are supported.
 modes, built-in variables and processing functions are supported.
 
 
 Any shader needs a first line specifying this type, in the following format:
 Any shader needs a first line specifying this type, in the following format:
@@ -30,7 +30,6 @@ Valid types are:
 * "canvas_item": For 2D rendering.
 * "canvas_item": For 2D rendering.
 * "particles": For particle systems.
 * "particles": For particle systems.
 
 
-
 Render Modes
 Render Modes
 ------------
 ------------
 
 
@@ -42,10 +41,10 @@ be after the *shader_type*. Example syntax is:
     shader_type spatial;
     shader_type spatial;
     render_mode unshaded, cull_disabled;
     render_mode unshaded, cull_disabled;
 
 
-Data types:
------------
+Data types
+----------
 
 
-Most GLSL ES 3.0 datatypes are supported. Following is the list:
+Most GLSL ES 3.0 datatypes are supported:
 
 
 +-----------------+---------------------------------------------------------------------------+
 +-----------------+---------------------------------------------------------------------------+
 | Type            | Description                                                               |
 | Type            | Description                                                               |
@@ -99,11 +98,10 @@ Most GLSL ES 3.0 datatypes are supported. Following is the list:
 | **samplerCube** | Sampler type for binding Cubemaps, which are read as floats.              |
 | **samplerCube** | Sampler type for binding Cubemaps, which are read as floats.              |
 +-----------------+---------------------------------------------------------------------------+
 +-----------------+---------------------------------------------------------------------------+
 
 
-
 Casting
 Casting
 ~~~~~~~
 ~~~~~~~
 
 
-Just like GLSL ES 3.0, implicit casting is not allowed between scalars and vectors of the same size but different type.
+Just like GLSL ES 3.0, implicit casting between scalars and vectors of the same size but different type is not allowed.
 Casting of types of different size is also not allowed. Conversion must be done explicitly via constructors.
 Casting of types of different size is also not allowed. Conversion must be done explicitly via constructors.
 
 
 Example:
 Example:
@@ -235,7 +233,7 @@ Godot Shading language supports the most common types of flow control:
     }
     }
 
 
     // for loops
     // for loops
-    for     (int i = 0; i < 10; i++) {
+    for (int i = 0; i < 10; i++) {
 
 
     }
     }
 
 
@@ -261,7 +259,6 @@ It's possible to define any function in a Godot shader. They take the following
 .. code-block:: glsl
 .. code-block:: glsl
 
 
     ret_type func_name(args) {
     ret_type func_name(args) {
-
         return ret_type; // if returning a value
         return ret_type; // if returning a value
     }
     }
 
 
@@ -288,8 +285,6 @@ Example below:
         result = a + b;
         result = a + b;
     }
     }
 
 
-
-
 Processor Functions
 Processor Functions
 -------------------
 -------------------
 
 
@@ -314,7 +309,6 @@ vertex functions are not that commonly used.
         VERTEX.x += sin(TIME); // offset vertex x by sine function on time elapsed
         VERTEX.x += sin(TIME); // offset vertex x by sine function on time elapsed
     }
     }
 
 
-
 Fragment Processor
 Fragment Processor
 ~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~
 
 
@@ -343,7 +337,6 @@ and does not run if no lights affect the object).
         DIFFUSE_LIGHT = vec3(0.0, 1.0, 0.0);
         DIFFUSE_LIGHT = vec3(0.0, 1.0, 0.0);
     }
     }
 
 
-
 Varyings
 Varyings
 ~~~~~~~~
 ~~~~~~~~
 
 
@@ -351,7 +344,6 @@ To send data from vertex to fragment shader, *varyings* are used. They are set f
 in the *vertex processor*, and the value is interpolated (and perspective corrected) when reaching every
 in the *vertex processor*, and the value is interpolated (and perspective corrected) when reaching every
 pixel in the fragment processor.
 pixel in the fragment processor.
 
 
-
 .. code-block:: glsl
 .. code-block:: glsl
 
 
     shader_type spatial;
     shader_type spatial;
@@ -411,11 +403,9 @@ Uniforms can't be written from within the shader.
 
 
     uniform float some_value;
     uniform float some_value;
 
 
-
 Any type except for *void* can be a uniform. Additionally, Godot provides optional shader hints
 Any type except for *void* can be a uniform. Additionally, Godot provides optional shader hints
 to make the compiler understand what the uniform is used for.
 to make the compiler understand what the uniform is used for.
 
 
-
 .. code-block:: glsl
 .. code-block:: glsl
 
 
     shader_type spatial;
     shader_type spatial;
@@ -451,10 +441,8 @@ As Godot 3D engine renders in linear color space, it's important to understand t
 that are supplied as color (ie, albedo) need to be specified as such for proper SRGB->linear
 that are supplied as color (ie, albedo) need to be specified as such for proper SRGB->linear
 conversion.
 conversion.
 
 
-
 Uniforms can also be assigned default values:
 Uniforms can also be assigned default values:
 
 
-
 .. code-block:: glsl
 .. code-block:: glsl
 
 
     shader_type spatial;
     shader_type spatial;
@@ -462,15 +450,12 @@ Uniforms can also be assigned default values:
     uniform vec4 some_vector = vec4(0.0);
     uniform vec4 some_vector = vec4(0.0);
     uniform vec4 some_color : hint_color = vec4(1.0);
     uniform vec4 some_color : hint_color = vec4(1.0);
 
 
-
-
 Built-in Functions
 Built-in Functions
 ------------------
 ------------------
 
 
 A large number of built-in functions are supported, conforming mostly to GLSL ES 3.0.
 A large number of built-in functions are supported, conforming mostly to GLSL ES 3.0.
 When vec_type (float), vec_int_type, vec_uint_type, vec_bool_type nomenclature is used, it can be scalar or vector.
 When vec_type (float), vec_int_type, vec_uint_type, vec_bool_type nomenclature is used, it can be scalar or vector.
 
 
-
 +-----------------------------------------------------------------------------------------------+------------------------------------------------+
 +-----------------------------------------------------------------------------------------------+------------------------------------------------+
 | Function                                                                                      | Description                                    |
 | Function                                                                                      | Description                                    |
 +===============================================================================================+================================================+
 +===============================================================================================+================================================+
@@ -788,7 +773,6 @@ happen later, though) with the following code, so it can be done manually:
         // same as above for binormal and tangent, if normal mapping is used
         // same as above for binormal and tangent, if normal mapping is used
     }
     }
 
 
-
 Other built-ins such as UV, UV2 and COLOR are also passed through to the fragment function if not modified.
 Other built-ins such as UV, UV2 and COLOR are also passed through to the fragment function if not modified.
 
 
 For instancing, the INSTANCE_CUSTOM variable contains the instance custom data. When using particles, this information
 For instancing, the INSTANCE_CUSTOM variable contains the instance custom data. When using particles, this information
@@ -801,7 +785,6 @@ is usually:
 This allows to easily adjust the shader to a particle system using default particles material. When writing a custom particles
 This allows to easily adjust the shader to a particle system using default particles material. When writing a custom particles
 shader, this value can be used as desired.
 shader, this value can be used as desired.
 
 
-
 Fragment Built-Ins
 Fragment Built-Ins
 ^^^^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^^^^
 
 
@@ -930,7 +913,6 @@ performance or force a specific pipeline.
 To write a light shader, simply make sure to assign something to DIFFUSE_LIGHT or SPECULAR_LIGHT.
 To write a light shader, simply make sure to assign something to DIFFUSE_LIGHT or SPECULAR_LIGHT.
 Assigning nothing means no light is processed.
 Assigning nothing means no light is processed.
 
 
-
 Canvas Item
 Canvas Item
 ~~~~~~~~~~~~
 ~~~~~~~~~~~~
 
 
@@ -986,7 +968,6 @@ Vertex Built-Ins
 | out float **POINT_SIZE**       | Point size for point drawing.                                  |
 | out float **POINT_SIZE**       | Point size for point drawing.                                  |
 +--------------------------------+----------------------------------------------------------------+
 +--------------------------------+----------------------------------------------------------------+
 
 
-
 Vertex data (VERTEX) is presented in local space.
 Vertex data (VERTEX) is presented in local space.
 If not written to, these values will not be modified and be passed through as they came.
 If not written to, these values will not be modified and be passed through as they came.
 
 
@@ -1003,7 +984,6 @@ happen later, though) with the following code, so it can be done manually:
         VERTEX = (EXTRA_MATRIX * (WORLD_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
         VERTEX = (EXTRA_MATRIX * (WORLD_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
     }
     }
 
 
-
 Other built-ins such as UV and COLOR are also passed through to the fragment function if not modified.
 Other built-ins such as UV and COLOR are also passed through to the fragment function if not modified.
 
 
 For instancing, the INSTANCE_CUSTOM variable contains the instance custom data. When using particles, this information
 For instancing, the INSTANCE_CUSTOM variable contains the instance custom data. When using particles, this information
@@ -1093,7 +1073,6 @@ Light Built-Ins
 |                                     | Can be modified.                                                              |
 |                                     | Can be modified.                                                              |
 +-------------------------------------+-------------------------------------------------------------------------------+
 +-------------------------------------+-------------------------------------------------------------------------------+
 
 
-
 Particles
 Particles
 ~~~~~~~~~
 ~~~~~~~~~
 
 
@@ -1147,5 +1126,4 @@ Vertex Built-Ins
 | in uint **RANDOM_SEED**         | Random seed used as base for random.                      |
 | in uint **RANDOM_SEED**         | Random seed used as base for random.                      |
 +---------------------------------+-----------------------------------------------------------+
 +---------------------------------+-----------------------------------------------------------+
 
 
-Particle shades only support vertex processing. They are drawn with any regular material for CanvasItem or Spatial, depending on
-whether they are 2D or 3D.
+Particle shades only support vertex processing. They are drawn with any regular material for CanvasItem or Spatial, depending on whether they are 2D or 3D.