Readme fixes, renamed demo textures for conventions

master
struggzard 2020-03-22 16:53:11 +02:00
parent cadefd3fd5
commit 3691659267
6 changed files with 112 additions and 194 deletions

294
README.md
View File

@ -109,202 +109,118 @@ clouds_data = {
The Skylayer mod designed to be configured by other mods. See demo.lua for examples and pre-builds commands for quick tests. The Skylayer mod designed to be configured by other mods. See demo.lua for examples and pre-builds commands for quick tests.
Demo by default is disabled and can be enabled by uncommenting file include inside init.lua. Demo by default is disabled and can be enabled by uncommenting file include inside init.lua.
### Plain color without clouds
```
local sl = {}
sl.name = "plain_without_clouds_sky"
sl.sky_data = {
base_color = { r = 0, g = 0, b = 0 },
clouds = false
}
skylayer.add_layer(player_name, sl)
```
### Gradient plain color with clouds ### Gradient plain color with clouds
``` ```
local sl = {} local sl = {}
sl.name = "gradient_plain_with_clouds_sky" sl.name = "gradient_plain_with_clouds_sky"
sl.sky_data = { sl.sky_data = {
gradient_colors = { gradient_colors = {
{ r = 68, g = 34, b = 153 }, { r = 68, g = 34, b = 153 },
{ r = 59, g = 12, b = 189 }, { r = 59, g = 12, b = 189 },
{ r = 51, g = 17, b = 187 }, { r = 51, g = 17, b = 187 },
{ r = 68, g = 68, b = 221 }, { r = 68, g = 68, b = 221 },
{ r = 17, g = 170, b = 187 }, { r = 17, g = 170, b = 187 },
{ r = 18, g = 189, b = 185 }, { r = 18, g = 189, b = 185 },
{ r = 34, g = 204, b = 170 }, { r = 34, g = 204, b = 170 },
{ r = 105, g = 208, b = 37 }, { r = 105, g = 208, b = 37 },
{ r = 170, g = 204, b = 34 }, { r = 170, g = 204, b = 34 },
{ r = 208, g = 195, b = 16 }, { r = 208, g = 195, b = 16 },
{ r = 204, g = 187, b = 51 }, { r = 204, g = 187, b = 51 },
{ r = 254, g = 174, b = 45 }, { r = 254, g = 174, b = 45 },
{ r = 255, g = 153, b = 51 }, { r = 255, g = 153, b = 51 },
{ r = 255, g = 102, b = 68 }, { r = 255, g = 102, b = 68 },
{ r = 255, g = 68, b = 34 }, { r = 255, g = 68, b = 34 },
{ r = 255, g = 51, b = 17 }, { r = 255, g = 51, b = 17 },
{ r = 248, g = 12, b = 18 }, { r = 248, g = 12, b = 18 },
{ r = 255, g = 51, b = 17 }, { r = 255, g = 51, b = 17 },
{ r = 255, g = 68, b = 34 }, { r = 255, g = 68, b = 34 },
{ r = 255, g = 102, b = 68 }, { r = 255, g = 102, b = 68 },
{ r = 255, g = 153, b = 51 }, { r = 255, g = 153, b = 51 },
{ r = 254, g = 174, b = 45 }, { r = 254, g = 174, b = 45 },
{ r = 204, g = 187, b = 51 }, { r = 204, g = 187, b = 51 },
{ r = 208, g = 195, b = 16 }, { r = 208, g = 195, b = 16 },
{ r = 170, g = 204, b = 34 }, { r = 170, g = 204, b = 34 },
{ r = 105, g = 208, b = 37 }, { r = 105, g = 208, b = 37 },
{ r = 34, g = 204, b = 170 }, { r = 34, g = 204, b = 170 },
{ r = 18, g = 189, b = 185 }, { r = 18, g = 189, b = 185 },
{ r = 17, g = 170, b = 187 }, { r = 17, g = 170, b = 187 },
{ r = 68, g = 68, b = 221 }, { r = 68, g = 68, b = 221 },
{ r = 51, g = 17, b = 187 }, { r = 51, g = 17, b = 187 },
{ r = 59, g = 12, b = 189 } { r = 59, g = 12, b = 189 }
} }
} }
sl.clouds_data = { sl.clouds_data = {
gradient_colors = { gradient_colors = {
{ r = 34, g = 204, b = 170 }, { r = 34, g = 204, b = 170 },
{ r = 105, g = 208, b = 37 }, { r = 105, g = 208, b = 37 },
{ r = 170, g = 204, b = 34 }, { r = 170, g = 204, b = 34 },
{ r = 208, g = 195, b = 16 }, { r = 208, g = 195, b = 16 },
{ r = 204, g = 187, b = 51 }, { r = 204, g = 187, b = 51 },
{ r = 254, g = 174, b = 45 }, { r = 254, g = 174, b = 45 },
{ r = 255, g = 68, b = 34 }, { r = 255, g = 68, b = 34 },
{ r = 255, g = 102, b = 68 }, { r = 255, g = 102, b = 68 },
{ r = 255, g = 153, b = 51 }, { r = 255, g = 153, b = 51 },
{ r = 254, g = 174, b = 45 }, { r = 254, g = 174, b = 45 },
{ r = 59, g = 12, b = 189 } { r = 59, g = 12, b = 189 }
}, },
speed = { x = 110, z = -400 } speed = { x = 110, z = -400 }
} }
sl.sun_data = { sl.sun_data = {
visible = false visible = false
} }
sl.moon_data = { sl.moon_data = {
visible = false visible = false
} }
skylayer.add_layer(player_name, sl) skylayer.add_layer(player_name, sl)
``` ```
### Gradient plain sky colors
``` ```
-- Datatype: local sl = {}
-- GradientSpec - a table in format {ColorSpec, ColorSpec}, (e.g. {{r=68, g=34, b=153}, {r=68, g=68, b=221}}) could be many gradient points. sl.name = "gradient_plain_sky_colors_with_defaults_sky"
sl.sky_data = {
gradient_sky = {
local sl = {} day_sky = {
sl.name = "sample_sky_with_clouds" { r = 100, g = 0, b = 6},
sl.sky_data = { { r = 6, g = 100, b = 0},
-- These parameters used for minetest set_sky api, { r = 0, g = 6, b = 100}
-- please refer MT lua_api docs for parameter details. },
bgcolor = {r=0, g=100, b=255}, -- table, color in RGB format, optional. day_horizon = {
type = "plain", -- string, available types: regular, skybox, plain. { r = 100, g = 56, b = 0},
textures = nil, -- table, textures for skybox type. { r = 42, g = 100, b = 0},
clouds = true, -- boolean, flag if clouds should appear in front of "skybox" or "plain" types. { r = 92, g = 100, b = 0}
sky_color = nil, -- table, a location and envinronment focused sky colors. },
night_sky = {
-- These optional parameter are skylayer specific, { r = 0, g = 255, b = 87},
-- if set they may override parameters above. { r = 250, g = 187, b = 100},
gradient_colors = GradientSpec -- table, color points used to create gradient based on world time, if set bgcolor will be overrided by color generated from gradient { r = 255, g = 82, b = 0}
gradient_sky = { },
day_sky = GradientSpec, night_horizon = {
day_horizon = GradientSpec, { r = 87, g = 100, b = 0},
dawn_sky = GradientSpec, { r = 0, g = 87, b = 100},
dawn_horizon = GradientSpec, { r = 100, g = 0, b = 87}
night_sky = GradientSpec, },
night_horizon = GradientSpec, }
indoors = GradientSpec, }
fog_sun_tint = GradientSpec, skylayer.add_layer(player_name, sl)
fog_moon_tint = GradientSpec,
} -- supports similar set of parameters as minetest api but in gradient type instead, in case some parameter is not set then default value will be used as documented for sky_colors.
}
sl.sun_data = {
-- These optional parameters used for minetest set_sun api,
-- please refer MT lua_api docs for paramater details.
visible: Boolean for whether the sun is visible. (default: true)
texture: A regular texture for the sun. Setting to "" will re-enable the mesh sun. (default: "sun.png")
tonemap: A 512x1 texture containing the tonemap for the sun (default: "sun_tonemap.png")
sunrise: A regular texture for the sunrise texture. (default: "sunrisebg.png")
sunrise_visible: Boolean for whether the sunrise texture is visible. (default: true)
scale: Float controlling the overall size of the sun. (default: 1)
}
sl.moon_data = {
-- These optional parameters used for minetest set_moon api,
-- please refer MT lua_api docs for paramater details.
parameters is a table with the following optional fields:
visible: Boolean for whether the moon is visible. (default: true)
texture: A regular texture for the moon. Setting to "" will re-enable the mesh moon. (default: "moon.png")
tonemap: A 512x1 texture containing the tonemap for the moon (default: "moon_tonemap.png")
scale: Float controlling the overall size of the moon (default: 1)
}
sl.stars_data = {
-- These optional parameters used for minetest set_moon api,
-- please refer MT lua_api docs for paramater details.
visible: Boolean for whether the stars are visible. (default: true)
count: Integer number to set the number of stars in the skybox. Only applies to "skybox" and "regular" skyboxes. (default: 1000)
star_color: ColorSpec, sets the colors of the stars, alpha channel is used to set overall star brightness. (default: #ebebff69)
scale: Float controlling the overall size of the stars (default: 1)
-- These optional parameter are skylayer specific,
-- if set they may override parameters above.
gradient_colors = GradientSpec -- table, same as sky gradient color, if set star_color will be overrided by color generated from gradient
}
sl.clouds_data = {
-- These optional parameters used for minetest set_clouds api,
-- please refer MT lua_api docs for paramater details.
density = 0.4, -- number, clouds density from 0 (no clouds) to 1 (full clouds).
color = "#fff0f0e5", -- string, basic cloud color with alpha channel.
ambient = "#000000", -- string, cloud color lower bound.
height = 120, -- number, cloud height
thickness = 16, -- number, cloud thickness in nodes.
speed = {x=5, z=-40}, -- table, speed + direction in nodes per second.
-- These optional parameter are skylayer specific,
-- if set they may override parameters above.
gradient_colors = GradientSpec -- table, same as sky gradient color, if set color will be overrided by color generated from gradient
}
skylayer.add_layer(player_name, sl)
``` ```
## Media
### Gradient supported sky definition sample Textures used for demo is all created by me with public domain (CC0):
``` - skylayer_demo_cold_moon.png
local sl = {} - skylayer_demo_hot_sun.png
sl.name = "plain_sample_sky" - skylayer_demo_stars_sky.png
sl.sky_data = {
gradient_colors = {
{r=68, g=34, b=153},
{r=254, g=174, b=45},
{r=59, g=12, b=189}
}
}
skylayer.add_layer(player_name, sl)
```
### Single solid color sky (no smooth transition)
```
local sl = {}
sl.name = "solid_black"
sl.sky_data = {
bgcolor = {r=0, g=0, b=0}
}
skylayer.add_layer(player_name, sl)
```
### Skybox image based sky
```
local sl = {}
sl.name = "stars_sky"
sl.sky_data = {
bgcolor = {r=0, g=0, b=0},
type = "skybox",
textures = {
"skylayer_demo_stars_sky.png",
"skylayer_demo_stars_sky.png",
"skylayer_demo_stars_sky.png",
"skylayer_demo_stars_sky.png",
"skylayer_demo_stars_sky.png",
"skylayer_demo_stars_sky.png"
}
}
skylayer.add_layer(player_name, sl)
```

View File

@ -278,19 +278,21 @@ core.update_sky_details = function(player, sky_layer)
sky_type = "regular" sky_type = "regular"
end end
local visibleClouds = sky_layer.clouds_data or sky_data.clouds == true
if core.legacy then if core.legacy then
player:set_sky( player:set_sky(
bg_color, bg_color,
sky_type, sky_type,
sky_data.textures, sky_data.textures,
core.ternary(sky_layer.clouds_data or sky_data.clouds ~= nil, sky_data.clouds == true, true) visibleClouds
) )
else else
player:set_sky({ player:set_sky({
base_color = bg_color, base_color = bg_color,
type = sky_type, type = sky_type,
textures = sky_data.textures, textures = sky_data.textures,
clouds = core.ternary(sky_layer.clouds_data or sky_data.clouds ~= nil, sky_data.clouds == true, true), clouds = visibleClouds,
sky_color = core.resolve_sky_color(sky_data) sky_color = core.resolve_sky_color(sky_data)
}) })
end end

View File

@ -108,7 +108,7 @@ local custom_moon_with_gradient_stars_sky = function(player_name)
local sl = {} local sl = {}
sl.name = "custom_moon_with_gradient_stars_sky" sl.name = "custom_moon_with_gradient_stars_sky"
sl.moon_data = { sl.moon_data = {
texture = "cold_moon.png", texture = "skylayer_demo_cold_moon.png",
} }
sl.stars_data = { sl.stars_data = {
scale = 2, scale = 2,
@ -125,7 +125,7 @@ local custom_sun_with_default_sky = function(player_name)
local sl = {} local sl = {}
sl.name = "custom_sun_with_default_sky" sl.name = "custom_sun_with_default_sky"
sl.sun_data = { sl.sun_data = {
texture = "hot_sun.png", texture = "skylayer_demo_hot_sun.png",
scale = 3 scale = 3
} }
skylayer.add_layer(player_name, sl) skylayer.add_layer(player_name, sl)

View File

@ -10,4 +10,4 @@ local modpath = minetest.get_modpath("skylayer");
dofile(modpath.."/api.lua") dofile(modpath.."/api.lua")
-- uncomment to enable demo -- uncomment to enable demo
--dofile(modpath.."/demo.lua") dofile(modpath.."/demo.lua")

View File

Before

Width:  |  Height:  |  Size: 912 B

After

Width:  |  Height:  |  Size: 912 B

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB