Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
skybox [2020/01/27 08:43] – [Creating a skybox at runtime] admin | skybox [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Loading a skybox ====== | ||
- | A skybox is a method of creating backgrounds to make a computer and video games level look bigger than it really is. When a skybox is used, the level is enclosed in a cuboid. The sky, distant mountains, distant buildings, and other unreachable objects are projected onto the cube's faces (using a technique called cube mapping), thus creating the illusion of distant three-dimensional surroundings. A skydome employs the same concept but uses either a sphere or a hemisphere instead of a cube. | ||
- | |||
- | |||
- | Processing of 3D graphics is computationally expensive, especially in real-time games, and poses multiple limits. Levels have to be processed at tremendous speeds, making it difficult to render vast skyscapes in real-time. Additionally, | ||
- | |||
- | |||
- | To compensate for these problems, games often employ skyboxes. Traditionally, | ||
- | |||
- | |||
- | As a viewer moves through a 3D scene, it is common for the skybox to remain stationary with respect to the viewer. This technique gives the skybox the illusion of being very far away, since other objects in the scene appear to move, while the skybox does not. This imitates real life, where distant objects such as clouds, stars and even mountains appear to be stationary when the viewpoint is displaced by relatively small distances. Effectively, | ||
- | |||
- | |||
- | The source of a skybox can be any form of texture, including photographs, | ||
- | |||
- | [source: https:// | ||
- | |||
- | |||
- | ===== Creating a skybox 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, | ||
- | Gorilla.Context.Texturing; | ||
- | |||
- | // in our form (TForm1) we added a field named " | ||
- | // in our form (TForm1) we added a field named " | ||
- | procedure TForm1.FormCreate(Sender: | ||
- | var LBmp : TBitmap; | ||
- | LCMPath : String; | ||
- | begin | ||
- | FGorilla := TGorillaViewport.Create(Self); | ||
- | FGorilla.Parent := Form1; | ||
- | FGorilla.Color | ||
- | | ||
- | FSkyBox := TGorillaSkyBox.Create(FGorilla); | ||
- | FSkyBox.Parent := FGorilla; | ||
- | FSkyBox.Size | ||
- | |||
- | LCMPath := ExtractFilePath(ParamStr(0)) + ' | ||
- | LBmp := TBitmap.CreateFromFile(LCMPath + ' | ||
- | try | ||
- | FSkyBox.Textures[TGorillaCubeMapFace.NegativeZ] := LBmp; | ||
- | LBmp.LoadFromFile(LCMPath + ' | ||
- | FSkyBox.Textures[TGorillaCubeMapFace.PositiveZ] := LBmp; | ||
- | LBmp.LoadFromFile(LCMPath + ' | ||
- | FSkyBox.Textures[TGorillaCubeMapFace.NegativeY] := LBmp; | ||
- | LBmp.LoadFromFile(LCMPath + ' | ||
- | FSkyBox.Textures[TGorillaCubeMapFace.PositiveY] := LBmp; | ||
- | LBmp.LoadFromFile(LCMPath + ' | ||
- | FSkyBox.Textures[TGorillaCubeMapFace.NegativeX] := LBmp; | ||
- | LBmp.LoadFromFile(LCMPath + ' | ||
- | FSkyBox.Textures[TGorillaCubeMapFace.PositiveX] := LBmp; | ||
- | finally | ||
- | FreeAndNil(LBmp); | ||
- | end; | ||
- | end; | ||
- | </ | ||
- | |||
- | Since v0.8.1.2510 skyboxes are rendered as 3D box with a real cubemap texture. | ||
- | (before only by 6 planes with simple 2D textures) | ||
- | |||
- | ===== DesignTime ===== | ||
- | |||
- | Drag and drop the TGorillaSkyBox component onto your viewport and start by uploading | ||
- | the cubemap texture. This is done by loading all 6 faces of a box. | ||
- | |||
- | When downloading a precomputed skybox texture set, you will get 6 textures, which can be associated the following way: | ||
- | |||
- | ^Property^Face^Common TextureName^ | ||
- | |FrontSide|TGorillaCubeMapFace.NegativeZ|negz.jpg| | ||
- | |BackSide|TGorillaCubeMapFace.PositiveZ|posz.jpg| | ||
- | |TopSide|TGorillaCubeMapFace.NegativeY|negy.jpg| | ||
- | |BottomSide|TGorillaCubeMapFace.PositiveY|posy.jpg| | ||
- | |LeftSide|TGorillaCubeMapFace.NegativeX|negx.jpg| | ||
- | |RightSide|TGorillaCubeMapFace.PositiveX|posx.jpg| | ||
- | |||
- | Next step: [[particles|Particles]] |