remove atlases - closes #975
This commit is contained in:
parent
6101bb1b53
commit
5277ad4a8c
10 changed files with 31 additions and 48 deletions
BIN
external/bgfx/lib/win64_vs2015/debug/bgfx.pdb
vendored
BIN
external/bgfx/lib/win64_vs2015/debug/bgfx.pdb
vendored
Binary file not shown.
BIN
external/bgfx/lib/win64_vs2015/release/bgfx.pdb
vendored
BIN
external/bgfx/lib/win64_vs2015/release/bgfx.pdb
vendored
Binary file not shown.
|
@ -218,16 +218,6 @@ struct MaterialPlugin : public AssetBrowser::IPlugin
|
|||
}
|
||||
}
|
||||
|
||||
if (slot.is_atlas)
|
||||
{
|
||||
int size = texture->atlas_size - 2;
|
||||
const char* values = "2x2\0" "3x3\0" "4x4\0";
|
||||
if (ImGui::Combo(StaticString<30>("Atlas size###", i), &size, values))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
texture->atlas_size = size + 2;
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -523,14 +523,17 @@ private:
|
|||
texture->onDataUpdated(m_x, m_y, m_width, m_height);
|
||||
static_cast<Lumix::RenderScene*>(m_terrain.scene)->forceGrassUpdate(m_terrain.handle);
|
||||
|
||||
Lumix::IScene* scene = m_world_editor.getUniverse()->getScene(Lumix::crc32("physics"));
|
||||
if (!scene) return;
|
||||
if (m_type != TerrainEditor::LAYER && m_type != TerrainEditor::COLOR)
|
||||
{
|
||||
Lumix::IScene* scene = m_world_editor.getUniverse()->getScene(Lumix::crc32("physics"));
|
||||
if (!scene) return;
|
||||
|
||||
auto* phy_scene = static_cast<Lumix::PhysicsScene*>(scene);
|
||||
Lumix::ComponentHandle cmp = scene->getComponent(m_terrain.entity, HEIGHTFIELD_TYPE);
|
||||
if (!Lumix::isValid(cmp)) return;
|
||||
auto* phy_scene = static_cast<Lumix::PhysicsScene*>(scene);
|
||||
Lumix::ComponentHandle cmp = scene->getComponent(m_terrain.entity, HEIGHTFIELD_TYPE);
|
||||
if (!Lumix::isValid(cmp)) return;
|
||||
|
||||
phy_scene->updateHeighfieldData(cmp, m_x, m_y, m_width, m_height, &data[0], bpp);
|
||||
phy_scene->updateHeighfieldData(cmp, m_x, m_y, m_width, m_height, &data[0], bpp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -716,8 +719,7 @@ void TerrainEditor::nextTerrainTexture()
|
|||
Lumix::Texture* tex = material->getTextureByUniform(TEX_COLOR_UNIFORM);
|
||||
if (tex)
|
||||
{
|
||||
m_texture_idx =
|
||||
Lumix::Math::minimum(tex->atlas_size * tex->atlas_size - 1, m_texture_idx + 1);
|
||||
m_texture_idx = Lumix::Math::minimum(tex->layers - 1, m_texture_idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1329,7 +1331,7 @@ void TerrainEditor::onGUI()
|
|||
Lumix::Texture* tex = getMaterial()->getTextureByUniform(TEX_COLOR_UNIFORM);
|
||||
if (tex)
|
||||
{
|
||||
for (int i = 0; i < tex->atlas_size * tex->atlas_size; ++i)
|
||||
for (int i = 0; i < tex->layers; ++i)
|
||||
{
|
||||
if (i % 4 != 0) ImGui::SameLine();
|
||||
if (ImGui::RadioButton(Lumix::StaticString<20>("", i, "###rb", i), m_texture_idx == i))
|
||||
|
|
|
@ -173,13 +173,11 @@ bool Material::save(JsonSerializer& serializer)
|
|||
{
|
||||
char path[MAX_PATH_LENGTH];
|
||||
int flags = 0;
|
||||
int atlas_size = -1;
|
||||
if (m_textures[i])
|
||||
{
|
||||
flags = m_textures[i]->bgfx_flags;
|
||||
path[0] = '/';
|
||||
Lumix::copyString(path + 1, MAX_PATH_LENGTH - 1, m_textures[i]->getPath().c_str());
|
||||
atlas_size = m_textures[i]->atlas_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -187,7 +185,6 @@ bool Material::save(JsonSerializer& serializer)
|
|||
}
|
||||
serializer.beginObject("texture");
|
||||
serializer.serialize("source", path);
|
||||
if (atlas_size > 0) serializer.serialize("atlas_size", atlas_size);
|
||||
if (flags & BGFX_TEXTURE_SRGB) serializer.serialize("srgb", true);
|
||||
if (flags & BGFX_TEXTURE_U_CLAMP) serializer.serialize("u_clamp", true);
|
||||
if (flags & BGFX_TEXTURE_V_CLAMP) serializer.serialize("v_clamp", true);
|
||||
|
@ -396,7 +393,6 @@ void Material::setTexture(int i, Texture* texture)
|
|||
|
||||
if (old_texture)
|
||||
{
|
||||
if (texture) texture->atlas_size = old_texture->atlas_size;
|
||||
removeDependency(*old_texture);
|
||||
m_resource_manager.getOwner().get(TEXTURE_TYPE)->unload(*old_texture);
|
||||
}
|
||||
|
@ -597,7 +593,6 @@ bool Material::deserializeTexture(JsonSerializer& serializer, const char* materi
|
|||
char label[256];
|
||||
bool keep_data = false;
|
||||
uint32 flags = 0;
|
||||
int atlas_size = -1;
|
||||
|
||||
while (!serializer.isObjectEnd())
|
||||
{
|
||||
|
@ -622,10 +617,6 @@ bool Material::deserializeTexture(JsonSerializer& serializer, const char* materi
|
|||
addDependency(*m_textures[m_texture_count]);
|
||||
}
|
||||
}
|
||||
else if (equalStrings(label, "atlas_size"))
|
||||
{
|
||||
serializer.deserialize(atlas_size, -1);
|
||||
}
|
||||
else if (equalStrings(label, "min_filter"))
|
||||
{
|
||||
serializer.deserialize(label, sizeof(label), "");
|
||||
|
@ -706,7 +697,6 @@ bool Material::deserializeTexture(JsonSerializer& serializer, const char* materi
|
|||
}
|
||||
if (m_textures[m_texture_count])
|
||||
{
|
||||
m_textures[m_texture_count]->atlas_size = atlas_size;
|
||||
m_textures[m_texture_count]->setFlags(flags);
|
||||
|
||||
if (keep_data)
|
||||
|
|
|
@ -2277,10 +2277,8 @@ struct PipelineImpl : public Pipeline
|
|||
Vec4 terrain_scale(info.m_terrain->getScale(), 0);
|
||||
const Mesh& mesh = *info.m_terrain->getMesh();
|
||||
|
||||
Vec4 terrain_params(info.m_terrain->getRootSize(),
|
||||
(float)detail_texture->width,
|
||||
(float)detail_texture->atlas_size,
|
||||
(float)splat_texture->width);
|
||||
Vec4 terrain_params(
|
||||
info.m_terrain->getRootSize(), (float)detail_texture->width, (float)splat_texture->width, 0);
|
||||
bgfx::setUniform(m_terrain_params_uniform, &terrain_params);
|
||||
bgfx::setUniform(m_rel_camera_pos_uniform, &rel_cam_pos);
|
||||
bgfx::setUniform(m_terrain_scale_uniform, &terrain_scale);
|
||||
|
|
|
@ -182,14 +182,6 @@ static void texture_slot(lua_State* state, const char* name, const char* uniform
|
|||
}
|
||||
|
||||
|
||||
static void atlas(lua_State* L)
|
||||
{
|
||||
auto* shader = getShader(L);
|
||||
if (!shader) return;
|
||||
shader->m_texture_slots[shader->m_texture_slot_count - 1].is_atlas = true;
|
||||
}
|
||||
|
||||
|
||||
static Renderer* getRendererGlobal(lua_State* L)
|
||||
{
|
||||
Renderer* renderer = nullptr;
|
||||
|
@ -387,7 +379,6 @@ static void registerFunctions(Shader* shader, ShaderCombinations* combinations,
|
|||
registerCFunction(L, "alpha_blending", &LuaWrapper::wrap<decltype(&alpha_blending), alpha_blending>);
|
||||
registerCFunction(L, "texture_slot", &LuaWrapper::wrap<decltype(&texture_slot), texture_slot>);
|
||||
registerCFunction(L, "texture_define", &LuaWrapper::wrap<decltype(&texture_define), texture_define>);
|
||||
registerCFunction(L, "atlas", &LuaWrapper::wrap<decltype(&atlas), atlas>);
|
||||
registerCFunction(L, "uniform", &LuaWrapper::wrap<decltype(&uniform), uniform>);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,14 +88,12 @@ public:
|
|||
{
|
||||
name[0] = uniform[0] = '\0';
|
||||
define_idx = -1;
|
||||
is_atlas = false;
|
||||
uniform_handle = BGFX_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
char name[30];
|
||||
char uniform[30];
|
||||
int define_idx;
|
||||
bool is_atlas;
|
||||
bgfx::UniformHandle uniform_handle;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ Texture::Texture(const Path& path, ResourceManagerBase& resource_manager, IAlloc
|
|||
, data(_allocator)
|
||||
, bytes_per_pixel(-1)
|
||||
, depth(-1)
|
||||
, layers(1)
|
||||
{
|
||||
atlas_size = -1;
|
||||
bgfx_flags = 0;
|
||||
is_cubemap = false;
|
||||
handle = BGFX_INVALID_HANDLE;
|
||||
|
@ -361,8 +361,11 @@ bool loadRaw(Texture& texture, FS::IFile& file)
|
|||
1,
|
||||
bgfx::TextureFormat::R32F,
|
||||
texture.bgfx_flags,
|
||||
mem);
|
||||
nullptr);
|
||||
// update must be here because texture is immutable otherwise
|
||||
bgfx::updateTexture2D(texture.handle, 0, 0, 0, 0, (uint16_t)texture.width, (uint16_t)texture.height, mem);
|
||||
texture.depth = 1;
|
||||
texture.layers = 1;
|
||||
texture.mips = 1;
|
||||
texture.is_cubemap = false;
|
||||
return bgfx::isValid(texture.handle);
|
||||
|
@ -424,11 +427,21 @@ static bool loadTGA(Texture& texture, FS::IFile& file)
|
|||
header.width,
|
||||
header.height,
|
||||
false,
|
||||
1,
|
||||
0,
|
||||
bgfx::TextureFormat::RGBA8,
|
||||
texture.bgfx_flags,
|
||||
nullptr);
|
||||
// update must be here because texture is immutable otherwise
|
||||
bgfx::updateTexture2D(texture.handle,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
header.width,
|
||||
header.height,
|
||||
bgfx::copy(image_dest, header.width * header.height * 4));
|
||||
texture.depth = 1;
|
||||
texture.layers = 1;
|
||||
return bgfx::isValid(texture.handle);
|
||||
}
|
||||
|
||||
|
@ -462,6 +475,7 @@ static bool loadDDS(Texture& texture, FS::IFile& file)
|
|||
texture.mips = info.numMips;
|
||||
texture.height = info.height;
|
||||
texture.depth = info.depth;
|
||||
texture.layers = info.numLayers;
|
||||
texture.is_cubemap = info.cubeMap;
|
||||
return bgfx::isValid(texture.handle);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ class LUMIX_RENDERER_API Texture : public Resource
|
|||
int height;
|
||||
int bytes_per_pixel;
|
||||
int depth;
|
||||
int layers;
|
||||
int mips;
|
||||
int atlas_size;
|
||||
bool is_cubemap;
|
||||
uint32 bgfx_flags;
|
||||
bgfx::TextureHandle handle;
|
||||
|
|
Loading…
Reference in a new issue