Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
viewport [2020/05/25 13:46] – [Rendering-Pipeline] adminviewport [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== Viewport ====== 
  
-The 2D/3D Firemonkey components (TButton, TLabel, ...) are still compatible with Gorilla3D. 
-But instead of using a TViewport3D or TForm3D, we need to drag at first the TGorillaViewport onto our form. 
-===== Creating a Gorilla3D Viewport at design-time ===== 
- 
-You can find the viewport at designtime in the toolbar under:  
- 
- 
-Gorilla3D > TGorillaViewport. 
- 
- 
-Simply drag it onto your form or create it at runtime by the following method.  
- 
-**__CAUTION:__ Gorilla3D is not compatible with TForm3D and TViewport3D!** 
- 
- 
-===== Creating a viewport at runtime ===== 
- 
-If you need to create the Gorilla3D viewport at runtime, you can do it the following way:  
- 
- 
-<file pascal Form1.pas> 
-uses 
-  FMX.UITypes, 
-  Gorilla.Viewport; 
- 
-// in our form (TForm1) we added a field named "FGorilla" 
-procedure TForm1.FormCreate(Sender: TObject); 
-begin 
-  FGorilla := TGorillaViewport.Create(Self); 
-  FGorilla.Parent := Form1; 
-  FGorilla.Color  := TAlphaColorRec.Black; 
-end; 
-</file> 
- 
-===== Rendering-Pipeline ===== 
- 
-Since v0.8.1.x we've changed the default rendering pipeline of the TGorillaViewport. 
-The pipeline is responsible for rendering all render passes and the main scene itself. 
-It computes transparency by using Weighted-Blended-Order-Independent-Transparency (WBOIT) rendering mechanism. 
- 
-Read more: [[transparency|Transparency]] 
- 
-**Render-Cycle:** 
-  - all pre-processing passes represented by instances of TGorillaRenderPassController 
-  - main render pass 
-  - all post-processing passes represented by instances of TGorillaRenderPassController 
- 
-**Render-Pass** 
-  - all opaque objects (not transparent) 
-  - all transparent objects (rendered into separated buffers) 
-  - compositing opaque and transparent render result 
- 
-===== Frame-Rate ===== 
-==== Requesting FrameRate (FPS) ==== 
- 
-Currently it is not possible to retrieve an actual framerate, but the TGorillaViewport provides an estimated framerate value. 
- 
-Simply setup a timer and request those value every 100 milliseconds. 
- 
-<file pascal> 
-procedure TForm1.Timer1Timer(Sender: TObject); 
-begin 
-  Self.Caption := Format('Gorilla 3D - %n FPS', [FGorilla.FPS]); 
-end; 
-</file> 
- 
-=== Notice === 
-The estimated framerate measures the time a complete render cycle needs, including all objects, render passes and the main pass itself. 
-Based on this value we compute the **possible frames per second** for the last interval. So Gorilla3D FPS value is only an orientation for you and the possible performance of your application. 
- 
-Animation-Framerate (TAnimation): Because skin- and skeleton animation extends basic Firemonkey TAnimation. Therefore animations are limited to 30 FPS for rendering. 
-==== UseFixedFrameRate ==== 
- 
-===== FrustumCulling ===== 
- 
-===== HighRes ===== 
- 
-The High-Resolution property is currently only useful on Android platform. 
-When activating higher resolution, than context size for rendering will be increased by device display scaling factor. 
- 
-Otherwise the size of the viewport will be used for rendering. 
-Deactivated HighRes property could lead to a more rastarized result, but is faster in rendering. 
-===== Fog ===== 
- 
-The viewport provides a classic render effect as basis implementation. Fog computation is a very popular element larger scenes when hiding elements in far distance, and making a scene disappear. 
- 
-^Property^Value^Description^ 
-|Fog | True/False | Enable or disable fog computation| 
-|FogMode |TGorillaFogMode  |Get or set fog computation mode. Allowed modes are: linear, exp and exp2. | 
-|FogDensity |Single  |Get or set density of computed fog. | 
-|FogStart |Single |Get or set lower limit of fog by distance. | 
-|FogEnd |Single | Get or set upper limit of fog by distance.| 
-|FogColor |TAlphaColorF | Get or set fog color.| 
- 
-Fog computation is a global scene effect over each visible element of the scene. 
-Due to necessary shader operations this is only allowed for derived types of TGorillaDefaultMaterialSource.  
- 
-**This means the fog effect will not work for default FMX materials.** 
-===== Optimization ===== 
- 
-In Firemonkey every time you change a visual property of a component, for example the position of a TCube, FMX will throw an event to update the viewport. 
- 
-<file pascal> 
-Cube1.Position.X := Cube1.Position.X + 0.1; 
-Cube1.Position.Y := Cube1.Position.Y + 0.2; 
-Cube1.Position.Z := Cube1.Position.Z + 0.3; 
-</file> 
- 
-As you can imagine this is very slow, especially when you did not expected an update on changing the x, y and z value of a position. 
- 
-Therefor the TGorillaViewport provides an optimization mechanism. 
-Encapsulate those operations into BeginUpdate and EndUpdate to perform only one update command on the viewport renderer. 
- 
-<file pascal> 
-  FGorilla.BeginUpdate(); 
-  try 
-    Cube1.Position.X := Cube1.Position.X + 0.1; 
-    Cube1.Position.Y := Cube1.Position.Y + 0.2; 
-    Cube1.Position.Z := Cube1.Position.Z + 0.3;   
-  finally 
-    FGorilla.EndUpdate(); 
-  end; 
-</file> 
- 
-In case you need explicit render instructions, you can suppress updates completely, by calling //EndUpdateWithoutInvalidate// instead of //EndUpdate//. 
- 
-<file pascal> 
-  FGorilla.BeginUpdate(); 
-  try 
-    Cube1.Position.X := Cube1.Position.X + 0.1; 
-    Cube1.Position.Y := Cube1.Position.Y + 0.2; 
-    Cube1.Position.Z := Cube1.Position.Z + 0.3;   
-  finally 
-    FGorilla.EndUpdateWithoutInvalidate(); 
-  end; 
-</file> 
- 
-But you have to update viewport yourself by calling: 
- 
-<file pascal> 
-  FGorilla.Invalidate(); 
-</file> 
-==== Shaders ==== 
- 
-Since v0.8.0 rendering pipeline was optimized due to unnecessary render instructions. An update limitation was implemented, that not every property change leads to a new rendering. 
-Besides that you may use a shader / material which updates itself by time. The TGorillaWaterMaterialSource is an example. Waves are generated by a timevalue, but it will only update on re-rendering. 
- 
-Here we need an explicit render instruction. 
-Like you may already know from other Delphi components the TGorillaViewport supports the "Invalidate" method to tell Gorilla3D to re-render. 
-Call this method constantly in a TTimer or by synchronized thread to update water material. 
- 
-Next step: [[models|Loading models]]