Skip to content

SpriteDepthFade

Narta Xaymar Dirks edited this page Oct 29, 2026 · 3 revisions
BlitzLLVM

SpriteDepthFade 〔BlitzLLVM〕

SpriteDepthFade:Void sprite:Int32, fade_distance:Float32
Parameter Mode Type Default Description
sprite In Int32 required The sprite.
fade_distance In Float32 required How far in front of a solid surface (world units) the sprite is faded out. 0 or less turns the effect off.

Description

〔BlitzLLVM〕 This command does not exist in the original Blitz products. BlitzLLVM adds it.

Fades a sprite out where it gets close to something solid behind it, which is what makes smoke, fire and fog made of sprites (soft particles) blend into the scene instead of cutting a hard line where they poke into a wall or the ground. The sprite is faded by the distance in front of the solid surface: at that distance or more it is as it would be without the command, and where it touches the surface it is gone. The distance is in world units (the same as PositionEntity), so a sprite 10 units across with a distance of 2 fades over the last 2 units next to the surface.

EntityDepthFade does the same for meshes and other entities that are not sprites.

A distance close to 0 (or less) turns the effect off, which is the default, and sprites without it cost nothing extra. The effect needs the sprite to be see-through: it works with EntityAlpha and the alpha of the texture (EntityBlend 1), and with EntityBlend 3 (add). It does nothing for sprites that are solid or masked, and with EntityBlend 2 (multiply), which does not look at alpha. Only what was drawn before the see-through things is taken into account: solid meshes, terrain, planes and solid sprites (a sprite without alpha or blending) fade the sprite, but see-through sprites and meshes do not, other sprites with a depth fade included. It works for perspective and orthographic cameras.

Differences

  • The original has no such command. This is an extension; programs that use it do not compile with the original Blitz3D.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
CameraClsColor camera, 40, 60, 90
PositionEntity camera, 0, 3, -5
RotateEntity camera, 20, 0, 0
light = CreateLight()
RotateEntity light, 45, 30, 0
floor = CreatePlane()
EntityColor floor, 90, 120, 80

; Two big smoke sprites standing in the ground: the left one with a hard edge, the right one with a depth fade.
For side = 0 To 1
	tex = CreateTexture(64, 64, 3)
	SetBuffer TextureBuffer(tex)
	ClsColor 230, 230, 230
	Cls
	SetBuffer BackBuffer()
	sprite = CreateSprite()
	EntityTexture sprite, tex
	EntityAlpha sprite, 0.8
	ScaleSprite sprite, 2.2, 2.2
	PositionEntity sprite, -2.6 + side * 5.2, 0.3, 2
	If side = 1 Then SpriteDepthFade sprite, 2
Next
RenderWorld
Flip
WaitKey

Related Commands

CreateSprite, HandleSprite, LoadSprite, RotateSprite, ScaleSprite, SpriteViewMode

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally