Change Light map value - Page 2

Change Light map value

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

User avatar
Posts: 134
Joined: 27 Jun 2007, 17:05

Re: Change Light map value

Post by ivand » 30 Jun 2018, 13:13

Kloot wrote:
Is [DOES NOTHING] by design or just an oversight?
Neither, gajop's copypasta snippet directly kills the default emission texture (as it should) for me on Core Platform.

Which map(s) are you using to test this?
Hello @Kloot!
Great to hear it works for you, perhaps something is off on my side. I test it on "Incandescence 2" map, although map is unpacked in SDD and I edit a gadget in LuaRules folder.

I have cleaned up gadget a bit here:

It effectively does nothing for me (no visible emission map changes).

If I change the part of code to

Code: Select all

	if gl.Texture("white4k.png") then
		Spring.SetMapShadingTexture("$ssmf_emission", "white4k.png")

	if gl.Texture(ssmfEmissionTexNew) then
		--Spring.SetMapShadingTexture("$ssmf_emission", ssmfEmissionTexNew)
Then the whole map becomes white (white4k.png is 4K * 4K sized white texture). But if i uncomment

Code: Select all

Spring.SetMapShadingTexture("$ssmf_emission", ssmfEmissionTexNew)
nothing happens
0 x

Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Change Light map value

Post by Kloot » 30 Jun 2018, 14:01

Could you please run the following minimal example widget on either Core Platform or Incandescence? This should have obvious effects if it works.

Code: Select all

local ssmfEmissionTexHandle = ""

function widget:GetInfo()
	return {
		name      = "Spring.SetMapShadingTexture",
		layer     = 0,
		enabled   = true,

function widget:Initialize()
	local ssmfEmissionTexInfo = gl.TextureInfo("$ssmf_emission")
	ssmfEmissionTexHandle = gl.CreateTexture(
		ssmfEmissionTexInfo.ysize, {
			border = false,
			min_filter = GL.NEAREST,
			mag_filter = GL.NEAREST,
			wrap_s = GL.CLAMP_TO_EDGE,
			wrap_t = GL.CLAMP_TO_EDGE,
			fbo = true,

	Spring.SetMapShadingTexture("$ssmf_emission", ssmfEmissionTexHandle)

function widget:Shutdown()
	Spring.SetMapShadingTexture("$ssmf_emission", "")

function widget:DrawWorld()
	gl.RenderToTexture(ssmfEmissionTexHandle, gl.Clear, GL.COLOR_BUFFER_BIT, 0, math.fmod(Spring.GetGameFrame(), 60) / 60, 0, 0)

NB: you only need to call Spring.SetMapShadingTexture once.
1 x

User avatar
Posts: 134
Joined: 27 Jun 2007, 17:05

Re: Change Light map value

Post by ivand » 30 Jun 2018, 14:47

Thanks for the hints @Kloot and @gajop.

I've managed to make it work.

The reasons were:
1. "fbo = true" missing in the gl.CreateTexture. I was falsely assuming fbo = gl.CreateFBO will do it for me, but I was wrong.
2. My emission map apparently was bleak enough, so I didn't notice the change between default emission map and 0,0,0,0 RGBA texture.
2a. Part of the issue is that I (for some weird reason) expected (0,0,0,0) RGBA to render as unlit surface, instead it's (0,0,0,1) RGBA that does that, so my dummy shader "gl_FragColor = vec4(0.0);" didn't make impression of doing anything.
0 x

Post Reply

Return to “Map Creation”