diff --git a/en/manual/graphics/materials/shading-attributes.md b/en/manual/graphics/materials/shading-attributes.md index 7f2c21330..8ccabffa6 100644 --- a/en/manual/graphics/materials/shading-attributes.md +++ b/en/manual/graphics/materials/shading-attributes.md @@ -20,7 +20,6 @@ The **diffuse** is the basic color of the material. A pure diffuse material is c The final diffuse contribution is calculated like this: - the **diffuse** defines the color used by the diffuse model - - the **diffuse model** defines which shading model is used for rendering the diffuse component (see below) Currently, the diffuse attribute supports only a **diffuse map**. @@ -42,7 +41,7 @@ Under the Lambert model, light is reflected equally in all directions with an in | Property | Description | ------------- | ----------- -| Diffuse map | The diffuse map color provider +| Diffuse map | The diffuse map color provider | Diffuse model | The shading model for diffuse lighting ## Specular @@ -62,10 +61,8 @@ By taking into into account the fact that almost all materials always have some The final specular color is calculated by mixing a fixed low-reflection color and the diffuse color. - With the metalness color at `0.0`, the effective specular color is equal to `0.02`, while the diffuse color is unchanged. The material is not metal but exhibits some reflectance and is sensitive to the Fresnel effect. - - With the metalness color at `1.0`, the effective specular color is equal to the diffuse color, and the diffuse color is set to `0`. The material is considered a pure metal. - - ![media/material-attributes-26.png](media/material-attributes-26.png) + ![media/material-attributes-26.png](media/material-attributes-26.png) The screenshots below show the result of the metalness factor on a material with the following attributes: @@ -100,15 +97,9 @@ The microfacet is defined by the following formula, where Rs is the resulting sp | Property | Description | ------------------- | ------- -| Fresnel | Defines the amount of light that is reflected and transmitted. The models supported are:

**Schlick**: An approximation of the Fresnel effect (default)

**Thin glass**: A simulation of light passing through glass

**None**: The material as-is with no Fresnel effect
-| Visibility | Defines the visibility between of the microfacets between (0, 1). Also known as the geometry attenuation - Shadowing and Masking - in the original Cook-Torrance. Stride simplifies the formula to use the visibility term instead:

![media/material-attributes-35.png](media/material-attributes-35.png)

and

![media/material-attributes-36.png](media/material-attributes-36.png)

**Schlick GGX** (default)

**Implicit**: The microsurface is always visible and generates no shadowing or masking

**Cook-Torrance**

**Kelemen**

**Neumann**

**Smith-Beckmann**

**Smith-GGX correlated**

**Schlick-Beckmann**
-| Normal Distribution |

Defines how the normal is distributed. The gloss attribute is used by this part of the function to modify the distribution of the normal.

**GGX** (default)

**Beckmann**

**Blinn-Phong**
-| Fresnel | Defines the amount of light that is reflected and transmitted. The models supported are:

**Schlick**: An approximation of the Fresnel effect (default)

**Thin glass**: A simulation of light passing through glass

**None**: The material as-is with no Fresnel effect
-| Visibility | Defines the visibility between of the microfacets between (0, 1). Also known as the geometry attenuation - Shadowing and Masking - in the original Cook-Torrance. Stride simplifies the formula to use the visibility term instead:

![media/material-attributes-35.png](media/material-attributes-35.png)

and

![media/material-attributes-36.png](media/material-attributes-36.png)

**Schlick GGX** (default)

**Implicit**: The microsurface is always visible and generates no shadowing or masking

**Cook-Torrance**

**Kelemen**

**Neumann**

**Smith-Beckmann**

**Smith-GGX correlated**

**Schlick-Beckmann**
-| Normal Distribution |

Defines how the normal is distributed. The gloss attribute is used by this part of the function to modify the distribution of the normal.

**GGX** (default)

**Beckmann**

**Blinn-Phong**
-| Fresnel | Defines the amount of light that is reflected and transmitted. The models supported are:


**Schlick**: An approximation of the Fresnel effect (default)



**Thin glass**: A simulation of light passing through glass



**None**: The material as-is with no Fresnel effect


-| Visibility | Defines the visibility between of the microfacets between (0, 1). Also known as the geometry attenuation - Shadowing and Masking - in the original Cook-Torrance. Stride simplifies the formula to use the visibility term instead:


![media/material-attributes-35.png](media/material-attributes-35.png)



and


![media/material-attributes-36.png](media/material-attributes-36.png)



**Schlick GGX** (default)



**Implicit**: The microsurface is always visible and generates no shadowing or masking



**Cook-Torrance**



**Kelemen**



**Neumann**



**Smith-Beckmann**



**Smith-GGX correlated**



**Schlick-Beckmann**


-| Normal Distribution |


Defines how the normal is distributed. The gloss attribute is used by this part of the function to modify the distribution of the normal.



**GGX** (default)



**Beckmann**



**Blinn-Phong**


