Blitz3D+ Command Reference

TextureAnisotropy [samples]

Parameters

samples (optional) - filtering level: 1, 2, 4, 8 (default), or 16; other values round down to the nearest supported level

Description

Sharpens textures seen at shallow angles, such as floors and roads.

Mipmapped textures go blurry when viewed nearly edge-on - the classic smeared road markings and mushy distant floor tiles. Anisotropic filtering takes extra samples along the squashed direction and keeps them crisp, which matters most on the ground, terrain and long walls your camera looks across.

The default of 8x is a good quality/performance balance on modern hardware; 16x is the maximum, and 1 turns the feature off, leaving plain trilinear filtering. The setting applies to texture sampling scene-wide.

For the full story, see the image-quality guide.

Requires Extended mode.

See also: AntiAliasMode, RenderScale, LoadTexture.

Example

; TextureAnisotropy Example
; -------------------------
; Requires Extended mode.

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

; A low camera looking down a long floor - the steep viewing angle
; is exactly where anisotropic filtering helps
camera=CreateCamera()
PositionEntity camera,0,1.2,-4
RotateEntity camera,8,0,0

light=CreateLight()
RotateEntity light,45,45,0

; Long textured runway; distant tiles blur without anisotropy
floor=CreateCube()
ScaleEntity floor,6,0.1,80
PositionEntity floor,0,-0.1,70

tex=LoadTexture("../3d_examples/media/MossyGround.BMP")
EntityTexture floor,tex
; Tile the texture many times along the runway
ScaleTexture tex,0.05,0.05

; Marker cones give a sense of distance
For i=0 To 9
    marker=CreateCone()
    ScaleEntity marker,0.4,0.8,0.4
    PositionEntity marker,-2.5+5*(i Mod 2),0.8,5+i*9
    EntityColor marker,255,120+i*13,40
Next

samples=8

While Not KeyDown(1)

    ; Keys 1-5 select the filtering level
    If KeyHit(2) Then samples=1
    If KeyHit(3) Then samples=2
    If KeyHit(4) Then samples=4
    If KeyHit(5) Then samples=8
    If KeyHit(6) Then samples=16

    ; Sharpen textures viewed at an angle
    TextureAnisotropy samples

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"1-5: anisotropy 1/2/4/8/16   Arrow keys: move camera   Esc: exit"
    Text 0,20,"TextureAnisotropy "+samples
    Text 0,40,"Watch the distant floor: 1x is muddy, 16x stays crisp"

    Flip

Wend

End

Index