Mod tweaks and perf improvements

- zeus:flowers -> zeus:vegetation
- Added tall grass to zeus:vegetation
- Added new plants
- Better Voronoi diagram, output debug images
master
Auri 2021-09-26 16:22:07 -07:00
parent b26126e0fb
commit f532ee4fe6
62 changed files with 701 additions and 509 deletions

View File

@ -11,4 +11,4 @@ zepha.player:set_hud(zepha.gui(function()
background = 'zepha:base:crosshair'
}
}
end))
end))

View File

@ -22,4 +22,4 @@ if zepha.server then
hand:add_stack({ 'zepha:base:hand', 1 })
p:set_hand_list(hand)
end)
end
end

View File

@ -21,7 +21,7 @@ zepha.register_blockmodel(':cross_plant', {
parts = {
{
face = 'nocull',
tex = 1,
tex = 2,
points = {
0.1, 0, 0.1, 0, 1,
0.9, 0, 0.9, 1, 1,
@ -38,7 +38,7 @@ zepha.register_blockmodel(':cross_plant', {
}
}, {
face = 'nocull',
tex = 1,
tex = 2,
points = {
0.9, 0.9, 0.9, 1, 0,
0.9, 0, 0.9, 1, 1,

View File

@ -0,0 +1,108 @@
--
-- Diagonal cross-shaped model. Has 2 vertical faces that make an X pattern when looked at from above.
-- Useful for representing plants, grass, etc.
-- Only takes one texture, which is displayed on all faces.
--
local wave_amplitude = 0.2
local offset_amplitude = 0.14
zepha.register_blockmodel(':cross_plant_tall', {
mesh_mods = {
{
type = 'offset_x',
amplitude = offset_amplitude,
},
{
type = 'offset_z',
amplitude = offset_amplitude,
}
},
parts = {
{
face = 'nocull',
tex = 2,
points = {
0.1, 0, 0.1, 0, 1,
0.9, 0, 0.9, 1, 1,
0.9, 0.9, 0.9, 1, 0.5,
0.1, 0.9, 0.1, 0, 0.5,
0.1, 0.9, 0.1, 0, 0.5,
0.9, 0.9, 0.9, 1, 0.5,
0.9, 1.8, 0.9, 1, 0,
0.1, 1.8, 0.1, 0, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = wave_amplitude
},
mesh_mod = {
type = 'offset',
scale = 0.1
}
}, {
face = 'nocull',
tex = 2,
points = {
0.9, 0.9, 0.9, 1, 0.5,
0.9, 0, 0.9, 1, 1,
0.1, 0, 0.1, 0, 1,
0.1, 0.9, 0.1, 0, 0.5,
0.9, 1.8, 0.9, 1, 0,
0.9, 0.9, 0.9, 1, 0.5,
0.1, 0.9, 0.1, 0, 0.5,
0.1, 1.8, 0.1, 0, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = wave_amplitude
},
mesh_mod = {
type = 'offset',
scale = 0.1
}
}, {
face = 'nocull',
tex = 1,
points = {
0.9, 0.9, 0.1, 1, 0.5,
0.9, 0, 0.1, 1, 1,
0.1, 0, 0.9, 0, 1,
0.1, 0.9, 0.9, 0, 0.5,
0.9, 1.8, 0.1, 1, 0,
0.9, 0.9, 0.1, 1, 0.5,
0.1, 0.9, 0.9, 0, 0.5,
0.1, 1.8, 0.9, 0, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = wave_amplitude
},
mesh_mod = {
type = 'offset',
scale = 0.1
}
}, {
face = 'nocull',
tex = 1,
points = {
0.1, 0, 0.9, 0, 1,
0.9, 0, 0.1, 1, 1,
0.9, 0.9, 0.1, 1, 0.5,
0.1, 0.9, 0.9, 0, 0.5,
0.1, 0.9, 0.9, 0, 0.5,
0.9, 0.9, 0.1, 1, 0.5,
0.9, 1.8, 0.1, 1, 0,
0.1, 1.8, 0.9, 0, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = wave_amplitude
},
mesh_mod = {
type = 'offset',
scale = 0.1
}
}
}
})

View File

@ -6,4 +6,5 @@ require './block_slab'
require './block_slab_foliage'
require './leaf_like'
require './cross_plant'
require './cross_plant_tall'
require './pillar'

View File

@ -17,6 +17,7 @@ _G['format'] = function(val, nl, idn)
if nl == nil then nl = 3 end
if type(val) == 'function' or type(val) == 'userdata' or type(val) == 'thread' then return tostring(val) end
if type(val) == 'boolean' then return val and 'true' or 'false' end
if type(val) == 'string' then return '"' .. val .. '"' end
if type(val) == 'nil' then return 'nil' end
if type(val) == 'table' then

View File

@ -1,7 +1,7 @@
zepha.__builtin.gui_env = { Gui = {}}
zepha.Gui = zepha.__builtin.gui_env.Gui
local env = zepha.__builtin.gui_env
setmetatable(env, {__index = _G})
setmetatable(env, { __index = _G })
-- create_element
-- Build a GUI Element with the provided constructor data, apply the metatable.

View File

@ -62,7 +62,6 @@ zepha.deserialize = function(str, opt, path, table_refs)
local tbl = {}
str = str:sub(2, #str - 1):trim()
-- print(path, tbl)
table_refs[path] = tbl
while #str > 0 do

View File

@ -1,4 +1,17 @@
-- Performs a shallow copy of a table.
function table.clone(tbl)
return { table.unpack(tbl) }
local new = {}
for k, v in pairs(tbl) do new[k] = v end
return new
end
-- Merges two tables together
function table.merge(...)
local new = {}
for i, tbl in ipairs(table.pack(...)) do
if type(tbl) == 'table' then
for k, v in pairs(tbl) do new[k] = v end
end
end
return new
end

View File

@ -6,13 +6,14 @@
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image.h>
#include <stb_image_write.h>
#pragma clang diagnostic pop
#include "StartGame.h"
/*
* Zepha, designed, developed, and created by Nicole Collings
* Zepha, designed, developed, and created by Auri Collings
* This is my child, and I hope you like it.
* Copyright 2018 - present Auri Collings, All Rights Reserved.
*/

View File

@ -115,7 +115,7 @@ void DebugDisplay::update(sptr<LocalPlayer> player, f64 delta, u32 interpolatedC
// Textual information
vec3 playerPos = glm::floor(player->getPos());
ivec3 playerPos = glm::floor(player->getPos());
vec3 chunkPos = Space::Chunk::world::fromBlock(playerPos);
vec3 mapBlockPos = Space::MapBlock::world::fromChunk(chunkPos);
vec3 regionPos = Space::Region::world::fromChunk(chunkPos);

View File

@ -14,6 +14,36 @@ TextureAtlas::TextureAtlas(uvec2 size) :
atlasData(size.x * 4 * size.y),
maxTextureSlots(canvasTileSize.x * canvasTileSize.y),
empty(canvasTileSize.x * canvasTileSize.y, true) {
/**
* Rect Function.
* Creates a rectangular image with the color specified.
*
* @param w - The width of the rect.
* @param h - The height of the rect.
* @param fill - The color to fill the rectangle with.
*/
parser.addFn<u16, u16, string>("rect", [](u16 w, u16 h, string hex) {
vec4 color = Util::hexToColorVec(hex);
vec<u8> newData(w * h * 4);
for (u32 i = 0; i < w * h * 4; i++) newData[i] = color[i % 4] * 255;
return TexParserData { std::make_shared<RawTexData>(newData, uvec2 { w, h }) };
});
/**
* Alpha Function.
* Adjusts the opacity of the provided image by a factor.
*
* @param factor - The factor that the opacity should be scaled by. 0 = transparent, 1 = opaque.
* @param tex - The texture to scale the alpha of.
*/
parser.addFn<f32, TexParserData>("alpha", [](f32 factor, TexParserData tex) {
for (u32 i = 0; i < tex.data->size.x * tex.data->size.y; i++)
tex.data->data[i * 4 + 3] = (tex.data->data[i * 4 + 3] / 255.f * factor) * 255;
return tex;
});
/**
* Crop Function.
@ -35,7 +65,7 @@ TextureAtlas::TextureAtlas(uvec2 size) :
tex.data->size = { w, h };
return tex;
});
/**
* Multiply Function.
* Multiplies the texture by the specified color.
@ -53,6 +83,49 @@ TextureAtlas::TextureAtlas(uvec2 size) :
return tex;
});
/**
* Stack function. ()
* Stacks the provided textures on top of each other, blending partially opaque pixels.
* Requires at least two textures. The maximum is currently eight textures,
* however that could be removed later with some tweaks to StringParser.
*
* @param b - The base texture to stack onto.
* @param s1 - A texture to stack on top of the base texture.
* @param s2 - Another texture to stack on top of s1.
* @param s3 - ...
*/
parser.addFn<TexParserData, TexParserData, optional<TexParserData>,
optional<TexParserData>, optional<TexParserData>, optional<TexParserData>,
optional<TexParserData>, optional<TexParserData>, optional<TexParserData>>("", [](
TexParserData b, TexParserData s1, optional<TexParserData> s2,
optional<TexParserData> s3, optional<TexParserData> s4, optional<TexParserData> s5,
optional<TexParserData> s6, optional<TexParserData> s7, optional<TexParserData> s8) {
vec<TexParserData> stack;
stack.reserve(8);
stack.emplace_back(s1);
if (s2) stack.emplace_back(*s2);
if (s3) stack.emplace_back(*s3);
if (s4) stack.emplace_back(*s4);
if (s5) stack.emplace_back(*s5);
if (s6) stack.emplace_back(*s6);
if (s7) stack.emplace_back(*s7);
if (s8) stack.emplace_back(*s8);
for (const let& s : stack) {
for (u32 i = 0; i < b.data->size.x * b.data->size.y; i++) {
const f32 factor = s.data->data[i * 4 + 3] / 255.f;
b.data->data[i * 4] = b.data->data[i * 4] * (1 - factor) + s.data->data[i * 4] * factor;
b.data->data[i * 4 + 1] = b.data->data[i * 4 + 1] * (1 - factor) + s.data->data[i * 4 + 1] * factor;
b.data->data[i * 4 + 2] = b.data->data[i * 4 + 2] * (1 - factor) + s.data->data[i * 4 + 2] * factor;
b.data->data[i * 4 + 3] = std::min((u16)(b.data->data[i * 4 + 3]) + s.data->data[i * 4 + 3], 255);
}
}
return b;
});
/**
* Literal Function.
* Converts raw strings to texture data by indexing the atlas.

View File

@ -11,6 +11,9 @@ class AtlasRef;
class TextureAtlas {
public:
struct RawTexData {
RawTexData(const vec<u8>& data, const uvec2& size):
data(data), size(size) {};
vec<u8> data;
uvec2 size;
};

View File

@ -17,5 +17,8 @@ enum class MeshMod {
NONE = 0,
OFFSET_X,
OFFSET_Y,
OFFSET_Z
OFFSET_Z,
ROTATE_X,
ROTATE_Y,
ROTATE_Z
};

View File

@ -73,11 +73,17 @@ namespace RegisterBiome {
auto noiseList = biomeTable.get<sol::optional<sol::table>>("noise");
if (noiseList) {
let heightTable = noiseList->get<sol::optional<sol::table>>("heightmap");
if (heightTable) heightmap = NoiseFromLua::parse(*heightTable);
let heightObj = noiseList->get<sol::object>("heightmap");
if (heightObj.is<sol::table>()) heightmap =
NoiseFromLua::parse(heightObj.as<sol::table>());
else if (heightObj.is<string>()) heightmap =
FastNoise::NewFromEncodedNodeTree(heightObj.as<string>().data());
let volumeTable = noiseList->get<sol::optional<sol::table>>("volume");
if (volumeTable) volume = NoiseFromLua::parse(*volumeTable);
let volumeObj = noiseList->get<sol::object>("volume");
if (volumeObj.is<sol::table>()) volume =
NoiseFromLua::parse(volumeObj.as<sol::table>());
else if (volumeObj.is<string>()) volume =
FastNoise::NewFromEncodedNodeTree(volumeObj.as<string>().data());
}
std::vector<std::shared_ptr<Structure>> schematics {};

View File

@ -110,6 +110,12 @@ namespace RegisterBlock {
model.meshMods.emplace_back(MeshMod::OFFSET_Y, modTable.get_or<float>("amplitude", 1));
else if (meshMod == "offset_z")
model.meshMods.emplace_back(MeshMod::OFFSET_Z, modTable.get_or<float>("amplitude", 1));
else if (meshMod == "rotate_x")
model.meshMods.emplace_back(MeshMod::ROTATE_X, modTable.get_or<float>("amplitude", 1));
else if (meshMod == "rotate_y")
model.meshMods.emplace_back(MeshMod::ROTATE_Y, modTable.get_or<float>("amplitude", 1));
else if (meshMod == "rotate_z")
model.meshMods.emplace_back(MeshMod::ROTATE_Z, modTable.get_or<float>("amplitude", 1));
}
}

View File

@ -34,6 +34,7 @@ void ServerClients::handleDisconnect(ENetEvent e) {
void ServerClients::createPlayer(sptr<ServerClient> client, DimensionPtr dimension) {
client->player = make_shared<ServerPlayer>(*client, dimension->getWorld(), game, dimension);
client->player->setPos({ 0, 64, 0 });
game.s()->getParser().playerConnected(client->player);
// client->player->setPos({ 256, -20, 256 }, true);

View File

@ -1,70 +1,63 @@
//
// Created by aurailus on 2019-11-12.
//
#include <glm/glm.hpp>
#include <stb_image_write.h>
#include "Voronoi3D.h"
Voronoi3D::Voronoi3D(unsigned short size) :
size(size),
data(voronoi_data(size)) {
for (unsigned short i = 0; i < size; i++) {
data[i].resize(size);
for (unsigned short j = 0; j < size; j++) {
data[i][j].resize(size);
}
}
#include "util/Space.h"
Voronoi3D::Voronoi3D(u16 size) : size(size), data(pow(size, 3)) {}
Voronoi3D::Voronoi3D(u16 size, const vec<VoronoiPoint>& data) : size(size), data(pow(size, 3)), points(data) {
generate();
}
void Voronoi3D::setPoints(const std::vector<std::pair<glm::vec3, unsigned short>>& points) {
this->points = points;
for (unsigned short i = 0; i < size; i++) {
for (unsigned short j = 0; j < size; j++) {
for (unsigned short k = 0; k < size; k++) {
float pointDistance = INFINITY;
unsigned short ind = 0;
for (auto& point : points) {
float thisPointDistance = glm::distance(point.first, { i, j, k });
if (thisPointDistance < pointDistance) {
pointDistance = thisPointDistance;
ind = point.second;
}
}
data[i][j][k] = ind;
void Voronoi3D::setData(const vec<VoronoiPoint>& data) {
this->points = data;
generate();
}
void Voronoi3D::generate() {
for (u32 i = 0; i < pow(size, 3); i++) {
const u16vec3 pos = Space::indexToPos(i, size);
f32 pointDistance = INFINITY;
u16 currentInd = 0;
for (u32 j = 0; j < points.size(); j++) {
f32 thisPointDistance = glm::distance(vec3(points[j].pos), vec3(pos));
if (thisPointDistance < pointDistance) {
pointDistance = thisPointDistance;
currentInd = j;
}
}
data[i] = currentInd;
}
}
unsigned short Voronoi3D::getPoint(unsigned short x, unsigned short y, unsigned short z) {
return data[x][y][z];
unsigned short Voronoi3D::operator[](u32 ind) {
return points[data[ind]].data;
}
unsigned short Voronoi3D::operator[](u16vec3 pos) {
return operator[](Space::posToIndex(pos, size));
}
//void Voronoi3D::setColorValues(const std::vector<glm::vec3>& values) {
// colorValues = values;
//}
void Voronoi3D::outputImage(u16 yCount) {
vec<u8> colorData(pow(size, 2) * 3);
//void Voronoi3D::generateImage(unsigned short depth) {
// auto colorData = new unsigned char[size * size * 3];
//
// for (int i = 0; i < size * size; i++) {
// int x = i % size;
// int y = i / size;
//
// unsigned short point = data[x][y][depth];
// auto color = colorValues[point];
//
// colorData[i * 3 + 0] = static_cast<int>(color.x * 255.f);
// colorData[i * 3 + 1] = static_cast<int>(color.y * 255.f);
// colorData[i * 3 + 2] = static_cast<int>(color.z * 255.f);
// }
//
// std::string name = "voronoi_";
// name += std::to_string(depth) + ".jpg";
// stbi_write_jpg(name.data(), size, size, 3, colorData, 100);
//}
for (u32 i = 0; i < yCount; i++) {
for (u32 j = 0; j < pow(size, 2); j++) {
u16 x = j % size;
u16 z = j / size;
vec3 color = points[data[Space::posToIndex(
{ x, floor(static_cast<f32>(i) / (yCount - 1) * (size - 1)), z }, size)]].color;
colorData[j * 3 + 0] = static_cast<u8>(color.x * 255);
colorData[j * 3 + 1] = static_cast<u8>(color.y * 255);
colorData[j * 3 + 2] = static_cast<u8>(color.z * 255);
}
string name = "voronoi_" + std::to_string(i) + ".jpg";
stbi_write_jpg(name.data(), size, size, 3, colorData.data(), 100);
}
}

View File

@ -1,29 +1,54 @@
//
// Created by aurailus on 2019-11-12.
//
#pragma once
#include <vector>
#include <glm/vec3.hpp>
#include "util/Types.h"
/**
* Creates a three-dimensional voronoi diagram which can be
* sampled to find the nearest point to a given position.
*/
class Voronoi3D {
public:
public:
/** Represents a point of data in the voronoi map. */
struct VoronoiPoint {
VoronoiPoint(u16vec3 pos, u16 data): pos(pos), data(data) {}
VoronoiPoint(u16vec3 pos, u16 data, vec3 color): pos(pos), data(data), color(color) {}
u16vec3 pos;
u16 data;
vec3 color;
};
Voronoi3D() = default;
Voronoi3D(unsigned short size);
explicit Voronoi3D(u16 size);
void setPoints(const std::vector<std::pair<glm::vec3, unsigned short>>& points);
Voronoi3D(u16 size, const vec<VoronoiPoint>& data);
unsigned short getPoint(unsigned short x, unsigned short y, unsigned short z);
/** Sets the data to the points specified and generates the map. */
void setData(const vec<VoronoiPoint>& data);
/** Retrieves a point data value at the specified index. */
u16 operator[](u32 ind);
/** Retrieves a point data value at the specified position. */
u16 operator[](u16vec3 pos);
// void setColorValues(const std::vector<glm::vec3>& values);
// void generateImage(unsigned short depth);
private:
typedef std::vector<std::vector<std::vector<unsigned short>>> voronoi_data;
/** Outputs a debug image into the working directory, with the number of layers specified by yCount. */
void outputImage(u16 yCount);
unsigned short size;
voronoi_data data;
std::vector<std::pair<glm::vec3, unsigned short>> points;
// std::vector<glm::vec3> colorValues;
private:
/** Generates the voronoi diagram. */
void generate();
/** The size of one axis of the voronoi map. */
u16 size;
/** A 3d grid of data corresponding to VoronoiPoint indices. */
vec<u16> data;
/** The voronoi points that the map was generated with. */
vec<VoronoiPoint> points;
};

View File

@ -1,5 +1,4 @@
#include <random>
#include <iostream>
#include "MapGen.h"
@ -33,7 +32,7 @@ MapGen::MapGen(Subgame& game, World& world, u32 seed, std::unordered_set<string>
let biomeScale = FastNoise::New<FastNoise::DomainScale>();
biomeScale->SetSource(biomePerlin);
biomeScale->SetScale(1/1000.f);
biomeScale->SetScale(1/2000.f);
let biomeFractal = FastNoise::New<FastNoise::FractalFBm>();
biomeFractal->SetSource(biomeScale);
@ -55,8 +54,8 @@ std::unique_ptr<MapGen::ChunkMap> MapGen::generateArea(u16 dim, ivec3 origin, u1
Job job(origin, size);
job.temperature.generate({ job.pos.x * 16, 0, job.pos.z * 16 }, biomeGenerator);
job.roughness.generate({ job.pos.x * 16, 0, job.pos.z * 16 }, biomeGenerator);
job.humidity.generate({ job.pos.x * 16, 0, job.pos.z * 16 }, biomeGenerator);
job.roughness.generate(ivec3 { job.pos.x * 16, 0, job.pos.z * 16 } + ivec3(2000), biomeGenerator);
job.humidity.generate(ivec3 { job.pos.x * 16, 0, job.pos.z * 16 } + ivec3(-2000), biomeGenerator);
let biomeMap = vec<u16>(pow(job.size * 16 + 1, 2));
u16vec3 bPos {};
@ -108,25 +107,25 @@ std::unique_ptr<MapGen::ChunkMap> MapGen::generateArea(u16 dim, ivec3 origin, u1
}
void MapGen::generateVoronoi(const std::unordered_set<u16>& biomes) {
vec<std::pair<vec3, u16>> points {};
vec<Voronoi3D::VoronoiPoint> points {};
for (auto biomeInd : biomes) {
auto& biome = game.getBiomes().biomeFromId(biomeInd);
points.emplace_back(vec3 {
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, (biome.temperature + 1) / 2 * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, biome.humidity * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, biome.roughness * voronoiSize)))
}, biomeInd);
}, biomeInd, biome.tint);
}
voronoi.setPoints(points);
voronoi.setData(points);
voronoi.outputImage(8);
}
u16 MapGen::getBiomeAt(f32 temperature, f32 humidity, f32 roughness) {
return voronoi.getPoint(
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, (temperature + 1) / 2 * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, humidity * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, roughness * voronoiSize))));
return voronoi[{
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, (temperature + 1) / 2 * (voronoiSize - 1)))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, (humidity + 1) / 2 * (voronoiSize - 1)))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, (roughness + 1) / 2 * (voronoiSize - 1))))
}];
}
uptr<MapGen::ChunkData> MapGen::populateChunkDensity(MapGen::Job& job, ivec3 localPos) {

Binary file not shown.

View File

@ -8,6 +8,5 @@ require './cactus'
require './sand'
require './sandstone'
require './stone'
require './tallgrass'
require './wood'
require './light'

View File

@ -1,28 +0,0 @@
for i = 1, 5, 1 do
zepha.register_block(":tall_grass_" .. i, {
name = "Tall Grass",
culls = false,
solid = false,
model = "zepha:base:cross_plant",
textures = { "tint(0, zeus:default:tallgrass_"..i..")" },
lowdef_render = false,
selection_box = {{1/16, 0, 1/16, 15/16, 0.30 + i * 0.1, 15/16}},
tool_props = {
health = 5,
multipliers = {
snap = 1.8,
grab = 1.2,
_other = 0.35
}
},
light_propagates = true,
yields = function(pos)
if math.random() > 0.8 then return "zeus:materials:plant_fibre" end
end
})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

View File

@ -1,10 +0,0 @@
{
"name": "Flowers",
"identifier": "zeus:flowers",
"description": "Flowers and vegitation for the Zeus subgame.",
"version": "0.0.1",
"main": "main",
"dependencies": {
"zeus:default": "^0"
}
}

View File

@ -1,60 +0,0 @@
local flowers = {
"rose",
"tulip",
"viola",
"geranium",
"red_mushroom",
"brown_mushroom",
"white_dandelion",
"yellow_dandelion"
}
local titlecase = function(first, rest) return first:upper()..rest:lower() end
for _,flower in pairs(flowers) do
local name = flower:gsub("_", " "):gsub("(%a)([%w_']*)", titlecase)
zepha.register_block("zeus:flowers:flower_" .. flower, {
culls = false,
solid = false,
name = name,
model = "zepha:base:cross_plant",
textures = {
"zeus:flowers:" .. flower
},
light_propagates = true,
lowdef_render = false,
selection_box = {
{ 4/16, 0, 4/16, 12/16, 14/16, 12/16 }
},
toughness = {
hand = 0
}
})
end
require './models/hash'
zepha.register_block("zeus:flowers:clover", {
name = "Clover",
culls = false,
solid = false,
model = "zeus:flowers:hash",
textures = {
"tint(0, crop(0, 0, 16, 16, zeus:flowers:clover))",
"tint(0, crop(16, 0, 16, 16, zeus:flowers:clover))",
"tint(0, crop(32, 0, 16, 16, zeus:flowers:clover))",
"tint(0, crop(0, 16, 16, 8, zeus:flowers:clover))",
"tint(0, crop(16, 16, 16, 8, zeus:flowers:clover))",
"tint(0, crop(0, 24, 16, 8, zeus:flowers:clover))",
"tint(0, crop(16, 24, 16, 8, zeus:flowers:clover))"
},
light_propagates = true,
lowdef_render = false,
selection_box = {
{1/16, 0, 1/16, 15/16, 4/16, 15/16}
},
toughness = {
hand = 0
}
})

View File

@ -1 +0,0 @@
require './flowers'

View File

@ -1,116 +0,0 @@
--
-- A flower blockmodel that is a short hash similar to wheat in Minecraft,
-- with multiple layers of topfaces.
--
local offset_amp = 0.2
local amp = 0.025
zepha.register_blockmodel('zeus:flowers:hash', {
mesh_mods = {
{
type = 'offset_x',
amplitude = offset_amp,
},
{
type = 'offset_z',
amplitude = offset_amp,
}
},
parts = {
{
face = 'nocull',
tex = 4,
points = {
4/16, 0, 0, 0, 1,
4/16, 0, 1, 1, 1,
4/16, 0.5, 1, 1, 0,
4/16, 0.5, 0, 0, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = amp
}
}, {
face = 'nocull',
tex = 5,
points = {
12/16, 0.5, 1, 0, 0,
12/16, 0, 1, 0, 1,
12/16, 0, 0, 1, 1,
12/16, 0.5, 0, 1, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = amp
}
}, {
face = 'nocull',
tex = 5,
points = {
0, 0, 12/16, 0, 1,
1, 0, 12/16, 1, 1,
1, 0.5, 12/16, 1, 0,
0, 0.5, 12/16, 0, 0
},
shader_mod = {
type = 'sway_attached',
amplitude = amp
}
}, {
face = 'nocull',
tex = 6,
points = {
0, 0, 4/16, 1, 1,
0, 0.5, 4/16, 1, 0,
1, 0.5, 4/16, 0, 0,
1, 0, 4/16, 0, 1
},
shader_mod = {
type = 'sway_attached',
amplitude = amp
}
}, {
face = 'nocull',
tex = 1,
points = {
0, 4/16, 0, 0, 0,
0, 4/16, 1, 0, 1,
1, 4/16, 1, 1, 1,
1, 4/16, 0, 1, 0
},
shader_mod = {
type = 'sway_full_block',
amplitude = amp
}
},
{
face = 'nocull',
tex = 2,
points = {
0, 3/16, 0, 0, 0,
0, 3/16, 1, 0, 1,
1, 3/16, 1, 1, 1,
1, 3/16, 0, 1, 0
},
shader_mod = {
type = 'sway_full_block',
amplitude = amp
}
},
{
face = 'nocull',
tex = 3,
points = {
0, 2/16, 0, 0, 0,
0, 2/16, 1, 0, 1,
1, 2/16, 1, 1, 1,
1, 2/16, 0, 1, 0
},
shader_mod = {
type = 'sway_full_block',
amplitude = amp
}
}
}
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

View File

@ -0,0 +1,10 @@
{
"name": "Vegetation",
"identifier": "zeus:vegetation",
"description": "Vegetation for the Zeus subgame.",
"version": "0.0.1",
"main": "main",
"dependencies": {
"zeus:default": "^0"
}
}

View File

@ -0,0 +1,74 @@
require './models/clover'
local selection_box_flower = {
{ 4/16, 0, 4/16, 12/16, 14/16, 12/16 }
}
local selection_box_grass = {
{ 2/16, 0, 2/16, 14/16, 7/16, 14/16 }
}
local function title_case(str)
local tf = function(first, rest) return first:upper()..rest:lower() end
return str:gsub('_', ' '):gsub("(%a)([%w_']*)", tf)
end
local function register_vegetation(identifier, override)
zepha.register_block(':' .. identifier, table.merge({
culls = false,
solid = false,
lowdef_render = false,
light_propagates = true,
toughness = { hand = 0 },
name = title_case(identifier),
model = 'zepha:base:cross_plant',
selection_box = selection_box_flower,
textures = { 'zeus:vegetation:' .. identifier }
}, override or {}))
end
register_vegetation('rose')
register_vegetation('tulip')
register_vegetation('viola')
register_vegetation('purple')
register_vegetation('geranium')
register_vegetation('dandelion_white', { name = 'White Dandelion' })
register_vegetation('dandelion_yellow', { name = 'Yellow Dandelion' })
register_vegetation('tall_blue', { model = 'zepha:base:cross_plant_tall' })
register_vegetation('mushroom_red', { name = 'Red Mushroom', model = 'zepha:base:cross_large' })
register_vegetation('mushroom_glow', { name = 'Glow Mushroom', model = 'zepha:base:cross_large' })
register_vegetation('mushroom_brown', { name = 'Brown Mushroom', model = 'zepha:base:cross_large' })
register_vegetation('clover', {
model = 'zeus:vegetation:clover',
textures = {
'tint(0, crop(0, 0, 16, 16, zeus:vegetation:clover))',
'tint(0, crop(16, 0, 16, 16, zeus:vegetation:clover))'
},
selection_box = {
{ 1/16, 0, 1/16, 15/16, 4/16, 15/16 }
}
})
local grass_def = {
name = 'Tall Grass',
model = 'zepha:base:cross_plant',
selection_box = selection_box_grass,
tool_props = {
health = 5,
multipliers = {
snap = 1.8,
grab = 1.2,
_other = 0.35
}
},
yields = function(pos)
if math.random() > 0.8 then return 'zeus:materials:plant_fibre' end
end
}
register_vegetation('tall_grass_1', table.merge(grass_def, { textures = { 'tint(0, zeus:vegetation:tall_grass_1)' }}))
register_vegetation('tall_grass_2', table.merge(grass_def, { textures = { 'tint(0, zeus:vegetation:tall_grass_2)' }}))
register_vegetation('tall_grass_3', table.merge(grass_def, { textures = { 'tint(0, zeus:vegetation:tall_grass_3)' }}))
register_vegetation('tall_grass_4', table.merge(grass_def, { textures = { 'tint(0, zeus:vegetation:tall_grass_4)' }}))
register_vegetation('tall_grass_5', table.merge(grass_def, { textures = { 'tint(0, zeus:vegetation:tall_grass_5)' }}))

View File

@ -0,0 +1,50 @@
local amp_offset_h = 3/16
local amp_offset_v = 1/16
local amp_sway = 0.025
zepha.register_blockmodel('zeus:vegetation:clover', {
mesh_mods = {
{
type = 'offset_x',
amplitude = amp_offset_h,
},
{
type = 'offset_y',
amplitude = amp_offset_v,
},
{
type = 'offset_z',
amplitude = amp_offset_h,
}
},
parts = {
{
face = 'nocull',
tex = 1,
points = {
0, 2.5/16, 0, 0, 0,
0, 2.5/16, 1, 0, 1,
1, 2.5/16, 1, 1, 1,
1, 2.5/16, 0, 1, 0
},
shader_mod = {
type = 'sway_full_block',
amplitude = amp_sway
}
},
{
face = 'nocull',
tex = 2,
points = {
0, 1.5/16, 0, 0, 0,
0, 1.5/16, 1, 0, 1,
1, 1.5/16, 1, 1, 1,
1, 1.5/16, 0, 1, 0
},
shader_mod = {
type = 'sway_full_block',
amplitude = amp_sway
}
}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 370 B

After

Width:  |  Height:  |  Size: 370 B

View File

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 453 B

View File

Before

Width:  |  Height:  |  Size: 609 B

After

Width:  |  Height:  |  Size: 609 B

View File

Before

Width:  |  Height:  |  Size: 533 B

After

Width:  |  Height:  |  Size: 533 B

View File

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

View File

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 334 B

View File

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

View File

@ -6,7 +6,7 @@
"main": "main",
"dependencies": {
"zeus:default": "^0",
"zeus:flowers": "^0",
"zeus:vegetation": "^0",
"@auri:hot_wheel": "^0"
}
}

View File

@ -1,70 +1,70 @@
-- local identifier = "zeus:world:desert"
--
-- local structures = {}
--
-- table.insert(structures, zepha.create_structure({
-- origin = V(),
-- probability = 0.001,
-- layout = {{{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}}
-- }))
--
-- table.insert(structures, zepha.create_structure({
-- origin = V(),
-- probability = 0.001,
-- layout = {{{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}}
-- }))
--
-- table.insert(structures, zepha.create_structure({
-- origin = V(),
-- probability = 0.001,
-- layout = {{{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}}
-- }))
--
-- local noise = {
-- -- heightmap = runfile(_PATH .. 'world_noise')
-- -- heightmap = {
-- -- module = "add",
-- -- sources = {{
-- -- module = "min",
-- -- sources = {{
-- -- module = "turbulence",
-- -- power = 1,
-- -- frequency = 0.3,
-- -- source = {
-- -- module = "add",
-- -- sources = {{
-- -- -- Elevation
-- -- module = "scale_bias",
-- -- source = {
-- -- module = "spheres",
-- -- frequency = 0.2
-- -- },
-- -- scale = 20
-- -- }, {
-- -- -- Features
-- -- module = "scale_bias",
-- -- source = {
-- -- module = "perlin",
-- -- frequency = 0.1,
-- -- octaves = 6,
-- -- },
-- -- scale = 8
-- -- }}
-- -- }
-- -- }, {
-- -- module = "scale_bias",
-- -- scale = 1,
-- -- bias = 1000,
-- -- source = {
-- -- module = "perlin",
-- -- frequency = 0.2
-- -- }
-- -- }}
-- -- }, {
-- -- module = "const",
-- -- value = -40
-- -- }}
-- -- }
local identifier = "zeus:world:desert"
local structures = {}
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.001,
layout = {{{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.001,
layout = {{{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.001,
layout = {{{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}, {{ "zeus:default:cactus" }}}
}))
local noise = {
-- heightmap = runfile(_PATH .. 'world_noise')
-- heightmap = {
-- module = "add",
-- sources = {{
-- module = "min",
-- sources = {{
-- module = "turbulence",
-- power = 1,
-- frequency = 0.3,
-- source = {
-- module = "add",
-- sources = {{
-- -- Elevation
-- module = "scale_bias",
-- source = {
-- module = "spheres",
-- frequency = 0.2
-- },
-- scale = 20
-- }, {
-- -- Features
-- module = "scale_bias",
-- source = {
-- module = "perlin",
-- frequency = 0.1,
-- octaves = 6,
-- },
-- scale = 8
-- }}
-- }
-- }, {
-- module = "scale_bias",
-- scale = 1,
-- bias = 1000,
-- source = {
-- module = "perlin",
-- frequency = 0.2
-- }
-- }}
-- }, {
-- module = "const",
-- value = -40
-- }}
-- }
-- volume = {
-- module = "scale",
-- y_scale = 2,
@ -83,23 +83,24 @@
-- }
-- }
-- }
-- }
--
-- zepha.register_biome(identifier, {
-- environment = {
-- temperature = 40/100,
-- humidity = 20/100,
-- roughness = 10/100
-- },
-- blocks = {
-- top = "zeus:default:sand",
-- soil = "zeus:default:sand",
-- rock = "zeus:default:sandstone"
-- },
-- tags = { natural = 1, default = 1 },
-- biome_tint = "#e6fa61",
-- noise = noise,
-- structures = structures
-- })
--
-- return identifier;
volume = require './world_noise'
}
zepha.register_biome(identifier, {
environment = {
temperature = 50/100,
humidity = 0/100,
roughness = 0/100
},
blocks = {
top = "zeus:default:sand",
soil = "zeus:default:sand",
rock = "zeus:default:sandstone"
},
tags = { natural = 1, default = 1 },
biome_tint = "#e6fa61",
noise = noise,
structures = structures
})
return identifier;

View File

@ -22,40 +22,46 @@ local structures = {}
for i = 1, 5 do
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.025,
layout = {{{ "zeus:default:tall_grass_" .. tostring(i) }}}
probability = 0.025 * (i / 3),
layout = {{{ "zeus:vegetation:tall_grass_" .. tostring(i) }}}
}))
end
--
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.05,
layout = {{{ "zeus:flowers:flower_red_mushroom" }}}
probability = 0.025,
layout = {{{ "zeus:vegetation:mushroom_glow" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.15,
layout = {{{ "zeus:vegetation:geranium" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.05,
layout = {{{ "zeus:flowers:flower_brown_mushroom" }}}
layout = {{{ "zeus:vegetation:tall_blue" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(1),
probability = 0.1,
layout = {{
{ none, none, none },
{ none, wood, none },
{ none, none, none }
}, {
{ none, leaf, none },
{ leaf, wood, leaf },
{ none, leaf, none }
}, {
{ none, none, none },
{ none, leaf, none },
{ none, none, none }
}}
}))
-- table.insert(structures, zepha.create_structure({
-- origin = V(1),
-- probability = 0.1,
-- layout = {{
-- { none, none, none },
-- { none, wood, none },
-- { none, none, none }
-- }, {
-- { none, leaf, none },
-- { leaf, wood, leaf },
-- { none, leaf, none }
-- }, {
-- { none, none, none },
-- { none, leaf, none },
-- { none, none, none }
-- }}
-- }))
local woo = "zeus:default:wood"
local lea = "zeus:default:leaves"
@ -111,15 +117,15 @@ local leaf_layer_3 = {
table.insert(structures, zepha.create_structure({
origin = V(2, 2, 2),
probability = 0.01,
probability = 0.02,
layout = {
trunk_layer_0,
trunk_layer_0,
trunk_layer_0,
trunk_layer_0,
trunk_layer_1,
trunk_layer_1,
trunk_layer_1,
-- trunk_layer_0,
-- trunk_layer_0,
-- trunk_layer_0,
-- trunk_layer_0,
-- trunk_layer_1,
-- trunk_layer_1,
-- trunk_layer_1,
trunk_layer_2,
trunk_layer_2,
trunk_layer_2,
@ -141,42 +147,49 @@ table.insert(structures, zepha.create_structure({
}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.55,
layout = {{{ "zeus:vegetation:clover" }}}
}))
local noise = {
-- heightmap = runfile(_PATH .. 'world_noise'),
heightmap = {
module = "add",
sources = {
require('./world_noise'),
{
module = "max",
smoothness = 50,
scalar = 0,
source = {
module = "add",
scalar = -50,
source = {
module = "multiply",
scalar = 400,
source = {
module = "simplex",
frequency = 0.00025,
lacunarity = 2.5,
octaves = 8,
persistence = 0.55
}
}
}
}
}
}
-- heightmap = {
-- module = "add",
-- sources = {
-- require './world_noise',
-- {
-- module = "max",
-- smoothness = 50,
-- scalar = 0,
-- source = {
-- module = "add",
-- scalar = -50,
-- source = {
-- module = "multiply",
-- scalar = 400,
-- source = {
-- module = "simplex",
-- frequency = 0.00025,
-- lacunarity = 2.5,
-- octaves = 8,
-- persistence = 0.55
-- }
-- }
-- }
-- }
-- }
-- }
volume = require './world_noise'
}
zepha.register_biome(identifier, {
environment = {
temperature = 25/100,
humidity = 70/100,
roughness = 20/100,
humidity = 100/100,
roughness = 60/100,
},
blocks = {
top = "zeus:default:grass",

View File

@ -16,7 +16,7 @@ local structures = {}
-- probability = 0.1,
-- -- origin = V{1, 1, 1},
-- origin = V(),
-- layout = {{{ "zeus:flowers:flower_geranium" }}}
-- layout = {{{ "zeus:vegetation:geranium" }}}
-- }))
table.insert(structures, zepha.create_structure({
@ -121,58 +121,60 @@ table.insert(structures, zepha.create_structure({
}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.1,
layout = {{{ "zeus:vegetation:purple" }}}
}))
for i = 1, 5 do
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.05,
layout = {{{ "zeus:default:tall_grass_" .. tostring(i) }}}
layout = {{{ "zeus:vegetation:tall_grass_" .. tostring(i) }}}
}))
end
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.55,
layout = {{{ "zeus:flowers:clover" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.0125,
layout = {{{ "zeus:flowers:flower_geranium" }}}
layout = {{{ "zeus:vegetation:clover" }}}
}))
table.insert(structures, zepha.create_structure({
origin = V(),
probability = 0.0125,
layout = {{{ "zeus:flowers:flower_white_dandelion" }}}
probability = 0.05,
layout = {{{ "zeus:vegetation:dandelion_white" }}}
}))
local noise = {
heightmap = {
module = "add",
sources = {
require('./world_noise'),
{
module = "max",
smoothness = 50,
scalar = 0,
source = {
module = "add",
scalar = -50,
source = {
module = "multiply",
scalar = 400,
source = {
module = "simplex",
frequency = 0.00025,
lacunarity = 2.5,
octaves = 8,
persistence = 0.55
}
}
}
}
}
}
-- heightmap = {
-- module = "add",
-- sources = {
-- require('./world_noise'),
-- {
-- module = "max",
-- smoothness = 50,
-- scalar = 0,
-- source = {
-- module = "add",
-- scalar = -50,
-- source = {
-- module = "multiply",
-- scalar = 400,
-- source = {
-- module = "simplex",
-- frequency = 0.00025,
-- lacunarity = 2.5,
-- octaves = 8,
-- persistence = 0.55
-- }
-- }
-- }
-- }
-- }
-- }
volume = require './world_noise'
-- volume = {
-- module = "scale",
-- y_scale = 2,
@ -195,9 +197,9 @@ local noise = {
zepha.register_biome(identifier, {
environment = {
temperature = 15/100,
temperature = 20/100,
humidity = 60/100,
roughness = 20/100,
roughness = 40/100,
},
blocks = {
top = "zeus:default:grass",
@ -208,6 +210,9 @@ zepha.register_biome(identifier, {
structures = structures,
biome_tint = "#46cfc0",
-- biome_tint = "#aaed45",
-- biome_tint = "#80d12e",
-- biome_tint = "#54beff",
-- biome_tint = "#1f83db",
noise = noise
})

View File

@ -1,11 +1,34 @@
return {
module = "multiply",
scalar = 100,
scalar = 2500,
source = {
module = "simplex",
frequency = 0.0002,
octaves = 5,
lacunarity = 3,
persistence = 0.45
module = "add",
sources = {{
module = "multiply",
sources = {{
module = "simplex",
octaves = 4,
lacunarity = 2.65,
frequency = 0.0025
}, {
module = "add",
scalar = 0.75,
source = {
module = "multiply",
scalar = 0.75,
source = {
module = "simplex",
frequency = 0.001
}
}
}}
}, {
module = "multiply",
scalar = 0.0075,
source = {
module = "position_output",
y_factor = -1
}
}}
}
};