Fix various Sphinx warnings
@@ -15,7 +15,7 @@ C++ and Objective-C
|
|||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
There are no written guidelines, but the code style agreed upon by the
|
There are no written guidelines, but the code style agreed upon by the
|
||||||
developers is enforced via the `clang-format <http://clang.llvm.org/docs/ClangFormat.html>`_
|
developers is enforced via the `clang-format <http://clang.llvm.org/docs/ClangFormat.html>`__
|
||||||
code beautifier, which takes care for you of all our conventions.
|
code beautifier, which takes care for you of all our conventions.
|
||||||
To name a few:
|
To name a few:
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ To name a few:
|
|||||||
to the type name
|
to the type name
|
||||||
|
|
||||||
The rules used by clang-format are outlined in the
|
The rules used by clang-format are outlined in the
|
||||||
`.clang-format <https://github.com/godotengine/godot/blob/master/.clang-format>`_
|
`.clang-format <https://github.com/godotengine/godot/blob/master/.clang-format>`__
|
||||||
file of the Godot repository.
|
file of the Godot repository.
|
||||||
|
|
||||||
As long as you ensure that your style matches the surrounding code and that you
|
As long as you ensure that your style matches the surrounding code and that you
|
||||||
@@ -62,7 +62,7 @@ Here's how to install clang-format:
|
|||||||
- Linux: It will usually be available out-of-the-box with the clang toolchain
|
- Linux: It will usually be available out-of-the-box with the clang toolchain
|
||||||
packaged by your distribution.
|
packaged by your distribution.
|
||||||
- macOS and Windows: You can download precompiled binaries from the
|
- macOS and Windows: You can download precompiled binaries from the
|
||||||
`LLVM website <http://llvm.org/releases/download.html>`_. You may need to add
|
`LLVM website <http://llvm.org/releases/download.html>`__. You may need to add
|
||||||
the path to the binary's folder to your system's ``PATH`` environment
|
the path to the binary's folder to your system's ``PATH`` environment
|
||||||
variable to be able to call ``clang-format`` out of the box.
|
variable to be able to call ``clang-format`` out of the box.
|
||||||
|
|
||||||
@@ -76,13 +76,10 @@ command:
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
clang-format -i -style=file <path/to/file(s)>
|
clang-format -i <path/to/file(s)>
|
||||||
|
|
||||||
- ``-i`` means that the changes should be written directly to the file (by
|
- ``-i`` means that the changes should be written directly to the file (by
|
||||||
default clang-format would only output the fixed version to the terminal).
|
default clang-format would only output the fixed version to the terminal).
|
||||||
- ``-style=file`` tells clang-format to use the ``.clang-format`` file of
|
|
||||||
Godot's repository as a style guide. Note that the ``file`` part is the
|
|
||||||
actual "file" word, not a path to a file.
|
|
||||||
- The path can point to several files, either one after the other or using
|
- The path can point to several files, either one after the other or using
|
||||||
wildcards like in a typical Unix shell. Be careful when globbing so that
|
wildcards like in a typical Unix shell. Be careful when globbing so that
|
||||||
you don't run clang-format on compiled objects (.o and .a files) that are
|
you don't run clang-format on compiled objects (.o and .a files) that are
|
||||||
@@ -111,9 +108,9 @@ clang-format automatically, for example each time you save a file.
|
|||||||
|
|
||||||
Here is a non-exhaustive list of beautifier plugins for some IDEs:
|
Here is a non-exhaustive list of beautifier plugins for some IDEs:
|
||||||
|
|
||||||
- Qt Creator: `Beautifier plugin <http://doc.qt.io/qtcreator/creator-beautifier.html>`_
|
- Qt Creator: `Beautifier plugin <http://doc.qt.io/qtcreator/creator-beautifier.html>`__
|
||||||
- Visual Studio Code: `Clang-Format <https://marketplace.visualstudio.com/items?itemName=xaver.clang-format>`_
|
- Visual Studio Code: `Clang-Format <https://marketplace.visualstudio.com/items?itemName=xaver.clang-format>`__
|
||||||
- vim: `vim-clang-format <https://github.com/rhysd/vim-clang-format>`_
|
- vim: `vim-clang-format <https://github.com/rhysd/vim-clang-format>`__
|
||||||
|
|
||||||
(Pull requests welcome to extend this list with tested plugins.)
|
(Pull requests welcome to extend this list with tested plugins.)
|
||||||
|
|
||||||
@@ -131,7 +128,7 @@ Python
|
|||||||
Godot's SCons buildsystem is written in Python 2, and various scripts included
|
Godot's SCons buildsystem is written in Python 2, and various scripts included
|
||||||
in the source tree are either in Python 2 or Python 3.
|
in the source tree are either in Python 2 or Python 3.
|
||||||
|
|
||||||
For those, we follow the `PEP-8 style guide <https://www.python.org/dev/peps/pep-0008/>`_,
|
For those, we follow the `PEP-8 style guide <https://www.python.org/dev/peps/pep-0008/>`__,
|
||||||
this is however not as strongly enforced as for the C++ code. If you are so
|
this is however not as strongly enforced as for the C++ code. If you are so
|
||||||
inclined, you can check and format your Python changes using
|
inclined, you can check and format your Python changes using
|
||||||
`autopep8 <https://pypi.python.org/pypi/autopep8>`_.
|
`autopep8 <https://pypi.python.org/pypi/autopep8>`__.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Differences
|
|||||||
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
||||||
| | Unity | Godot |
|
| | Unity | Godot |
|
||||||
+===================+===================================================================================+================================================================================================================+
|
+===================+===================================================================================+================================================================================================================+
|
||||||
| License | Proprietary, closed, free license with revenue caps and usage restrictions | MIT License, free and fully open source without any restriction |
|
| License | Proprietary, closed, free license with revenue caps and usage restrictions | MIT license, free and fully open source without any restriction |
|
||||||
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
||||||
| OS (editor) | Windows, OSX, Linux (unofficial and unsupported) | Windows, X11 (Linux, \*BSD), Haiku, OSX |
|
| OS (editor) | Windows, OSX, Linux (unofficial and unsupported) | Windows, X11 (Linux, \*BSD), Haiku, OSX |
|
||||||
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
||||||
@@ -23,7 +23,7 @@ Differences
|
|||||||
| | | Mobile: Android, iOS, Windows Phone, Tizen, | | Mobile: Android, iOS, Blackberry (deprecated) |
|
| | | Mobile: Android, iOS, Windows Phone, Tizen, | | Mobile: Android, iOS, Blackberry (deprecated) |
|
||||||
| | | Web: WebGL | | Web: WebGL, HTML5 (via emscripten, broken) |
|
| | | Web: WebGL | | Web: WebGL, HTML5 (via emscripten, broken) |
|
||||||
| | | Consoles: PS4, PS Vita, XBox One, XBox 360, WiiU, 3DS | |
|
| | | Consoles: PS4, PS Vita, XBox One, XBox 360, WiiU, 3DS | |
|
||||||
| | | VR: Oculus Rift, SteamVR, Google Cardboard, Playstation VR, Gear VR, HoloLens | |
|
| | | VR: Oculus Rift, SteamVR, Google Cardboard, Playstation VR, Gear VR, HoloLens | |
|
||||||
| | | TV: AndroidTV, Samsung SMARTTV, tvOS | |
|
| | | TV: AndroidTV, Samsung SMARTTV, tvOS | |
|
||||||
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
+-------------------+-----------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+
|
||||||
| Scene system | | Component/Scene (GameObject > Component) | Scene tree and nodes, allowing scenes to be nested and/or inherit other scenes |
|
| Scene system | | Component/Scene (GameObject > Component) | Scene tree and nodes, allowing scenes to be nested and/or inherit other scenes |
|
||||||
@@ -177,11 +177,9 @@ You can control nodes by accessing them using a script, and call functions (buil
|
|||||||
But there's more! Certain nodes throw signals when certain actions happen. You can connect these signals to call a specific function when they happen. Note that you can define your own signals and send them whenever you want. This feature is documented `here <gdscript.html#signals>`_.
|
But there's more! Certain nodes throw signals when certain actions happen. You can connect these signals to call a specific function when they happen. Note that you can define your own signals and send them whenever you want. This feature is documented `here <gdscript.html#signals>`_.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Using Godot in C++
|
Using Godot in C++
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Just for your information, Godot also allows you to develop your project directly in C++ by using its API, which is not possible with Unity at the moment. As an example, you can consider Godot Engine's editor as a "game" written in C++ using Godot API.
|
Just for your information, Godot also allows you to develop your project directly in C++ by using its API, which is not possible with Unity at the moment. As an example, you can consider Godot Engine's editor as a "game" written in C++ using Godot API.
|
||||||
|
|
||||||
If you are interested in using Godot in C++, you may want to start reading the `Developing in C++ <_developing.html>`_ page.
|
If you are interested in using Godot in C++, you may want to start reading the `Developing in C++ <_developing.html>`_ page.
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
@@ -8,6 +8,6 @@
|
|||||||
introduction_to_3d
|
introduction_to_3d
|
||||||
3d_performance_and_limitations
|
3d_performance_and_limitations
|
||||||
spatial_material
|
spatial_material
|
||||||
shader_material
|
shader_materials
|
||||||
high_dynamic_range
|
high_dynamic_range
|
||||||
using_gridmaps
|
using_gridmaps
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ this little menu inside the window because it is often overlooked!
|
|||||||
.. image:: img/tuto_3d6.png
|
.. image:: img/tuto_3d6.png
|
||||||
|
|
||||||
Default environment
|
Default environment
|
||||||
----------------
|
-------------------
|
||||||
|
|
||||||
When created from the Project Manager, the 3D environment has a default sky.
|
When created from the Project Manager, the 3D environment has a default sky.
|
||||||
|
|
||||||
@@ -215,4 +215,3 @@ Lights
|
|||||||
|
|
||||||
There is no limitation on the number of lights nor of types of lights in
|
There is no limitation on the number of lights nor of types of lights in
|
||||||
Godot. As many as desired can be added (as long as performance allows).
|
Godot. As many as desired can be added (as long as performance allows).
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.. _doc_spatial_material:
|
.. _doc_spatial_material:
|
||||||
|
|
||||||
Spatial Material
|
Spatial Material
|
||||||
===============
|
================
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
@@ -68,7 +68,7 @@ Additionaly, on very low end devices such as mobile, switching to vertex lightin
|
|||||||
Keep in mind that, when vertex lighting is enabled, only directional lighting can produce shadows (for performance reasons).
|
Keep in mind that, when vertex lighting is enabled, only directional lighting can produce shadows (for performance reasons).
|
||||||
|
|
||||||
No Depth Test
|
No Depth Test
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
In order for close objects to appear over far away objects, depth testing is performed.
|
In order for close objects to appear over far away objects, depth testing is performed.
|
||||||
Disabling it has the result of objects appearing over (or under) everything else.
|
Disabling it has the result of objects appearing over (or under) everything else.
|
||||||
@@ -179,8 +179,8 @@ Specifies when depth rendering must take place.
|
|||||||
* Opaque Only (default): Depth is only drawn for opaque objects
|
* Opaque Only (default): Depth is only drawn for opaque objects
|
||||||
* Always: Depth draw is drawn for both opaque and transparent objects
|
* Always: Depth draw is drawn for both opaque and transparent objects
|
||||||
* Never: No depth draw takes place (note: do not confuse with depth test option above)
|
* Never: No depth draw takes place (note: do not confuse with depth test option above)
|
||||||
* Depth Pre-Pass: For transparent objects, an opaque pass is made first with the opaque parts, then tranparency is drawn above. Use this option
|
* Depth Pre-Pass: For transparent objects, an opaque pass is made first with the opaque parts,
|
||||||
with transparent grass or tree foliage.
|
then tranparency is drawn above. Use this option with transparent grass or tree foliage.
|
||||||
|
|
||||||
.. image:: img/material_depth_draw.png
|
.. image:: img/material_depth_draw.png
|
||||||
|
|
||||||
@@ -389,5 +389,3 @@ Render Priority
|
|||||||
---------------
|
---------------
|
||||||
|
|
||||||
Rendering order can be changed for objects, although this is mostly useful for transparent ojects (or opaque objects that do depth draw but no color draw, useful for cracks on the floor).
|
Rendering order can be changed for objects, although this is mostly useful for transparent ojects (or opaque objects that do depth draw but no color draw, useful for cracks on the floor).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ Godot:
|
|||||||
|
|
||||||
|
|
||||||
DEPTH_TEXTURE
|
DEPTH_TEXTURE
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
For 3D Shaders, it's also possible to access the screen depth buffer. For this,
|
For 3D Shaders, it's also possible to access the screen depth buffer. For this,
|
||||||
the DEPTH_TEXTURE built-in is used. This texture is not linear, it must be
|
the DEPTH_TEXTURE built-in is used. This texture is not linear, it must be
|
||||||
@@ -130,6 +130,3 @@ The following code retrieves the 3D position below the pixel being drawn:
|
|||||||
float depth = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;
|
float depth = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;
|
||||||
vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth*2.0-1.0,1.0);
|
vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth*2.0-1.0,1.0);
|
||||||
vec3 pixel_position = upos.xyz/upos.w;
|
vec3 pixel_position = upos.xyz/upos.w;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Any shader needs a first line specifying this type, in the following format:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type <type>;
|
shader_type <type>;
|
||||||
|
|
||||||
Valid types are:
|
Valid types are:
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ be after the *shader_type*. Example syntax is:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
render_mode unshaded,cull_disabled;
|
render_mode unshaded, cull_disabled;
|
||||||
|
|
||||||
Data types:
|
Data types:
|
||||||
-----------
|
-----------
|
||||||
@@ -110,22 +110,22 @@ Example:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
float a = 2; // valid
|
float a = 2; // valid
|
||||||
float a = 2.0; // valid
|
float a = 2.0; // valid
|
||||||
float a = float(2); // valid
|
float a = float(2); // valid
|
||||||
|
|
||||||
Default integer constants are signed, so casting is always needed to convert to unsigned:
|
Default integer constants are signed, so casting is always needed to convert to unsigned:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
int a = 2; // valid
|
int a = 2; // valid
|
||||||
uint a = 2; // invalid
|
uint a = 2; // invalid
|
||||||
uint a = uint(2); // valid
|
uint a = uint(2); // valid
|
||||||
|
|
||||||
Members
|
Members
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
Individual scalar members of vector types are accessed via the "x", "y", "z" and "w" members. Alternatively, using "r", "g", "b" and "a" also works and is equivalent.
|
Individual scalar members of vector types are accessed via the "x", "y", "z" and "w" members. Alternatively, using "r", "g", "b" and "a" also works and is equivalent.
|
||||||
Use whatever fits best for your use case.
|
Use whatever fits best for your use case.
|
||||||
|
|
||||||
For matrices, use [idx] indexing syntax to access each vector.
|
For matrices, use [idx] indexing syntax to access each vector.
|
||||||
@@ -137,28 +137,28 @@ Construction of vector types must always pass:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
// The required amount of scalars
|
// The required amount of scalars
|
||||||
vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
|
vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
|
||||||
// Complementary vectors and/or scalars
|
// Complementary vectors and/or scalars
|
||||||
vec4 a = vec4( vec2(0.0, 1.0), vec2(2.0, 3.0) );
|
vec4 a = vec4(vec2(0.0, 1.0), vec2(2.0, 3.0));
|
||||||
vec4 a = vec4( vec3(0.0, 1.0, 2.0), 3.0 );
|
vec4 a = vec4(vec3(0.0, 1.0, 2.0), 3.0);
|
||||||
// A single scalar for the whole vector
|
// A single scalar for the whole vector
|
||||||
vec4 a = vec4( 0.0 );
|
vec4 a = vec4(0.0);
|
||||||
|
|
||||||
Swizzling
|
Swizzling
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
|
||||||
It is possible to obtain any combination of them in any order, as long as the result is another vector type (or scalar).
|
It is possible to obtain any combination of them in any order, as long as the result is another vector type (or scalar).
|
||||||
This is easier shown than explained:
|
This is easier shown than explained:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
|
vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
|
||||||
vec3 b = a.rgb; // Creates a vec3 with vec4 components
|
vec3 b = a.rgb; // Creates a vec3 with vec4 components
|
||||||
vec3 b = a.aaa; // Also valid, creates a vec3 and fills it with "a".
|
vec3 b = a.aaa; // Also valid, creates a vec3 and fills it with "a".
|
||||||
vec3 b = a.bgr; // Order does not matter
|
vec3 b = a.bgr; // Order does not matter
|
||||||
vec3 b = a.xyz; // Also rgba, xyzw are equivalent
|
vec3 b = a.xyz; // Also rgba, xyzw are equivalent
|
||||||
float c = b.w; // Invalid, because "w" is not present in vec3 b
|
float c = b.w; // Invalid, because "w" is not present in vec3 b
|
||||||
|
|
||||||
Precision
|
Precision
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
@@ -167,9 +167,9 @@ It is possible to add precision modifiers to datatypes, use them for uniforms, v
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
lowp vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // low precision, usually 8 bits per component mapped to 0-1
|
lowp vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // low precision, usually 8 bits per component mapped to 0-1
|
||||||
mediump vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // medium precision, usually 16 bits or half float
|
mediump vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // medium precision, usually 16 bits or half float
|
||||||
highp vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // high precision, uses full float or integer range (default)
|
highp vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // high precision, uses full float or integer range (default)
|
||||||
|
|
||||||
|
|
||||||
Using lower precision for some operations can speed up the math involved (at the cost of, of course, less precision).
|
Using lower precision for some operations can speed up the math involved (at the cost of, of course, less precision).
|
||||||
@@ -191,7 +191,7 @@ Godot shading language supports the same set of operators as GLSL ES 3.0. Below
|
|||||||
+-------------+-----------------------+--------------------+
|
+-------------+-----------------------+--------------------+
|
||||||
| 2 | unary | **+, -, !, ~** |
|
| 2 | unary | **+, -, !, ~** |
|
||||||
+-------------+-----------------------+--------------------+
|
+-------------+-----------------------+--------------------+
|
||||||
| 3 | multiplicative | **/, *, % ** |
|
| 3 | multiplicative | **/, \*, %** |
|
||||||
+-------------+-----------------------+--------------------+
|
+-------------+-----------------------+--------------------+
|
||||||
| 4 | additive | **+, -** |
|
| 4 | additive | **+, -** |
|
||||||
+-------------+-----------------------+--------------------+
|
+-------------+-----------------------+--------------------+
|
||||||
@@ -219,23 +219,23 @@ Godot Shading language supports the most common types of flow control:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
//if and else
|
// if and else
|
||||||
if (cond) {
|
if (cond) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//for loops
|
// for loops
|
||||||
for(int i=0;i<10;i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//whiles
|
// while
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Keep in mind that, in modern GPUs, an infinite loop can exist and can freeze your application (including editor).
|
Keep in mind that, in modern GPUs, an infinite loop can exist and can freeze your application (including editor).
|
||||||
Godot can't protect you from this, so be careful to not make this mistake!
|
Godot can't protect you from this, so be careful to not make this mistake!
|
||||||
@@ -252,16 +252,16 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// a better example:
|
// a better example:
|
||||||
|
|
||||||
int sum2(int a, int b) {
|
int sum2(int a, int b) {
|
||||||
return a+b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Functions can be used from any other function that is below it.
|
Functions can be used from any other function that is below it.
|
||||||
@@ -276,12 +276,12 @@ Example below:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
void sum2(int a, int b, inout int result) {
|
void sum2(int a, int b, inout int result) {
|
||||||
result = a+b;
|
result = a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Processor Functions
|
Processor Functions
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
@@ -300,11 +300,11 @@ vertex functions are not that commonly used.
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
void vertex() {
|
void vertex() {
|
||||||
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
|
||||||
@@ -315,11 +315,11 @@ runs on every visible pixel the object or primitive is drawn to.
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
ALBEDO=vec3(1.0,0.0,0.0); // use red for material albedo
|
ALBEDO = vec3(1.0, 0.0, 0.0); // use red for material albedo
|
||||||
}
|
}
|
||||||
|
|
||||||
Light Processor
|
Light Processor
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
@@ -329,11 +329,11 @@ and does not run if no lights affect the object).
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
void light() {
|
void light() {
|
||||||
COLOR=vec3(0.0,1.0,0.0);
|
COLOR = vec3(0.0, 1.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Varyings
|
Varyings
|
||||||
@@ -346,29 +346,29 @@ pixel in the fragment processor.
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
varying vec3 some_color;
|
varying vec3 some_color;
|
||||||
void vertex() {
|
void vertex() {
|
||||||
some_color = NORMAL; // make the normal the color
|
some_color = NORMAL; // make the normal the color
|
||||||
}
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
ALBEDO = some_color;
|
ALBEDO = some_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uniforms
|
Uniforms
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
Passing values to shaders is possible. These are global to the whole shader and called *uniforms*.
|
Passing values to shaders is possible. These are global to the whole shader and called *uniforms*.
|
||||||
When a shader is later assigned to a material, the uniforms will appear as editable parameters on it.
|
When a shader is later assigned to a material, the uniforms will appear as editable parameters on it.
|
||||||
Uniforms can't be written from within the shader.
|
Uniforms can't be written from within the shader.
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
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
|
||||||
@@ -377,10 +377,10 @@ to make the compiler understand what the uniform is used for.
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
uniform vec4 color : hint_color;
|
uniform vec4 color : hint_color;
|
||||||
uniform float amount : hint_range(0,1);
|
uniform float amount : hint_range(0, 1);
|
||||||
|
|
||||||
|
|
||||||
Full list of hints below:
|
Full list of hints below:
|
||||||
@@ -416,9 +416,9 @@ Uniforms can also be assigned default values:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
|
|
||||||
uniform vec4 some_vector = vec4(0.0);
|
uniform vec4 some_vector = vec4(0.0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -429,8 +429,6 @@ A large number of built-in functions are supported, conforming mostly to GLSL ES
|
|||||||
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 |
|
||||||
+=======================================================================+=============================================+
|
+=======================================================================+=============================================+
|
||||||
@@ -584,7 +582,7 @@ When vec_type (float), vec_int_type, vec_uint_type, vec_bool_type nomenclature i
|
|||||||
|
|
||||||
|
|
||||||
Shader Types In-Depth
|
Shader Types In-Depth
|
||||||
------------------
|
---------------------
|
||||||
|
|
||||||
Spatial
|
Spatial
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
@@ -605,7 +603,7 @@ Render Modes
|
|||||||
+---------------------------------+----------------------------------------------------------------------+
|
+---------------------------------+----------------------------------------------------------------------+
|
||||||
| **blend_mul** | Multiplicative blend mode. |
|
| **blend_mul** | Multiplicative blend mode. |
|
||||||
+---------------------------------+----------------------------------------------------------------------+
|
+---------------------------------+----------------------------------------------------------------------+
|
||||||
| **depth_draw_opaque** | Only draw depth for opaque geometry (not transparent). |
|
| **depth_draw_opaque** | Only draw depth for opaque geometry (not transparent). |
|
||||||
+---------------------------------+----------------------------------------------------------------------+
|
+---------------------------------+----------------------------------------------------------------------+
|
||||||
| **depth_draw_always** | Always draw depth (opaque and transparent). |
|
| **depth_draw_always** | Always draw depth (opaque and transparent). |
|
||||||
+---------------------------------+----------------------------------------------------------------------+
|
+---------------------------------+----------------------------------------------------------------------+
|
||||||
@@ -698,29 +696,29 @@ Vertex Built-Ins
|
|||||||
Vertex data (VERTEX, NORMAL, TANGENT, BITANGENT) is presented in local model space. If not
|
Vertex data (VERTEX, NORMAL, TANGENT, BITANGENT) is presented in local model space. If not
|
||||||
written to, these values will not be modified and be passed through as they came.
|
written to, these values will not be modified and be passed through as they came.
|
||||||
|
|
||||||
They can be optionally set to be presented in world space (after being transformed by world)
|
They can be optionally set to be presented in world space (after being transformed by world)
|
||||||
by adding the *world_vertex_coords* render mode.
|
by adding the *world_vertex_coords* render mode.
|
||||||
|
|
||||||
It is also possible to completely disable the built-in modelview transform (projection will still
|
It is also possible to completely disable the built-in modelview transform (projection will still
|
||||||
happen later, though) with the following code, so it can be done manually:
|
happen later, though) with the following code, so it can be done manually:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
render_mode skip_vertex_transform;
|
render_mode skip_vertex_transform;
|
||||||
|
|
||||||
void vertex() {
|
void vertex() {
|
||||||
|
|
||||||
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX,1.0)).xyz;
|
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||||
NORMAL = (MODELVIEW_MATRIX * vec4(VERTEX,0.0)).xyz;
|
NORMAL = (MODELVIEW_MATRIX * vec4(VERTEX, 0.0)).xyz;
|
||||||
//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
|
||||||
is usually:
|
is usually:
|
||||||
|
|
||||||
* **x**: Rotation angle in radians.
|
* **x**: Rotation angle in radians.
|
||||||
* **y**: Phase during lifetime (0 to 1).
|
* **y**: Phase during lifetime (0 to 1).
|
||||||
@@ -862,7 +860,7 @@ Light Built-Ins
|
|||||||
+-----------------------------------+------------------------------------------+
|
+-----------------------------------+------------------------------------------+
|
||||||
|
|
||||||
Writing light shaders is completely optional. Unlike other game engines, they don't affect
|
Writing light shaders is completely optional. Unlike other game engines, they don't affect
|
||||||
performance or force a specific pipeline.
|
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.
|
||||||
@@ -932,19 +930,19 @@ happen later, though) with the following code, so it can be done manually:
|
|||||||
|
|
||||||
.. code-block:: glsl
|
.. code-block:: glsl
|
||||||
|
|
||||||
shader_type spatial;
|
shader_type spatial;
|
||||||
render_mode skip_vertex_transform;
|
render_mode skip_vertex_transform;
|
||||||
|
|
||||||
void vertex() {
|
void vertex() {
|
||||||
|
|
||||||
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
|
||||||
is usually:
|
is usually:
|
||||||
|
|
||||||
* **x**: Rotation angle in radians.
|
* **x**: Rotation angle in radians.
|
||||||
* **y**: Phase during lifetime (0 to 1).
|
* **y**: Phase during lifetime (0 to 1).
|
||||||
@@ -1079,6 +1077,3 @@ Vertex Built-Ins
|
|||||||
|
|
||||||
Particle shades only support vertex processing. They are drawn with any regular material for CanvasItem or Spatial, depending on
|
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.
|
whether they are 2D or 3D.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ to the high integration with Godot:
|
|||||||
* The editor integration is a pleasure to work with, with code completion expanding as far as completing nodes, signals, and many other items pertaining to the current scene being edited.
|
* The editor integration is a pleasure to work with, with code completion expanding as far as completing nodes, signals, and many other items pertaining to the current scene being edited.
|
||||||
* Has vector types built-in (such as Vectors, transorms etc), making it efficient for heavy linear algebra.
|
* Has vector types built-in (such as Vectors, transorms etc), making it efficient for heavy linear algebra.
|
||||||
* It supports multiple threads as well as statically typed languages (which is one of the limitation that avoided us going for other VMs such as Lua, Squirrel, etc).
|
* It supports multiple threads as well as statically typed languages (which is one of the limitation that avoided us going for other VMs such as Lua, Squirrel, etc).
|
||||||
* It uses no garbage collector, so it trades a small bit of automation (most
|
* It uses no garbage collector, so it trades a small bit of automation (most objects are reference counted anyway), by determinism.
|
||||||
objects are reference counted anyway), by determinism.
|
|
||||||
* The dynamic nature of it makes it easy to optimize chunks of it in C++ (via GDNative) if more performance is required at some point, without recompiling the engine.
|
* The dynamic nature of it makes it easy to optimize chunks of it in C++ (via GDNative) if more performance is required at some point, without recompiling the engine.
|
||||||
|
|
||||||
If undecided, and have experience in programming (specially dynamically
|
If undecided, and have experience in programming (specially dynamically
|
||||||
|
|||||||
|
After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
@@ -1,7 +1,7 @@
|
|||||||
.. _doc_import_images:
|
.. _doc_import_images:
|
||||||
|
|
||||||
Importing Images
|
Importing Images
|
||||||
==============
|
================
|
||||||
|
|
||||||
Why importing them?
|
Why importing them?
|
||||||
-------------------
|
-------------------
|
||||||
@@ -34,11 +34,11 @@ Compress Mode
|
|||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
* VRAM Compression: This is the most common copression mode for 3D assets. File on disk is reduced and
|
* VRAM Compression: This is the most common copression mode for 3D assets. File on disk is reduced and
|
||||||
video memory usage is also reduced considerably. For 3D, it may present unwanted arctifacts, though.
|
video memory usage is also reduced considerably. For 3D, it may present unwanted arctifacts, though.
|
||||||
* Lossless Compression: This is the most common compression for 2D assets. It shows assets without any
|
* Lossless Compression: This is the most common compression for 2D assets. It shows assets without any
|
||||||
kind of arctifacting, and disk compression is decent. It will use considerably more amount of video memory than VRAM, though.
|
kind of arctifacting, and disk compression is decent. It will use considerably more amount of video memory than VRAM, though.
|
||||||
* Lossy Compression: For games with lots of large 2D assets, lossy compression can be a great choice. It has some arctifacting,
|
* Lossy Compression: For games with lots of large 2D assets, lossy compression can be a great choice. It has some arctifacting,
|
||||||
but less than VRAM and the file size is almost a tenth of Lossless.
|
but less than VRAM and the file size is almost a tenth of Lossless.
|
||||||
* Uncompressed: Only useful for formats that can't be compressed (like, raw float).
|
* Uncompressed: Only useful for formats that can't be compressed (like, raw float).
|
||||||
|
|
||||||
In this table, each of the four options are described together with their
|
In this table, each of the four options are described together with their
|
||||||
@@ -60,6 +60,11 @@ advantages and disadvantages ( |good| = Best, |bad| =Worst ):
|
|||||||
| Load Time | |regular| Normal | |bad| Slow | |bad| Slow | |good| Fast |
|
| Load Time | |regular| Normal | |bad| Slow | |bad| Slow | |good| Fast |
|
||||||
+----------------+------------------------+---------------------------+-------------------------+------------------------------------------------------+
|
+----------------+------------------------+---------------------------+-------------------------+------------------------------------------------------+
|
||||||
|
|
||||||
|
.. |bad| image:: img/bad.png
|
||||||
|
|
||||||
|
.. |good| image:: img/good.png
|
||||||
|
|
||||||
|
.. |regular| image:: img/regular.png
|
||||||
|
|
||||||
HDR Mode
|
HDR Mode
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
@@ -150,7 +155,3 @@ Detect 3D
|
|||||||
|
|
||||||
This option makes Godot be aware of when a texture (which is imported for 2D as default) is used in 3D. If this happens, setting are changed so the texture flags
|
This option makes Godot be aware of when a texture (which is imported for 2D as default) is used in 3D. If this happens, setting are changed so the texture flags
|
||||||
are friendlier to 3D (mipmaps, filter and repeat become enabled and compression is changed to VRAM). Texture is also reimported automaticlaly.
|
are friendlier to 3D (mipmaps, filter and repeat become enabled and compression is changed to VRAM). Texture is also reimported automaticlaly.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.. _doc_importing_3d_scenes:
|
.. _doc_importing_3d_scenes:
|
||||||
|
|
||||||
Importing 3D Scenes
|
Importing 3D Scenes
|
||||||
==================
|
===================
|
||||||
|
|
||||||
Godot Scene Importer
|
Godot Scene Importer
|
||||||
--------------------
|
--------------------
|
||||||
@@ -250,7 +250,7 @@ objects in your 3D modelling software. When imported, Godot will detect them and
|
|||||||
actions automatically:
|
actions automatically:
|
||||||
|
|
||||||
Remove nodes (-noimp)
|
Remove nodes (-noimp)
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Node names that have this suffix will be removed at import time, mo
|
Node names that have this suffix will be removed at import time, mo
|
||||||
matter what their type is. They will not appear in the imported scene.
|
matter what their type is. They will not appear in the imported scene.
|
||||||
|
|||||||