Skip to content

Broken lantern/candle in metro map, light emitting shader is displayed #322

@illwieckz

Description

@illwieckz

I've noticed this issue a long time ago, but #301 seems to also trigger it in Terminus. It may be time to look at it…

Look at those candles and lanterns, how they look in Unvanquished:

metro lantern

metro lantern

metro lantern

metro lantern

And how they look in Tremulous:

metro lantern

metro lantern

metro lantern

metro lantern

Along with the flame, you'll notice those square textures in NetRadiant (those things are misc_model entities so they are meant to be baked in BSP):

metro lantern

metro lantern

metro lantern

metro lantern

Those squares textures are in fact… light emitting shaders, that's a clever hack to ship an md3 model with built-in lighting (with light orientation etc.). We see how those light emitting shaders are set:

metro lantern

metro lantern

metro lantern

The one floating above or in front of the lantern is meant to use the back splash feature of the light emitting shader to lit the ground or the wall.

This is the code for the square light emitting shader:

//lanterne1.md3 self lightning
models/mapobjects/kosad/lanterne/lumieresoft
{
	qer_editorimage models/mapobjects/kosad/lanterne/lumieresoft
	qer_trans .2

	q3map_surfacelight 5000
	q3map_lightrgb 1 .8 .4
	q3map_backsplash 30 4

	{
		map $lightmap
		blendfunc filter
	}
}

What's weird is that this lightmap is not meant to be displayed at all so I don't know why there is a lightmap stage, maybe to be sure the compiler will not ignore the shader and the light will be emitted.

The blendFunc filter operation is the default operation to blend a lightmap over a diffuseMap. What's weird is that if we don't take in account this material is not meant to be rendered, this is a lightmap blended with nothing. This is like undefined behaviour.

Then, if we look at the code of the candle flame shader:

textures/metro/kosad_flammebougie
{
	qer_editorimage textures/metro/kosad_flammebougie1

	surfaceparm nolightmap
	surfaceparm nomarks
	surfaceparm trans

	cull disable
	deformvertexes autosprite2

	{
		animmap 50 textures/metro/kosad_flammebougie1 textures/metro/kosad_flammebougie2 textures/metro/kosad_flammebougie3 textures/metro/kosad_flammebougie4 textures/metro/kosad_flammebougie5 textures/metro/kosad_flammebougie6 textures/metro/kosad_flammebougie7 textures/metro/kosad_flammebougie8
		blendfunc add
	}
}

It's an animMap blended with add operation (like glow maps), added over… nothing.

Note that those pictures are jpeg with black bacground, the right operation may be alphaFunc GT0 or alphaFunc GE128.

The blendFunc are usually used to blend multiple stage within shaders, that's not the same purpose.

This time, the material must be displayed, but not the way it is.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions