Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
textures [2020/01/12 21:12] – [Textures] admin | textures [2020/05/25 12:32] – [Example] admin | ||
---|---|---|---|
Line 13: | Line 13: | ||
===== Supported Formats ===== | ===== Supported Formats ===== | ||
+ | A texture format is described by a components internal format and a general format. While the components define the exact datatypes of byte data, the general format is more a simple setup information. | ||
+ | ==== Components / InternalFormat ==== | ||
+ | ^Format^Description^ | ||
+ | |TPixelFormatEx.RGBA|| | ||
+ | |TPixelFormatEx.RGBA16F|| | ||
+ | |TPixelFormatEx.RGBA32F|| | ||
+ | |TPixelFormatEx.RGB|| | ||
+ | |TPixelFormatEx.RGB16F|| | ||
+ | |TPixelFormatEx.RGB32F|| | ||
+ | |TPixelFormatEx.RG|| | ||
+ | |TPixelFormatEx.RG16F|| | ||
+ | |TPixelFormatEx.RG32F|| | ||
+ | |TPixelFormatEx.R|| | ||
+ | |TPixelFormatEx.R16F|| | ||
+ | |TPixelFormatEx.R32F|| | ||
+ | |TPixelFormatEx.Depth|| | ||
+ | |TPixelFormatEx.Depth16|| | ||
+ | |TPixelFormatEx.Depth24|| | ||
+ | |TPixelFormatEx.Depth32|| | ||
+ | |...|| | ||
+ | |||
+ | ==== Format ==== | ||
+ | ^^^ | ||
+ | |TPixelFormatEx.RGBA|| | ||
+ | |TPixelFormatEx.RGB|| | ||
+ | |TPixelFormatEx.RG|| | ||
+ | |TPixelFormatEx.R|| | ||
+ | |TPixelFormatEx.Depth|| | ||
+ | |...|| | ||
===== Min-/Mag Filter ===== | ===== Min-/Mag Filter ===== | ||
+ | ^Filter^Description^ | ||
+ | |TTextureFilter.Linear|| | ||
+ | |TTextureFilter.Nearest|| | ||
===== Wrapping ===== | ===== Wrapping ===== | ||
+ | ^Kind^^ | ||
+ | |TGorillaTextureWrap.ClampToBorder|| | ||
+ | |TGorillaTextureWrap.ClampToEdge|| | ||
+ | |TGorillaTextureWrap.Clamp|| | ||
+ | |TGorillaTextureWrap.Repeated|| | ||
+ | |TGorillaTextureWrap.MirrorRepeated|| | ||
+ | |||
+ | ===== Setting up ===== | ||
+ | |||
+ | To set up a Gorilla3D texture correctly, you need to encapsulate property configuration inside of BeginSetup and EndSetup method. | ||
+ | Only then all settings will correctly be submitted to OpenGL. | ||
+ | ===== Example ===== | ||
+ | |||
+ | At first a simple example where a TGorillaTextureBitmap is created with a size of 1024 x 1024 pixels and will all necessary settings. | ||
<file pascal> | <file pascal> | ||
Line 34: | Line 80: | ||
finally | finally | ||
LTexture.EndSetup(); | LTexture.EndSetup(); | ||
+ | end; | ||
+ | </ | ||
+ | |||
+ | Secondly a common example to ignore linear interpolation of a material texture. This becomes very useful, when displaying textures in pixelart, like minecraft. | ||
+ | |||
+ | We have to disable interpolation and mipmapping. | ||
+ | |||
+ | <file pascal> | ||
+ | var LTexture : TGorillaTextureBitmap; | ||
+ | begin | ||
+ | // request the texture and convert to Gorilla3D texture bitmap. | ||
+ | LTexture := GorillaLambertMaterialSource1.Texture as TGorillaTextureBitmap; | ||
+ | | ||
+ | // start manipulating properties and update them in GPU. | ||
+ | LTexture.BeginSetup(); | ||
+ | try | ||
+ | LTexture.MinFilter := TTextureFilter.Nearest; | ||
+ | LTexture.MagFilter := TTextureFilter.Nearest; | ||
+ | LTexture.Style := LTexture.Style - [TTextureStyle.MipMaps]; | ||
+ | finally | ||
+ | LTexture.EndSetup(); | ||
+ | end; | ||
+ | | ||
+ | // re-assign texture to update for shader | ||
+ | GorillaLambertMaterialSource1.Texture := LTexture; | ||
end; | end; | ||
</ | </ |