Changing sky colour
Posted: Tue Aug 25, 2015 9:22 am
You can change the textures used to simulate Rayleigh and Mie scattering, and therefore the colours in the background of your sky, with MaterialEx:setTexture(). For example, you can swap the two default textures with:
(You don't need to, and probably shouldn't, make the setTexture call every frame; making it every time the game is loaded, or you want to change the texture again, is enough. You could also call it on every level change if you want to switch to different textures depending on the party's level, in order to use several different sky colour palettes in your mod.)
Note that unlike other textures in the game you need to give the .dds extension rather than .tga.
I haven't figured out what the format for these textures is yet. The dds headers appear to be garbage.
Code: Select all
defineMaterial{
name = "day_sky",
clouds0Map = "assets/textures/env/sky_cloudy_0.tga", -- stratos
clouds1Map = "assets/textures/env/sky_cloudy_1.tga",
clouds2Map = "assets/textures/env/sky_cloudy_2.tga",
clouds3Map = "assets/textures/env/sky_cloudy_3.tga",
cloudsRim1Map = "assets/textures/env/sky_cloudy_rim_1.tga",
cloudsRim2Map = "assets/textures/env/sky_cloudy_rim_2.tga",
cloudsRim3Map = "assets/textures/env/sky_cloudy_rim_3.tga",
doubleSided = false,
lighting = false,
alphaTest = false,
blendMode = "Translucent",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
shader = "sky",
onUpdate = function(self, time)
self:setTexture("rayleighTex","assets/atmosphere/mie_scatter_opt.dds")
self:setTexture("mieTex","assets/atmosphere/rayleigh_scatter_opt.dds")
end,
}
defineMaterial{
name = "night_sky",
clouds0Map = "assets/textures/env/sky_cloudy_0.tga", -- stratos
clouds1Map = "assets/textures/env/sky_cloudy_1.tga",
clouds2Map = "assets/textures/env/sky_cloudy_2.tga",
clouds3Map = "assets/textures/env/sky_cloudy_3.tga",
cloudsRim1Map = "assets/textures/env/sky_cloudy_rim_1.tga",
cloudsRim2Map = "assets/textures/env/sky_cloudy_rim_2.tga",
cloudsRim3Map = "assets/textures/env/sky_cloudy_rim_3.tga",
doubleSided = false,
lighting = false,
alphaTest = false,
blendMode = "Translucent",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
shader = "sky",
onUpdate = function(self, time)
self:setTexture("rayleighTex","assets/atmosphere/mie_scatter_opt.dds")
self:setTexture("mieTex","assets/atmosphere/rayleigh_scatter_opt.dds")
end,
}Note that unlike other textures in the game you need to give the .dds extension rather than .tga.
I haven't figured out what the format for these textures is yet. The dds headers appear to be garbage.