Light, heat and particles
Vintage Story already has several ways of making things glow. VSPT turns each of them into real light, and this page covers how to use them from a mod. None of it needs VSPT-specific code or files. It was written for VSPT 0.3.
Glowing blocks and items
Section titled “Glowing blocks and items”A face with a glow level glows under the path tracer, in the texel’s own colour, and lights its surroundings as a real light does:
"vertexFlags": { "glowLevel": 255 }- Without a material rule, glow level 255 on a white texel is about 12,800 nits, the brightness of a torch flame. Lower levels and darker texels are dimmer in proportion.
- For control over how bright and what colour, give the texture a rule with
emissiveNitsandemissiveKelvinoremissiveColor, and an_mmap to say which texels glow. See Making things glow. - The block’s
lightHsvstill drives the game’s light grid, which is what mobs and crops see. The path tracer lights the picture from the glowing faces themselves, so keep the two roughly in step.
Particles
Section titled “Particles”Every particle the game spawns is path traced, from rain and smoke to sparks and crumbs, and so are your mod’s. A particle is a flat, rough surface of its colour, lit by the world around it, and its opacity is how much of it a ray hits. It has no texture.
A particle’s light comes from its glow level, which is the low byte of its vertex flags (0 to 255):
| Glow level | Under the path tracer |
|---|---|
| 0 to 32 | No light of its own; lit by the world like any surface. The game gives rain 32 so that it shows in the dark |
| 33 to 255 | Glows in its colour, at the glow level over 255 times about 12,800 nits, and lights what it flies past |
Cube particles have their glow doubled (up to 255), as the game’s own cube particle shader does. In code, set
VertexFlags:
// Embers off a blade: small glowing cubes that rise and fall back.var embers = new SimpleParticleProperties( 1, 3, // how many a spawn, from and to ColorUtil.ToRgba(255, 255, 140, 40), // alpha, red, green, blue: deep orange pos, pos.AddCopy(0.1, 0.1, 0.1), // where, from and to new Vec3f(-0.2f, 0.6f, -0.2f), // velocity, from new Vec3f(0.2f, 1.4f, 0.2f), // and to 1.2f, // life, seconds 0.3f, // gravity 0.15f, 0.3f, // size, from and to EnumParticleModel.Cube);embers.VertexFlags = 96; // glow level: above 32 gives light under VSPTworld.SpawnParticles(embers);In a block’s JSON particleProperties, it is vertexFlags, as vanilla’s fire has it:
"vertexFlags": 128The smithing sparks
Section titled “The smithing sparks”The sparks off the anvil are vanilla’s own particles, made in code rather than assets, so there is nothing named to
patch. They are three static SimpleParticleProperties on BlockEntityAnvil in the survival mod
(Vintagestory.GameContent):
| Field | What it is | Glow level |
|---|---|---|
bigMetalSparks |
Larger sparks that bounce and redden as they cool | (temperature - 700) / 2, held between 32 and 128 |
smallMetalSparks |
A quick spray of tiny ones | (temperature - 770) / 3, held between 32 and 128 |
slagPieces |
Bits in the work item’s own colour | None: lit by the world |
The temperature is the work item’s, so the sparks dim as the metal cools: the big ones stop giving light below about 765 °C, the small ones below about 870 °C. Anything smithed on the vanilla anvil gets them, a mod’s weapons and tools included, with no files at all.
Hot metal
Section titled “Hot metal”Anything the game makes glow because of its temperature glows under the path tracer as a real blackbody (Planck’s law, in absolute units), and lights its surroundings. It covers an ingot or a work item in the forge, a work item on the anvil, a cast cooling in its mould, a hot stack on the ground, and a hot item dropped or held. Any item that carries a temperature gets this, a mod’s included.
| Temperature | Looks like |
|---|---|
| Under 450 °C | Nothing |
| 600 to 700 °C | Dull red, plain in the dark, faint by day |
| 900 °C | Cherry red |
| 1,100 °C | Orange; lights the forge |
| 1,300 °C | Yellow-white |
| 1,500 °C | White, brighter than a torch flame |
The texture shows through the glow: each texel’s share follows its brightness against the rest of its texture, as hot metal is never even. So a texture with scale or seams painted in keeps them while it glows.
Your own renderers
Section titled “Your own renderers”A mod’s renderer is traced like vanilla’s when it draws a mesh with a texture from one of the game’s atlases and a model matrix, into the screen or one of the game’s own framebuffers. Line meshes (outlines, a selection box) are drawn over the picture, as the game’s selection outline is.
If you draw hot things yourself, set the standard shader’s glow as vanilla’s anvil renderer does, and the path tracer reads the temperature back from it:
int temperature = (int)stack.Collectible.GetTemperature(world, stack);int glow = GameMath.Clamp((temperature - 550) / 2, 0, 255);float[] incandescence = ColorUtil.GetIncandescenceColorAsColor4f(temperature);prog.Uniform("rgbaGlowIn", new Vec4f(incandescence[0], incandescence[1], incandescence[2], glow / 255f));prog.Uniform("extraGlow", glow);A glow whose alpha does not match its level is taken as a brightening of what the surface already emits, not as a temperature: that is how the forge’s coals brighten under the bellows.
