update vertex

This commit is contained in:
ouczbs 2024-04-30 17:34:27 +08:00
parent 9b5b3d61a7
commit 5172310fd8
10 changed files with 88 additions and 28 deletions

Binary file not shown.

Binary file not shown.

View File

@ -4,7 +4,6 @@
#include "../meta/vertex.h"
namespace engineapi {
using refl::parray;
using refl::ToParray;
class Texture;
class Material;
class Mesh : public Asset {

View File

@ -104,8 +104,7 @@ namespace engineapi {
indices.push_back(face.mIndices[j]);
}
}
Mesh* model = new Mesh(mesh->mName.C_Str(), mFlags, vertices, indices);
return model;
return new Mesh(mesh->mName.C_Str(), mFlags, vertices, indices);
}
void Model::Use()
{

View File

@ -1,11 +1,7 @@
#pragma once
#include "refl/refl.h"
namespace engineapi {
enum class EVkFormat : uint32_t {
None = 0,
R32G32B32 = 106,
};
struct VertexMeta {
EVkFormat vkFormat;
uint32_t format;
};
}

View File

@ -1,5 +1,4 @@
#include "vertex.h"
namespace engineapi {
void BoneVertex::AddBoneData(uint32_t boneID, float weight)
{

View File

@ -9,42 +9,40 @@ namespace engineapi {
struct Vertex {
};
struct PosVertex_Meta;
struct PosVertex : public Vertex{
using MyMeta = PosVertex_Meta;
__cppast(VkMeta = { {} ,VertexMeta{.vkFormat=EVkFormat::R32G32B32} })
struct PosVertex {
using MyMetas = class PosVertex_MultyMeta;
UPROPERTY_vk({}, VertexMeta{ VK_FORMAT_R32G32B32_SFLOAT })
Vector3 Position = {};
};
struct TexVertex_Meta;
struct TexVertex : public Vertex {
using MyMeta = TexVertex_Meta;
__cppast(Meta = {})
using MyMetas = class TexVertex_MulytMeta;
UPROPERTY_vk({}, VertexMeta{ VK_FORMAT_R32G32B32_SFLOAT })
Vector3 Position = {};
__cppast(Meta = {})
UPROPERTY_vk()
Vector3 Normal = {};
__cppast(Meta = {})
UPROPERTY_vk()
Vector2 TexCoords = {};
};
struct BoneVertex_Meta;
struct BoneVertex : public Vertex
{
using MyMeta = BoneVertex_Meta;
__cppast(Meta = {})
using MyMetas = class BoneVertex_MulytMeta;
UPROPERTY_vk({}, VertexMeta{ VK_FORMAT_R32G32B32_SFLOAT })
Vector3 Position = {};
__cppast(Meta = {})
UPROPERTY_vk()
Vector2 TexCoords = {};
__cppast(Meta = {})
UPROPERTY_vk()
Vector3 Normal = {};
__cppast(Meta = {})
UPROPERTY_vk()
Vector3 Tangent = {};
// 骨骼蒙皮数据
__cppast(Meta = {})
UPROPERTY_vk()
float Weights[MAX_NUM_BONES_PER_VERTEX] = {};
__cppast(Meta = {})
UPROPERTY_vk()
uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {};
void AddBoneData(uint32_t boneID, float weight);
};
};
#include "meta_vertex_gen.inl"
#include "vkmeta_vertex_gen.inl"
#include "vertex_gen.inl"

View File

@ -12,6 +12,7 @@
#include "wrapper/descriptorpool.h"
#include "window.h"
#include "zlog.h"
#include "vkmeta_vertex_gen.inl"
namespace vulkanapi {
RenderVulkanAPI::RenderVulkanAPI()
:backend("vulkan")

View File

@ -0,0 +1,62 @@
import("core.project.depend")
function cmd_compile(genfile, sourcefile, template, macro, define)
import("find_sdk")
local meta = find_sdk.find_my_program("refl")
template = template or path.join(meta.sdkdir, "template")
if not macro then --优先使用库定义
macro = path.join(os.projectdir(), "engine/3rdparty/zlib/include/refl/macro.h")
if not os.exists(macro) then
macro = path.join(os.curdir(), "macro.h")
end
end
argv = {"build", sourcefile, "-o", genfile, "-t", template, "-m", macro}
if define then
table.insert(argv, "-d")
table.insert(argv, define)
end
print("cmd_meta_compile", genfile)
os.runv(meta.program, argv)
return argv
end
function _listen_gen_vs_file(target, batch)
-- genfile, sourcefile = batch[1], batch[2]
-- local dependfile = target:dependfile(genfile)
-- depend.on_changed(
-- function()
-- cmd_compile(batch[1], batch[2], template, macro, define)
-- end,
-- {dependfile = dependfile, files = sourcefile}
-- )
end
function compile(target)
local glsl_batch = target:data("glsl.batch")
if not glsl_batch then
return
end
for _, batch in ipairs(glsl_batch.vs) do
local dir = path.directory(batch)
local vs = path.filename(batch)
local vert = string.gsub(vs, ".vs.glsl$", ".vert.spv")
_listen_gen_vs_file(target, dir, vert)
end
end
function main(target)
local ps = {}
local psfiles = target:extraconf("rules", "glsl.env", "ps")
for _, file in ipairs(psfiles) do
local p = path.join(target:scriptdir(), file)
for __, filepath in ipairs(os.files(p)) do
table.insert(ps, filepath)
end
end
local vsfiles = target:extraconf("rules", "glsl.env", "vs")
for _, file in ipairs(vsfiles) do
local p = path.join(target:scriptdir(), file)
for __, filepath in ipairs(os.files(p)) do
table.insert(vs, filepath)
end
end
local glslfiles = {ps = ps, vs = vs}
target:data_set("glsl.batch", glslfiles)
end

View File

@ -1,4 +1,10 @@
rule("glsl.env")
after_load(function (target)
import("glsl_compiler")(target)
end)
on_config(function (target)
import("glsl_compiler").compile(target)
end)
-- before load
before_build(function (target)
os.cd("$(projectdir)/engine/assets/shader")