Changing sky colour

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Changing sky colour

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Changing sky colour

Post 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...)
A trip of a thousand leagues starts with a step.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Changing sky colour

Post 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).
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Changing sky colour

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply