Skip to content

EntityLighting

Narta Xaymar Dirks edited this page Oct 31, 2026 · 1 revision

EntityLighting

EntityLighting:Void entity:Int32, mode:Int32
Parameter Mode Type Default Description
entity In Int32 required The entity (a mesh, a sprite, ...) to change.
mode In Int32 required 0 for lighting of the vertices as the original does it (the default), 1 for lighting of every pixel.

Description

A BlitzLLVM extension: lights the pixels of an entity instead of its vertices. The original (and Direct3D 7) lights the vertices of a mesh and blends the result across each triangle, so a highlight or the edge of a spot light is only as fine as the mesh, and a point light that falls between the vertices of a big floor or wall is missing or wrong. With mode 1, the same lighting is worked out for every pixel of a triangle from the interpolated position and normal: ambient light, directional, point and spot lights (with the same eight lights, the same range, attenuation and cone as before), shininess, EntityFX full bright, and vertex colors, EntityColor and EntityAlpha all work as they do per vertex. The result is then multiplied with the texture, blended by TextureBlend and fogged exactly as before, so nothing but the smoothness of the lighting changes: where the mesh is fine enough the picture is the same, and where it is not, the lighting is the correct one instead of an approximation.

It is mode 0 (vertices) by default, because the original lights vertices and programs are meant to look as they did there. Entities with the flat shading effect of EntityFX (4) keep the lighting of their first vertex for the whole triangle, as flat shading means that. The cost is the lighting work for every pixel instead of every vertex, so it is slower in scenes with many lights and few, large triangles being lit by a lot of pixels; the mode belongs to each entity and can be changed at any time, so only the entities that need smooth lighting pay for it. The environment variable BLITZLLVM_ENTITY_LIGHTING=1 gives entities that were not given a mode the pixel mode.

Differences

  • Not in the original: lighting is always per vertex there.

Related Commands

EntityAlpha, EntityAutoFade, EntityBlend, EntityClass, EntityColor, EntityDepthFade 〔BlitzLLVM〕, EntityDistance, EntityFX

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally