Page 1 of 1

Changing sky colour

Posted: Tue Aug 25, 2015 9:22 am
by minmay
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:

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,
}
(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.

Re: Changing sky colour

Posted: Tue Aug 25, 2015 10:08 am
by cromcrom
Thanks. might not be really related, but I would like to make my nights really really really dark (like, you can't see nothing, unless you have some light source with you...)

Re: Changing sky colour

Posted: Tue Aug 25, 2015 10:25 am
by petri
I precomputed these textures a very long time ago (using a "physically correct" atmospheric scattering simulation program I wrote), but if I remember correctly, they are 64x64x64 3D volumes in D3DFMT_A16B16G16R16F format (16-bit floating point).

Re: Changing sky colour

Posted: Tue Aug 25, 2015 5:35 pm
by minmay
cromcrom wrote:Thanks. might not be really related, but I would like to make my nights really really really dark (like, you can't see nothing, unless you have some light source with you...)
You could disable the sky's LightComponents.