How the original decides how an actor, surface or HUD element is blended: the ERenderStyle numbering, the PolyFlags words that come out of it, the palette index 0 rule for masked textures, Fatness, bMeshEnviroMap, and zone fog on surfaces and on actor vertices. Core owns every decision here; the frontend only sets up the blend state it is told to.
ERenderStyleis 0 None, 1 Normal, 2 Masked, 3 Translucent, 4 Modulated. Render.dll's sprite path turns styles 2, 3, 4 intoPF_Unlit|PF_Masked(0x400002),PF_Unlit|PF_Translucent(0x400004),PF_Unlit|PF_Modulated(0x400040). This is also the evidence that the Texture class bools are numbered by declaration order within one flag word:bMasked0x2,bTransparent0x4,bModulate0x40,bUnlit0x400000. The offset 0x80 of a Texture holds exactly 32 bools frombInvisible(0x1) tobX7(0x80000000), andexecTraceTexturereads it (Engine.dll 0x1037ad2c) and ORs it with the surface flags. Port:HP1.Core/Runtime/World/UETextureFacts.cs, which checks the layout at startup and fails loudly if it ever shifts.- Meshes:
FUN_10b338f0(Render.dll) builds the actor's polygon flags. Style 3 gives PF_Translucent (4).Opacity < 1.0adds0x10000004(also for NaN, since the compare leaves C0 set when unordered).bNoSmooth(Actor+0x198 bit 0x2) adds PF_NoSmooth (0x800) on sprites and meshes (not on particles).bMeshEnviroMapadds PF_Environment on all triangles. PF_Unlit comes frombUnlit(+0x198 bit 1), orRegion.ZoneNumber == 0, or the viewport not being in lit mode (RendMap != 5, or UClient.NoLighting). Port:HP1.Core/Runtime/Render/MeshTriangleOrder.cs(ActorPolyFlags),HP1.Core/Runtime/Render/UEActorLighting.cs(UnlitFlag). - Unlit colour (GUnlitColor in
DrawMesh/DrawLodMesh): a grey ofclamp(ScaleGlow * 0.5 + AmbientGlow / 256, 0, 1); no zone ambient is added. - Frame pass: surfaces and sprites with
(PolyFlags | Texture.PolyFlags) & 0x47(Invisible, Masked, Translucent, Modulated) go to the second pass; seesprites-and-draw-order.md. Movers are brushes in the surface passes. - HUD canvas:
execDrawTile/execDrawTileClipped(Engine.dll 0x1038971d, 0x1038a0b7) map Canvas Style 3 to PF_Translucent and Style 4 to PF_Modulated; every other style, including Masked, gives 0, then PF_TwoSided is always added andbNoSmoothadds PF_NoSmooth. The mask comes only from the texture's own flag (Texture->PolyFlags & PF_Masked, 0x1038781f). Text (WrappedPrint0x10387d54,execDrawTextClipped0x1038a3f1) uses a different table: None gives PF_Invisible, 3 gives 4, 4 gives 0x40, and0x1000802(Masked | NoSmooth | 0x01000000) is always added. Port:HP1.Core/Runtime/VM/UEWorldFrameProducer.Canvas.cs(tiles),HP1.Core/Runtime/VM/UEWorldFrameProducer.Text.cs(text). - Decals: Style 4 gives
0x40000040, 3 gives PF_Translucent, others 0 (DrawDecals). For a modulated decal D3DDrv'sDrawTrianglesignores the light (vertex colour 0xFFFFFFFF); the blend is DESTCOLOR/SRCCOLOR (2srcdst).
- A Texture is PF_Masked by its
bMaskedtag. When the engine imports a BMP itself (UEngineTextureFactory::FactoryCreateBinary, Engine.dll 0x10425a50) it sets PF_Masked only if palette entry 0 is exactly (255,0,255,255) and at least one pixel of mip 0 uses index 0, else clears it. Port:HP1.Core/Runtime/World/UETextureImport.cs. - A script can write
bMaskedat run time. The menu'sLogoTexture1/LogoTexture2are set masked byFEBook.Created, and the original draws the logo masked; without that the index-0 background shows black under the menu buttons. - The same name can exist in several packages with different
bMasked(station,snitch,window2), so the port looks textures up by package and group, never by leaf name (UEPackageReader.cs). - D3DDrv's alpha test is the PF_Masked bit, reference 0x7f, GREATER; the bit is cleared only under PF_Translucent, so Masked plus Modulated is cut by the mask. A texture drawn masked without
bMaskeduses D3DDrv's P8 to 8888 table: alpha is the palette alpha, entry 0 becomes zero. Palette alpha is 0xFF for packages older than version 0x42 (GenFX, Detail, FireEng, GreatFire, Liquids, Palettes). Frontend:hpengine/RenderRules.cs(AlphaTest),hpengine/SdlRenderer.cs. - Not original (improvement, author 2026-11-03, D-78): the original uploads mesh skins at precache with the texture's own flags, so PF_Masked faces such as the glasses of Harry and Dumbledore keep palette index 0 opaque, a dark band on some machines. The port cuts index 0 per use. A campaign scan predicted 59 affected mesh skins, 28 seen; the decision covers all of them.
- Not original (improvement, D-48, D-53): D3DDrv samples with LINEAR mag/min and no mip interpolation (
UseTrilinear=False, point mip filter), and never sets anisotropy. Enhanced mode, the default, adds trilinear mips and 16x anisotropic filtering;VisualMode=Originaluses the original's sampler.
Actor.Fatnessmoves each mesh vertex along its normal before lighting and clipping: the offset is 0 when Fatness is 128, otherwiseFatness * 0.0625 - 8in UE units (constants .rdata 0x10b387c0 and 0x10b38644 in Render.dll; the mesh vertex loops inDrawMeshandDrawLodMesh). It uses the same unit normal that feeds vertex lighting. Port:HP1.Core/Runtime/Render/ActorFatness.cs. An older reference port multiplied by an extra 0.02 for Unity metres; that does not apply here.
FUN_10b0d3c0(Render.dll 0x10b0d3f9..0x10b0d621): with the vertex point P and normal N in view space, D = P / |P|, R = D - N * 2(D.N), then R is rotated into world space with the frame's Uncoords. U = (T.x + 1) * UScale * 128 and V = (T.y + 1) * VScale * 128, i.e. texture fractions (T.x+1)/2 and (T.y+1)/2. Vertex light ispow(max(T.z, 0), 0.25). The sign of N does not change R. Port:HP1.Core/Runtime/Render/EnviroMapping.cs, computed in world space, equal to the view-space body up to rounding.- An empty mesh slot, and
bMeshEnviroMapmeshes, use Actor.Texture, else the zone's EnvironmentMap, else the level's, else the last non-null texture of the mesh (0x10b11811..0x10b1183f;RenderRules.MeshFallbackTexture).
- Fog comes from volumetric lights (
VolumeRadius,VolumeBrightness,VolumeFog) in zones withbFogZone. Radius is(VolumeRadius + 1) * 25(AActor::WorldVolumetricRadius, Engine.dll 0x1031b9e0). It is only used when the device supports fog maps (D3DDrv sets 1) and volumetric lighting is on in the ini. - Surfaces (
FLightManager::SetupForSurf): a surface gets a fog map when it has a lightmap, is not Unlit or Translucent, and its zone is a fog zone. One map per draw record: OccludeBsp merges a polygon into the frame's record of its surface and zone unless the record flags contain any of 0x4010047, so such polygons get their own record. The light colour isFGetHSV(Hue, Sat, 255) * Level.Brightness * LightBrightness / 255. Texels use 16.16 fixed point and the tableFastSqrt(0x10b4ca44, built inFLightManager::Initoutside the 24-bit window; sqrt(2) is kept as a double, which differs from a float build in 248 of 2048 entries). A surface drawn by the master frame and by a mirror has two different maps, because the records are in each frame's Coords. Port:HP1.Core/Runtime/VM/FogMap.cs(texel generator),HP1.Core/Runtime/VM/LevelFogMaps.cs(per-frame records). D3DDrv composites the map in a shader (2 * rgb / 255 + dest * (1 - 2 * a / 255)). - Actors (
LightAndFog): a vertex fog valuefis doubled,a = min(1, f * VolumeFog / 255),rgb = min(1, (1 - a) * rgb + f * col),A = min(1, A + a), quantised into the D3D specular byte. The records an actor uses are those of its sprite's volumetric leaves (SetupForActorparam 4, marked at 0x10b0a45a..0x10b0a4c2), sorted far first byappQsort(0x10b0a5b1); this is independent of LightRadius, the 3+3 light cap and line of sight. PF_RenderFog is set only when that list is non-empty (0x10b0a47c). The fog test goes by the actor's zone (its ZoneNumber among the level's fog zones), not by the actor's own bFogZone bit. A third-person weapon takes its pawn's volumetric list. Actor fog does not depend on surface fog maps. Port:HP1.Core/Runtime/Render/ActorFogFrame.cs. - Open: the global flag DAT_10b658d8 in
LightAndFogis global in the original and per actor in the port; the two tests differ only by rounding at the fog boundary (density tending to zero). - The fog texel body was first transcribed from the decompile and checked against a replica of it. It has not been run against the original's own machine code the way the span buffer was; treat its last-bit equality as unproven.