Browse Source

Reworked some of the graphics manuals

Björn Ritzl 5 years ago
parent
commit
c2f7085ea7

+ 11 - 7
docs/en/en.json

@@ -226,15 +226,15 @@
                 "items": [
                     {
                         "path": "/manuals/importing-assets",
-                        "name": "Importing and editing assets"
+                        "name": "Importing assets"
                     },
                     {
                         "path": "/manuals/importing-graphics",
-                        "name": "Importing and using 2D graphics"
+                        "name": "Importing 2D graphics"
                     },
                     {
                         "path": "/manuals/importing-models",
-                        "name": "Importing and using 3D models"
+                        "name": "Importing 3D models"
                     },
                     {
                         "path": "/manuals/adapting-graphics-to-screen-size",
@@ -256,10 +256,6 @@
                         "path": "/manuals/font",
                         "name": "Font"
                     },
-                    {
-                        "path": "/manuals/graphics",
-                        "name": "Graphics"
-                    },
                     {
                         "path": "/manuals/resource",
                         "name": "Resource management"
@@ -268,6 +264,10 @@
                         "path": "/manuals/tilesource",
                         "name": "Tile source"
                     },
+                    {
+                        "path": "/manuals/texture-filtering",
+                        "name": "Texture filtering"
+                    },
                     {
                         "path": "/manuals/texture-profiles",
                         "name": "Texture profiles"
@@ -436,6 +436,10 @@
                     {
                         "path": "/manuals/shader",
                         "name": "Shader"
+                    },
+                    {
+                        "path": "/manuals/texture-filtering",
+                        "name": "Texture filtering"
                     }
                 ]
             },

+ 5 - 152
docs/en/manuals/graphics.md

@@ -3,156 +3,9 @@ title: Defold graphics manual
 brief: This manual outlines Defold's support for graphical elements.
 ---
 
-# Graphics
+Deprecated manual!
 
