Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
viewport [2020/05/25 13:56] – [FrustumCulling] admin | viewport [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: | ||
- | |||
- | |||
- | ===== 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 " | ||
- | procedure TForm1.FormCreate(Sender: | ||
- | begin | ||
- | FGorilla := TGorillaViewport.Create(Self); | ||
- | FGorilla.Parent := Form1; | ||
- | FGorilla.Color | ||
- | end; | ||
- | </ | ||
- | |||
- | ===== 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]] | ||
- | |||
- | ==== Rendering-Order ==== | ||
- | |||
- | **Render-Cycle** | ||
- | |||
- | A render-cycle is the process of rendering everything needed for a frame. | ||
- | |||
- | - all pre-processing render passes (represented by instances of TGorillaRenderPassController | ||
- | - main render pass | ||
- | - all post-processing render passes (represented by instances of TGorillaRenderPassController) | ||
- | |||
- | **Render-Pass** | ||
- | |||
- | A render pass is a closed unit for rendering specific elements or some kind of effect, inside of a step of the render-cycle. | ||
- | |||
- | - 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: | ||
- | begin | ||
- | Self.Caption := Format(' | ||
- | end; | ||
- | </ | ||
- | |||
- | === 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): | ||
- | ==== UseFixedFrameRate ==== | ||
- | |||
- | ===== FrustumCulling ===== | ||
- | |||
- | The viewing frustum is a geometric representation of the volume visible to the virtual camera. Naturally, objects outside this volume will not be visible in the final image, so they are discarded. | ||
- | |||
- | [[https:// | ||
- | |||
- | This is a great boost to the performance of your application, | ||
- | The FrustumCulling property enables or disables the functionality in general. | ||
- | |||
- | But you can activate/ | ||
- | <file pascal> | ||
- | GorillaCube1.FrustumCullingCheck := false; | ||
- | </ | ||
- | |||
- | If FrustumCullingCheck is set to FALSE, it will always be rendered, wether it's inside or outside of the view frustum. | ||
- | ===== 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 | ||
- | |FogDensity |Single | ||
- | |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; | ||
- | </ | ||
- | |||
- | 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; | ||
- | </ | ||
- | |||
- | In case you need explicit render instructions, | ||
- | |||
- | <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; | ||
- | </ | ||
- | |||
- | But you have to update viewport yourself by calling: | ||
- | |||
- | <file pascal> | ||
- | FGorilla.Invalidate(); | ||
- | </ | ||
- | ==== Shaders ==== | ||
- | |||
- | Since v0.8.0 rendering pipeline was optimized due to unnecessary render instructions. An update limitation was implemented, | ||
- | 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 " | ||
- | Call this method constantly in a TTimer or by synchronized thread to update water material. | ||
- | |||
- | Next step: [[models|Loading models]] |