Page 1 of 1

Changing the map texture?

Posted: 22 Feb 2013, 16:56
by yanom
So I've noticed that when I terraform things in Zero-K it makes the ground all brick-textured, to look like manmade construction rather than natural terrain. How do I do that? I've got buildings in my game that make the ground around them flatter when they're built, and I'd like to apply a cobblestone or concrete texture to the ground it flattens.

Re: Changing the map texture?

Posted: 22 Feb 2013, 18:15
by gajop
Changing map texture is not easy in my experience.
Not sure how ZK does it (check their code) but I'm doing this the following way in ToolBox:
1. When the game starts I generate new textures for each map square (map squares are rectangles of 1024x1024 size). The reason for this is that for some reason the textures you get by default don't support rendering (FBO disabled or sth). code
2. I set those newly generated textures using Spring.SetMapTexture(tex).code
3. When needed I render to those textures using gl.RenderToTexture(tex, function()). I also use shaders in this step (not sure if it's necessary). code

All this should be done in one of the GL calls, like widget:DrawWorld.

Check my code here: https://github.com/gajop/Toolbox/blob/m ... exture.lua it is complex and ugly atm.

PS: Maybe there's an easier way (read: there probably is), so please share it if you find it :)

Re: Changing the map texture?

Posted: 22 Feb 2013, 18:26
by FLOZi

Re: Changing the map texture?

Posted: 22 Feb 2013, 19:17
by zwzsg
Err, wouldn't the simple BuildingGroundDecal tags cover yanom's need?

Re: Changing the map texture?

Posted: 25 Feb 2013, 16:20
by yanom
oooh, that's right. Building ground decals! Do those dissapear after the building dies?

it appears that ground decals aren't turned on in Low or Very Low graphics mode, though. Anyway for the mod to force them to show up? They're kind of important, I don't want users on slow PC's to miss out. I can make them non-transparent and low-res if that helps.