-Defold is a full 3D engine, but it is designed and built with strong support for 2D games.
-
-## Image resources
-
-In Defold, there are two types of resources that are used as an image source for visual components:
-
-![atlas](images/icons/atlas.png){.icon} Atlas
-: An atlas contains a list of separate images files, which are automatically combined into a larger texture image. Atlases can contain still images and *Animation Groups*, sets of images that together form a flipbook animation.
-
-  ![atlas](images/graphics/atlas.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about the atlas resource in the [Atlas manual](/manuals/atlas).
-
-![tile source](images/icons/tilesource.png){.icon} Tile Source
-: A tile source references an image file that is already made out to consist of smaller sub-images ordered on a uniform grid. Another term commonly used for this type of compound image is _sprite sheet_. Tile sources can contain flipbook animations, defined by the first and last tile for the animation. It is also possible to use an image to automatically attach collision shapes to tiles.
-
-  ![tile source](images/graphics/tilesource.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about the tile source resource in the [Tile source manual](/manuals/tilesource).
-
-## Visual components
-
-There are several component types that get their image data from atlas or tile source image resources:
-
-![sprite](images/icons/sprite.png){.icon}
-: A sprite is a simple image or flipbook animation that is displayed on screen.
-
-  ![sprite](images/graphics/sprite.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about sprites in the [Sprite manual](/manuals/sprite).
-
-![tile map](images/icons/tilemap.png){.icon} Tile map
-: A tilemap component pieces together a map from tiles (image and collision shapes) that come from a tile source. Tile maps cannot use atlas sources.
-
-  ![tilemap](images/graphics/tilemap.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about tilemaps in the [Tilemap manual](/manuals/tilemap).
-
-![particle effect](images/icons/particlefx.png){.icon} Particle fx
-: Particles that are spawned from a particle emitter consist of a still image or a flipbook animation from an atlas or tile source.
-
-  ![particles](images/graphics/particles.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about particle effects in the [Particle fx manual](/manuals/particlefx).
-
-![gui](images/icons/gui.png){.icon} GUI
-: GUI box nodes and pie nodes can use still images and flipbook animations from atlases and tile sources.
-
-  ![gui](images/graphics/gui.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about GUIs in the [GUI manual](/manuals/gui).
-
-![spine](images/icons/spine-model.png){.icon} Spine model
-: Spine models gets their data from Spine scene resources. Those contain two pieces of data:
-
-  1. A Spine Json file that describes the bone animations.
-  2. An atlas that contain the images that are attached to the bones. Spine models cannot use data from tile maps.
-
-  ![spine](images/graphics/spine.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about Spine models in the [Spine model manual](/manuals/spinemodel).
-
-
-## 3D graphics
-
-Models get its image data directly from an image file that is mapped onto the model according to the model's UV map:
-
-![model](images/icons/model.png){.icon} Model
-: 3D models
-
-  ![model](images/graphics/model.png){srcset="images/graphics/[email protected] 2x"}
-
-Learn more about models in the [Model manual](/manuals/model).
-
-Collada support
-: Defold's 3D support requires you to save or export model, skeleton and animation data in the _Collada_ format. This is a widely adopted format that most 3D modeling software supports. So you should be able to create assets in in _Maya_, _3D Max_, _Blender_, _Sketchup_ or any other popular software and then bring the results into Defold.
-
-  Defold currently only supports baked animations. Animations need to have matrices for each animated bone each keyframe, and not position, rotation and scale as separate keys.
-
-  Animations are also linearly interpolated. If you do more advanced curve interpolation the animations needs to be prebaked from the exporter.
-
-  Animation clips in Collada are not supported. To use multiple animations per model, export them into separate *.dae* files and gather the files into an *.animationset* file in Defold.
-
-Materials, shaders and textures
-: 3D software commonly allows you to set properties on your object vertices, like coloring and texturing. This information goes into the Collada *.dae* file that you export from your 3D software. Depending on the requirements of your game you will have to select and/or create appropriate and _performant_ materials for your objects. A material combines _shader programs_ with a set of parameters for rendering of the object.
-
-  You will also need to design and implement a game camera that works with your intended gameplay.
-
-  There is a simple 3D model material available in the built-in materials folder. If you need to create custom materials for your models, see the [Material documentation](/manuals/material) for information. The [Shader manual](/manuals/shader) contains information on how shader programs work.
-
-Rendering models
-: The default render script is tailor made for 2D games and does not work with 3D models. But by copying the default render script and adding a handful of lines of code to the render script you can enable rendering of your models. For instance:
-
-  ```lua
-
-  function init(self)
-    self.model_pred = render.predicate({"model"})
-    ...
-  end
-
-  function update()
-    ...
-    render.set_depth_mask(true)
-    render.enable_state(render.STATE_DEPTH_TEST)
-    render.set_projection(stretch_projection(-1000, 1000))  -- orthographic
-    render.draw(self.model_pred)
-    render.set_depth_mask(false)
-    ...
-  end
-  ```
-
-  See the [Render documentation](/manuals/render) for details on how render scripts work.
-
-
-## Texture filtering and sampling
-
-You can control the filtering that is done during texture sampling. The filter method governs the visual result in cases when a _texel_ (a pixel in a texture) is not perfectly aligned with a screen pixel. This happens when you move a graphical element that contains the texture less than a pixel. The following filter methods are available:
-
-Nearest
-: The nearest texel will be picked to color the screen pixel. This sampling method should be chosen if you want a perfect one-to-one pixel mapping from your textures to what you see on screen. With nearest filtering everything will snap from pixel to pixel when moving. This may  look twitchy if the Sprite moves slowly.
-
-Linear
-: The texel will be averaged with its neighbors before coloring the screen pixel. This produces smooth appearances for slow, continuous motions as a Sprite will bleed into the pixels before fully coloring them--thus it is possible to move a Sprite less than a whole pixel.
-
-The setting for which filtering to use is stored in the [Project Settings](/manuals/project-settings) file. There are two settings:
-
-default_texture_min_filter
-: Minifying filtering applies whenever the texel is smaller than the screen pixel.
-
-default_texture_mag_filter
-: Magnifying filtering applies whenever the texel is larger than the screen pixel.
-
-Both settings accept the values `linear` or `nearest`. For example:
-
-```ini
-[graphics]
-default_texture_min_filter = nearest
-default_texture_mag_filter = nearest
-```
-
-If you don’t specify anything, both are set to `linear` by default.
-
-Note that the setting in "game.project" is used by in the default samplers. If you specify samplers in a custom material, you can set the filter method on each sampler specifically. See the [Materials manual](/manuals/material/) for details.
-
-## Materials and shaders
-
-The default material and shader files are located under "/builtins/materials/" in your project. The default shaders for sprites, tiles, spine models and models performs a texture lookup through a sampler with filtering set according to the settings in "game.project". The fragment shader also uses a fragment shader constant called `tint` that is multiplied with the texture color.
-
-You can set the `tint` and other shader constant while the game is running with the functions [`sprite.set_constant()`](/ref/sprite#sprite.set_constant) and [`sprite.reset_constant()`](/ref/sprite#sprite.reset_constant). Similar functions exist for other component types than sprites.
-
-The [Materials manual](/manuals/material/) explains how to create custom materials.
+* Read more about [how to import and use 2D graphics here](/manuals/importing-graphics)
+* Read more about [how to import and use 2D graphics here](/manuals/importing-graphics)
+* Read more about [texture filtering](/manuals/texture-filtering)
+* Read more about [materials](/manuals/materiual)

+ 0 - 5
docs/en/manuals/importing-graphics.md

@@ -40,11 +40,6 @@ Learn more about bitmap fonts in the [Fonts manual](/manuals/font/#bitmap-bmfont
   ![BMfont](images/font/bm_font.png){srcset="images/font/[email protected] 2x"}
 
 
- The atlas and tile source assets can in turn be used to create:
-
-* Images can be used to create texture [atlases](/manuals/atlas) and tile sources which in turn can be used by visual components such as [sprites](/manuals/sprite), [tilemaps](/manuals/tilemap) and [particle effects](/manuals/particlefx). Read more about this in the [Graphics manual](/manuals/graphics/#importing-image-files).
-
-
 ## Using Defold assets
 
 When you have converted the images into Atlas and Tile Source files you can use these to create several different kinds of visual components:

+ 16 - 15
docs/en/manuals/importing-models.md

@@ -4,39 +4,44 @@ brief: This manual covers how to import 3D models used by the model component.
 ---
 
 # Importing 3D models
-
-Defold currently only support models in the Collada *.dae* format. You can use tools such as Maya and Blender to create and/or convert 3D models into Collada format. Blender is a powerful and popular 3D modeling, animation and rendering program. It runs on Windows, Mac OS X and Linux and is freely available for download at http://www.blender.org
+Defold currently only support models, skeletons and animations in the Collada *.dae* format. You can use tools such as Maya, 3D Max, Sketchup and Blender to create and/or convert 3D models into Collada format. Blender is a powerful and popular 3D modeling, animation and rendering program. It runs on Windows, Mac OS X and Linux and is freely available for download at http://www.blender.org
 
 ![Model in Blender](images/model/blender.png){srcset="images/model/[email protected] 2x"}
 
 ## Exporting to Collada
-
 When you export a model to Collada format you get a file with the *.dae* file extension. This file contain all the vertices, edges and faces that make up the model, as well as _UV coordinates_ (what part of the texture image maps to a certain part of the mesh) if you have defined them, the bones in the skeleton and animation data.
 
 A detailed description on polygon meshes can be found on http://en.wikipedia.org/wiki/Polygon_mesh. UV coordinates and UV mapping is described at http://en.wikipedia.org/wiki/UV_mapping.
 
+Defold imposes some limnitations on exported animation data:
+
+* Defold currently only supports baked animations. Animations need to have matrices for each animated bone each keyframe, and not position, rotation and scale as separate keys.
+
+* Animations are also linearly interpolated. If you do more advanced curve interpolation the animations needs to be prebaked from the exporter.
+
+* Animation clips in Collada are not supported. To use multiple animations per model, export them into separate *.dae* files and gather the files into an *.animationset* file in Defold.
+
+
+### Requirements
 When you export a model to Collada format you need to make sure that it fulfills the following requirements:
 
 * The model must consist of a single mesh
 * The model must use a single material
 
 
-### Joining multiple meshes
-
+#### Joining multiple meshes
 You can use Blender to join multiple meshes. Select all of the meshes and press `CTRL`/`CMD` + `J` to join them.
 
 ![Join meshes](images/model/blender_join_meshes.png)
 
 
-### Removing materials
-
+#### Removing materials
 You can use Blender to remove extra materials from the model. Select the material to remove and press the `-` button.
 
 ![Remove materials](images/model/blender_remove_materials.png)
 
 
-### Exporting a texture
-
+#### Exporting a texture
 If you do not already have a texture for your model you can use Blender to generate a texture. You should do this before you remove extra materials from the model. Start by selecting the mesh and all of its vertices:
 
 ![Select all](images/model/blender_select_all_vertices.png)
@@ -54,21 +59,17 @@ You can then proceed to export the UV layout to an image that can be used as a t
 ![Export UV layout result](images/model/blender_export_uv_layout_result.png)
 
 
-### Exporting using Blender
-
+## Exporting using Blender
 You export your model into Collada format using the Export menu option. Select the model before you select the Export to Collada menu option and check "Selection Only" to only export the model.
 
 ![Exporting using Blender](images/model/blender_export.png)
 
 
-
 ## Importing to Defold
-
-To import the model, simply drag and drop the *.dae* file and the corresponding texture image into the *Assets pane* somewhere.
+To import the model, simply drag and drop the *.dae* file and the corresponding texture image into the *Assets Pane* somewhere.
 
 ![Imported model assets](images/model/assets.png){srcset="images/model/[email protected] 2x"}
 
 
 ## Using a model
-
 Once you have the model imported into Defold you can use it in a [Model component](/manuals/model).

+ 34 - 1
docs/en/manuals/model.md

@@ -87,9 +87,42 @@ A model also has a number of different properties that can be manipulated using
 `textureN`
 : The model textures where N is 0-7 (`hash`). You can change this using a texture resource property and `go.set()`. Refer to the [API reference for an example](/ref/model/#textureN).
 
-## Material constants
+
+## Material
+
+3D software commonly allows you to set properties on your object vertices, like coloring and texturing. This information goes into the Collada *.dae* file that you export from your 3D software. Depending on the requirements of your game you will have to select and/or create appropriate and _performant_ materials for your objects. A material combines _shader programs_ with a set of parameters for rendering of the object.
+
+There is a simple 3D model material available in the built-in materials folder. If you need to create custom materials for your models, see the [Material documentation](/manuals/material) for information. The [Shader manual](/manuals/shader) contains information on how shader programs work.
+
+
+### Material constants
 
 The default model material has the following constants that can be changed using `model.set_constant()` and reset using `model.reset_constant()` (refer to the [Material manual for more details](/manuals/material/#vertex-and-fragment-constants)):
 
 `tint`
 : The color tint of the model (`vector4`). The vector4 is used to represent the tint with x, y, z, and w corresponding to the red, green, blue and alpha tint. Refer to the [API reference for an example](/ref/model/#model.set_constant:url-constant-value).
+
+
+## Rendering
+
+The default render script is tailor made for 2D games and does not work with 3D models. But by copying the default render script and adding a handful of lines of code to the render script you can enable rendering of your models. For instance:
+
+  ```lua
+
+  function init(self)
+    self.model_pred = render.predicate({"model"})
+    ...
+  end
+
+  function update()
+    ...
+    render.set_depth_mask(true)
+    render.enable_state(render.STATE_DEPTH_TEST)
+    render.set_projection(stretch_projection(-1000, 1000))  -- orthographic
+    render.draw(self.model_pred)
+    render.set_depth_mask(false)
+    ...
+  end
+  ```
+
+See the [Render documentation](/manuals/render) for details on how render scripts work.

+ 34 - 0
docs/en/manuals/texture-filtering.md

@@ -0,0 +1,34 @@
+---
+title: Texture filtering
+brief: This manual describes the available options for texture filtering when rendering graphics.
+---
+
+# Texture filtering and sampling
+
+Texture filtering decides the visual result in cases when a _texel_ (a pixel in a texture) is not perfectly aligned with a screen pixel. This happens when you move a graphical element that contains the texture less than a pixel. The following filter methods are available:
+
+Nearest
+: The nearest texel will be picked to color the screen pixel. This sampling method should be chosen if you want a perfect one-to-one pixel mapping from your textures to what you see on screen. With nearest filtering everything will snap from pixel to pixel when moving. This may  look twitchy if the Sprite moves slowly.
+
+Linear
+: The texel will be averaged with its neighbors before coloring the screen pixel. This produces smooth appearances for slow, continuous motions as a Sprite will bleed into the pixels before fully coloring them--thus it is possible to move a Sprite less than a whole pixel.
+
+The setting for which filtering to use is stored in the [Project Settings](/manuals/project-settings/#graphics) file. There are two settings:
+
+default_texture_min_filter
+: Minifying filtering applies whenever the texel is smaller than the screen pixel.
+
+default_texture_mag_filter
+: Magnifying filtering applies whenever the texel is larger than the screen pixel.
+
+Both settings accept the values `linear` or `nearest`. For example:
+
+```ini
+[graphics]
+default_texture_min_filter = nearest
+default_texture_mag_filter = nearest
+```
+
+If you don’t specify anything, both are set to `linear` by default.
+
+Note that the setting in "game.project" is used by in the default samplers. If you specify samplers in a custom material, you can set the filter method on each sampler specifically. See the [Materials manual](/manuals/material/) for details.