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

ivand
Posts: 310
Joined: 27 Jun 2007, 17:05

Re: Change Light map value

Post by ivand »

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:
https://hastebin.com/openufiyaj.lua

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")
	end

	if gl.Texture(ssmfEmissionTexNew) then
		--Spring.SetMapShadingTexture("$ssmf_emission", ssmfEmissionTexNew)
		Spring.Echo(ssmfEmissionTexNew)
	end
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
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Change Light map value

Post by Kloot »

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,
	}
end

function widget:Initialize()
	local ssmfEmissionTexInfo = gl.TextureInfo("$ssmf_emission")
	ssmfEmissionTexHandle = gl.CreateTexture(
		ssmfEmissionTexInfo.xsize,
		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)
end

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

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

NB: you only need to call Spring.SetMapShadingTexture once.
ivand
Posts: 310
Joined: 27 Jun 2007, 17:05

Re: Change Light map value

Post by ivand »

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.
Post Reply

Return to “Map Creation”