+| Fresnel | Defines the amount of light that is reflected and transmitted. The models supported are:
**Schlick**: An approximation of the Fresnel effect (default)
**Thin glass**: A simulation of light passing through glass
**None**: The material as-is with no Fresnel effect +| Visibility | Defines the visibility between of the microfacets between (0, 1). Also known as the geometry attenuation - Shadowing and Masking - in the original Cook-Torrance. Stride simplifies the formula to use the visibility term instead:
![media/material-attributes-35.png](media/material-attributes-35.png)
and
![media/material-attributes-36.png](media/material-attributes-36.png)
**Schlick GGX** (default)
**Implicit**: The microsurface is always visible and generates no shadowing or masking
**Cook-Torrance**
**Kelemen**
**Neumann**
**Smith-Beckmann**
**Smith-GGX correlated**
**Schlick-Beckmann** +| Normal Distribution | Defines how the normal is distributed. The gloss attribute is used by this part of the function to modify the distribution of the normal.
**GGX** (default)
**Beckmann**
**Blinn-Phong** ## Emissive diff --git a/en/manual/index.md b/en/manual/index.md index 9e061ab13..d36518300 100644 --- a/en/manual/index.md +++ b/en/manual/index.md @@ -10,8 +10,10 @@ These pages contain information about how to use Stride, an open-source C# game ## Latest documentation ### Recent updates -- New [Scripts - Gizmos](scripts/gizmos.md) - Description and example of the Flexible Processing system -- New [ECS - Flexible Processing](engine/entity-component-system/flexible-processing.md) - Description and example of the Flexible Processing system + +- Updated [Scripts - Types of script](scripts/types-of-script.md) - Asynchronous script example improved +- New [Scripts - Gizmos](scripts/gizmos.md) - Description and example of the Flexible Processing system +- New [ECS - Flexible Processing](engine/entity-component-system/flexible-processing.md) - Description and example of the Flexible Processing system - Updated [Linux - Setup and requirements](platforms/linux/setup-and-requirements.md) - Fedora OS option added - New [Scripts - Serialization](scripts/serialization.md) - Explanation of serialization - Updated [Scripts - Public properties and fields](scripts/public-properties-and-fields.md) - Content improvements and additions diff --git a/en/manual/scripts/types-of-script.md b/en/manual/scripts/types-of-script.md index c40162fd7..1efae7183 100644 --- a/en/manual/scripts/types-of-script.md +++ b/en/manual/scripts/types-of-script.md @@ -16,10 +16,10 @@ Example: ```cs public class StartUpScriptExample : StartupScript { - public override void Start() - { - // Do some stuff during initialization - } + public override void Start() + { + // Do some stuff during initialization + } } ``` @@ -36,10 +36,10 @@ The following script performs updates every frame, no matter what: ```cs public class SampleSyncScript : SyncScript { - public override void Update() - { - // Performs the update on the entity — this code is executed every frame - } + public override void Update() + { + // Performs the update on the entity — this code is executed every frame + } } ``` @@ -48,7 +48,6 @@ public class SampleSyncScript : SyncScript Asynchronous scripts are initialized only once, then canceled when removed from the scene. * Asynchronous code goes in the [Execute](xref:Stride.Engine.AsyncScript.Execute) function. - * Code performing the cancellation goes in the [Cancel](xref:Stride.Engine.ScriptComponent.Cancel) method. The following script performs actions that depend on events and triggers: @@ -56,22 +55,38 @@ The following script performs actions that depend on events and triggers: ```cs public class SampleAsyncScript : AsyncScript { - public override async Task Execute() - { - // The initialization code should come here, if necessary - - while (Game.IsRunning) // loop until the game ends (optional depending on the script) - { - await MyEvent; - - // Do some stuff - - await Script.NextFrame(); // wait for the next frame (optional depending on the script) - } - } + public override async Task Execute() + { + // The initialization code should come here, if necessary + // This method starts running on the main thread + + while (Game.IsRunning) // loop until the game ends (optionalpendingon the script) + { + // We're still on the main thread + + // Task.Run will pause the execution of this method until the task is completed, + // while that's going on, the game will continue running, it will display new frames and process inputs appropriately + var lobbies = await Task.Run(() => GetMultiplayerLobbies()); + + // After awaiting a task, the thread the method runs on will have changed, + // this method now runs on a thread pool thread instead of the main thread + // You can manipulate the data returned by the task here if needed + // But if you want to interact with the engine safely, you have to make sure the method runs on the main thread + + // await Script.NextFrame() yields execution of this method to the main thread, + // meaning that this method is paused, and once the main thread processes the next frame, + // it will pick that method up and run it + await Script.NextFrame(); + // So after this call, this method is back on the main thread + + // You can now safely interact with the engine's systems by displaying the lobbies retrieved above in a UI for example + } + } } ``` +Check out an example from our [Async scripts tutorial](../../tutorials/csharpintermediate/async-scripts.md). + ## See also * [Create a script](create-a-script.md) @@ -80,4 +95,4 @@ public class SampleAsyncScript : AsyncScript * [Scheduling and priorities](scheduling-and-priorities.md) * [Events](events.md) * [Debugging](debugging.md) -* [Preprocessor variables](preprocessor-variables.md) \ No newline at end of file +* [Preprocessor variables](preprocessor-variables.md)