diff --git a/CMakeLists.txt b/CMakeLists.txt index 105a7c68..3824f922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ else() set(DL_DISABLE_AUDIO false) set(DL_DISABLE_OPENSSL false) set(DL_DISABLE_CURL false) - set(DL_DISABLE_CONSOLE false) + set(DL_DISABLE_CONSOLE false) # 仅控制是否有控制台 set(DL_USE_MT false) endif() @@ -144,23 +144,30 @@ add_subdirectory ("dl") if(NOT DL_DISABLE_RENDER) message("------------------解析dl_test-----------------------") add_subdirectory ("project/dl_test") + + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_editor/CMakeLists.txt) + message("------------------解析dl_editor-----------------------") + add_subdirectory ("project/dl_editor") + endif() + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_midi/CMakeLists.txt) + message("------------------解析dl_midi-----------------------") + add_subdirectory ("project/dl_midi") + endif() + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_chess/CMakeLists.txt) + message("------------------解析dl_chess-----------------------") + add_subdirectory ("project/dl_chess") + endif() + if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_snake/CMakeLists.txt) + message("------------------解析dl_snake-----------------------") + add_subdirectory ("project/dl_snake") + endif() endif() + message("------------------解析dl_console-----------------------") add_subdirectory ("project/dl_console") - -if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_editor/CMakeLists.txt) - message("------------------解析dl_editor-----------------------") - add_subdirectory ("project/dl_editor") -endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_midi/CMakeLists.txt) - message("------------------解析dl_midi-----------------------") - add_subdirectory ("project/dl_midi") -endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_chess/CMakeLists.txt) - message("------------------解析dl_chess-----------------------") - add_subdirectory ("project/dl_chess") -endif() if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_config/CMakeLists.txt) message("------------------解析dl_config-----------------------") add_subdirectory ("project/dl_config") endif() + + diff --git a/dl/math/dl_random.h b/dl/math/dl_random.h index 7b7816f4..bb287518 100644 --- a/dl/math/dl_random.h +++ b/dl/math/dl_random.h @@ -84,6 +84,11 @@ public: return Integer(min, max); } + static unsigned Uint(unsigned min, unsigned max) + { + return Integer(min, max); + } + /** * @brief 从容器随机选择一个 * @param[in] container 容器(不能为空) diff --git a/dl/render/dl_factory.h b/dl/render/dl_factory.h index 50e69709..cda07134 100644 --- a/dl/render/dl_factory.h +++ b/dl/render/dl_factory.h @@ -151,6 +151,7 @@ public: /** * @brief 创建默认精灵 */ + [[nodiscard]] gcSprite CreateSpriteDefault(const Color& col = ColorDef::WHITE); /** diff --git a/dl/system/dl_midi.cpp b/dl/system/dl_midi.cpp index 0ea7f058..3a1de5bc 100644 --- a/dl/system/dl_midi.cpp +++ b/dl/system/dl_midi.cpp @@ -54,7 +54,7 @@ namespace dl // message[1] = 64; // message[2] = 91; // _out->sendMessage(&message); - // std::this_thread::sleep_for(std::chrono::milliseconds(500)); + // std::this_thread::sleep_for(std::chrono::milliseconds(500)); // message[0] = 128; // message[1] = 70; // message[2] = 40; @@ -98,4 +98,10 @@ namespace dl _imp->_out->sendMessage((unsigned char*)buf.data(), buf.size()); } + void Midi::PlayC() + { + /*unsigned char + _imp->_out->sendMessage(,);*/ + } + } diff --git a/dl/system/dl_midi.h b/dl/system/dl_midi.h index 42e27936..5dce25a5 100644 --- a/dl/system/dl_midi.h +++ b/dl/system/dl_midi.h @@ -24,6 +24,7 @@ public: ~Midi(); void Play(BufferView buf); + void PlayC(); private: MidiImp* _imp; }; diff --git a/dl/vk/dl_vertex.h b/dl/vk/dl_vertex.h index 25ed16cb..71f0c6a0 100644 --- a/dl/vk/dl_vertex.h +++ b/dl/vk/dl_vertex.h @@ -22,8 +22,8 @@ namespace dl struct Vertex { Position3 _pos; - Position3 _normal; Position2 _uv; + Position3 _normal; Position3 _tangent; static VkVertexInputBindingDescription getBindingDescription() { @@ -36,22 +36,26 @@ struct Vertex static std::array getAttributeDescriptions() { std::array attributeDescriptions{}; - attributeDescriptions[0].binding = 0; - attributeDescriptions[0].location = 0; - attributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[0].offset = offsetof(Vertex, _pos); - attributeDescriptions[1].binding = 0; - attributeDescriptions[1].location = 2; - attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[1].offset = offsetof(Vertex, _normal); - attributeDescriptions[2].binding = 0; - attributeDescriptions[2].location = 1; - attributeDescriptions[2].format = VK_FORMAT_R32G32_SFLOAT; - attributeDescriptions[2].offset = offsetof(Vertex, _uv); - attributeDescriptions[3].binding = 0; - attributeDescriptions[3].location = 3; - attributeDescriptions[3].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[3].offset = offsetof(Vertex, _tangent); + uint32_t i = 0; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _pos); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _uv); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _normal); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(Vertex, _tangent); return attributeDescriptions; } }; @@ -61,11 +65,12 @@ constexpr size_t NUM_BONE = 4; struct VertexBone { Position3 _pos; - Position3 _normal; Position2 _uv0; Position2 _uv1; - std::array _joint0; + Position3 _normal; + Position3 _tangent; Position4 _weight0; + std::array _joint0; Position4 _color; static VkVertexInputBindingDescription getBindingDescription() { @@ -75,19 +80,14 @@ struct VertexBone bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; return bindingDescription; } - static std::array getAttributeDescriptions() + static std::array getAttributeDescriptions() { - std::array attributeDescriptions{}; + std::array attributeDescriptions{}; uint32_t i = 0; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; attributeDescriptions[i].offset = offsetof(VertexBone, _pos); - ++i; - attributeDescriptions[i].binding = 0; - attributeDescriptions[i].location = i; - attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[i].offset = offsetof(VertexBone, _normal); ++i; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; @@ -98,6 +98,21 @@ struct VertexBone attributeDescriptions[i].location = i; attributeDescriptions[i].format = VK_FORMAT_R32G32_SFLOAT; attributeDescriptions[i].offset = offsetof(VertexBone, _uv1); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(VertexBone, _normal); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32_SFLOAT; + attributeDescriptions[i].offset = offsetof(VertexBone, _tangent); + ++i; + attributeDescriptions[i].binding = 0; + attributeDescriptions[i].location = i; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; + attributeDescriptions[i].offset = offsetof(VertexBone, _weight0); ++i; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; @@ -106,12 +121,7 @@ struct VertexBone ++i; attributeDescriptions[i].binding = 0; attributeDescriptions[i].location = i; - attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_UINT; - attributeDescriptions[i].offset = offsetof(VertexBone, _weight0); - ++i; - attributeDescriptions[i].binding = 0; - attributeDescriptions[i].location = i; - attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_UINT; + attributeDescriptions[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; attributeDescriptions[i].offset = offsetof(VertexBone, _color); return attributeDescriptions; diff --git a/dl/vk/dl_vk.h b/dl/vk/dl_vk.h index cc7a3f26..fb2928b4 100644 --- a/dl/vk/dl_vk.h +++ b/dl/vk/dl_vk.h @@ -352,9 +352,9 @@ public: void* pUserData) { if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) - ;// log_test0(pCallbackData->pMessage); + log_test0(pCallbackData->pMessage); else if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) - log_info0(pCallbackData->pMessage);//提高了一个等级,方便断点 + log_info0(pCallbackData->pMessage); return VK_FALSE; } diff --git a/project/dl_snake/CMakeLists.txt b/project/dl_snake/CMakeLists.txt new file mode 100644 index 00000000..06fda5c0 --- /dev/null +++ b/project/dl_snake/CMakeLists.txt @@ -0,0 +1,87 @@ +cmake_minimum_required (VERSION 3.12) +project ("dl_snake") + +# 项目资源路径 +set(PATH_RES ${PROJECT_SOURCE_DIR}/res) + +add_compile_options("$<$:/source-charset:utf-8>") +add_compile_options("$<$:/execution-charset:utf-8>") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + +# 设置处理 +if (DL_DISABLE_RENDER) + message(SEND_ERROR ${PROJECT_NAME}"必须启动绘图系统,将会编译失败(DL_DISABLE_RENDER)!") + +endif() +# 添加源、设置可执行文件 +aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC_LIST_TEST) + +# 安卓为动态链接库 +if (NOT CMAKE_SYSTEM_NAME MATCHES "Android") +if(DL_DISABLE_CONSOLE) + add_compile_definitions(DL_DISABLE_CONSOLE) + add_executable (${PROJECT_NAME} WIN32 ${SRC_LIST_TEST}) +else() + add_executable (${PROJECT_NAME} ${SRC_LIST_TEST}) +endif() +else() +add_library (${PROJECT_NAME} SHARED ${SRC_LIST_TEST}) +endif() + +if (NOT CMAKE_SYSTEM_NAME MATCHES "Android") +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 23) +endif() + +# dl库 +include_directories(${CMAKE_SOURCE_DIR}/dl) +target_link_libraries(${PROJECT_NAME} dl) + +# fmt +include_directories(${CMAKE_SOURCE_DIR}/third/fmt/include) +# json +include_directories(${CMAKE_SOURCE_DIR}/third/json) +# tinyxml2 +include_directories(${CMAKE_SOURCE_DIR}/third/tinyxml2) +# asio +include_directories(${CMAKE_SOURCE_DIR}/third/asio/include) +# angelscript +include_directories(${CMAKE_SOURCE_DIR}/third/angelscript/angelscript/include) +# lua +include_directories(${CMAKE_SOURCE_DIR}/third/lua) +# lua bridge +include_directories(${CMAKE_SOURCE_DIR}/third/LuaBridge3/Source) + +# dl资源文件夹 +set(DL_PATH_RES ${CMAKE_SOURCE_DIR}/res) +# vld资源文件夹 +if(CMAKE_CL_64) + set(DL_PATH_VLD ${CMAKE_SOURCE_DIR}/third/vld/bin/Win64) +else() + set(DL_PATH_VLD ${CMAKE_SOURCE_DIR}/third/vld/bin/Win32) +endif() + +# 目标文件夹 +set(PATH_OUT ${CMAKE_BINARY_DIR}/project/${PROJECT_NAME}/${CMAKE_CONFIGURATION_TYPES}) + +# 复制文件 +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${DL_PATH_RES}/dl ${PATH_OUT}/dl) +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PATH_RES} ${PATH_OUT}) +if (CMAKE_BUILD_TYPE MATCHES "Debug") +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${DL_PATH_VLD} ${PATH_OUT}) +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/third/vld/vld.ini ${PATH_OUT}) +endif() + + +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + +install(DIRECTORY ${PATH_RES} DESTINATION bin) \ No newline at end of file diff --git a/project/dl_snake/res/language.xlsx b/project/dl_snake/res/language.xlsx new file mode 100644 index 00000000..453c95ac Binary files /dev/null and b/project/dl_snake/res/language.xlsx differ diff --git a/project/dl_snake/res/readme.txt b/project/dl_snake/res/readme.txt new file mode 100644 index 00000000..e69de29b diff --git a/project/dl_snake/res/snakeFiles.rar b/project/dl_snake/res/snakeFiles.rar new file mode 100644 index 00000000..af59ac79 Binary files /dev/null and b/project/dl_snake/res/snakeFiles.rar differ diff --git a/project/dl_snake/res/sound/config.json b/project/dl_snake/res/sound/config.json new file mode 100644 index 00000000..5be3009f --- /dev/null +++ b/project/dl_snake/res/sound/config.json @@ -0,0 +1,5 @@ +{ + "path": "sound/", + "whitelist": [] + +} \ No newline at end of file diff --git a/project/dl_snake/src/game.h b/project/dl_snake/src/game.h new file mode 100644 index 00000000..b5fc4904 --- /dev/null +++ b/project/dl_snake/src/game.h @@ -0,0 +1,131 @@ +#pragma once +#include "head.h" +constexpr Size MAP_SIZE = { 16,16 }; +constexpr Size MAP_NODE_SIZE = { 12,12 }; + + +enum class MapNodeState { + PASS, + FOOD, + BODY +}; + +class MapNode { +public: + void SetNodeXy(const PointU& xy) { + _xy = xy; + } + + void SetNodeState(MapNodeState s) { + _state = s; + switch (_state) + { + case MapNodeState::PASS: + _spr.CancelRef(); + break; + case MapNodeState::FOOD: + _spr = g_factory->CreateSpriteDefault(ColorDef::RED); + _spr->SetQuad({10,10}); + _spr->SetQuad(createQuad(Position{10.0f,10.0f}, false)); + _spr->SetOrder(0.8); + _spr->AddCoor(); + _spr->GetCoor()->SetPosition(toPosition(_xy * MAP_NODE_SIZE)); + break; + case MapNodeState::BODY: + _spr = g_factory->CreateSpriteDefault(ColorDef::YELLOW); + _spr->SetQuad({ 10,10 }); + _spr->SetQuad(createQuad(Position{ 10.0f,10.0f }, false)); + _spr->SetOrder(0.8); + _spr->AddCoor(); + _spr->GetCoor()->SetPosition(toPosition(_xy * MAP_NODE_SIZE)); + break; + default: + break; + } + } + + void RenderNode() { + if (_spr) + { + _spr->Render(); + } + } +private: + MapNodeState _state; + PointU _xy; + + gcSprite _spr; + +}; + +class Map { +public: + void Reset() { + _vec.resize(MAP_SIZE[0] * MAP_SIZE[1]); + for (unsigned j = 0; j< MAP_SIZE[1]; ++j) + { + for (unsigned i = 0; i < MAP_SIZE[0]; ++i) + { + unsigned idx = MAP_SIZE[0] * j + i; + _vec[idx].SetNodeState(MapNodeState::PASS); + _vec[idx].SetNodeXy({i,j}); + } + } + } + + void CreateFood(const PointU& xy) { + unsigned idx = MAP_SIZE[0] * xy[1] + xy[0]; + if (idx >= _vec.size()) + { + log_err("创建food下标越界:x: {},y: {}", xy[0], xy[1]); + return; + } + + _vec[idx].SetNodeState(MapNodeState::FOOD); + } + + void RenderMap() { + for (size_t i = 0; i < _vec.size(); ++i) + { + _vec[i].RenderNode(); + } + } + +private: + std::vector _vec; +}; + +class Game{ + +public: + Game() { + Random::SetSeed(0); + _sprBg = g_factory->CreateSpriteDefault(ColorDef::GREEN); + _txtFps = g_factory->CreateTextDefault(); + + _map.Reset(); + _map.CreateFood({ + Random::Uint(0, MAP_SIZE[0] - 1) , + Random::Uint(0, MAP_SIZE[1] - 1) + }); + } + + void Update() { + _sprBg->SetQuad(createQuad(g_system->GetWindowSize(), false)); + _sprBg->SetOrder(0.9); + _sprBg->Render(); + + _txtFps->SetString(std::to_string(g_time->GetFPS())); + _txtFps->GetCoor()->SetPosition({ 200, 200 }); + _txtFps->SetOrder(0.5); + _txtFps->Render(); + + _map.RenderMap(); + + } + +private: + gcSprite _sprBg; + gcText _txtFps; + Map _map; +}; \ No newline at end of file diff --git a/project/dl_snake/src/head.cpp b/project/dl_snake/src/head.cpp new file mode 100644 index 00000000..cd7765f9 --- /dev/null +++ b/project/dl_snake/src/head.cpp @@ -0,0 +1,35 @@ +#include "head.h" +#include "game.h" + +Game* g_Game; + +void Init() { + g_Game = new Game; + +} + +void Run() { + g_Game->Update(); +} + +int Main() +{ + dl::Engine::Init(); + log_msg("snake start"); + + g_factory->SetPath("img/","model/","out/","temp/"); + + g_system->SetFuncInit(Init); + g_system->SetFuncRun(Run); + + ParamWindow pw; + pw._strTitle = "snake"; + pw._size = { 800,600 }; + + g_system->Start(pw); + + + dl::Engine::Release(); + return 0; +} + diff --git a/project/dl_snake/src/head.h b/project/dl_snake/src/head.h new file mode 100644 index 00000000..dee530f4 --- /dev/null +++ b/project/dl_snake/src/head.h @@ -0,0 +1,7 @@ +#pragma once +#include +using namespace dl; + +int Main(); +class Game; +extern Game* g_Game; \ No newline at end of file diff --git a/project/dl_snake/src/main.cpp b/project/dl_snake/src/main.cpp new file mode 100644 index 00000000..ba6f572a --- /dev/null +++ b/project/dl_snake/src/main.cpp @@ -0,0 +1,13 @@ +#include + +extern int Main(); +//int CALLBACK WinMain( +// __in HINSTANCE hInstance, +// __in HINSTANCE hPrevInstance, +// __in LPSTR lpCmdLine, +// __in int nCmdShow +//) +int main() +{ + return Main(); +} diff --git a/project/dl_test/CMakeLists.txt b/project/dl_test/CMakeLists.txt index 19586ae2..14884384 100644 --- a/project/dl_test/CMakeLists.txt +++ b/project/dl_test/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # 设置处理 if (DL_DISABLE_RENDER) - message(SEND_ERROR "dl_test必须启动绘图系统,将会编译失败(DL_DISABLE_RENDER)!") + message(SEND_ERROR ${PROJECT_NAME}"必须启动绘图系统,将会编译失败(DL_DISABLE_RENDER)!") endif() # dl目录 @@ -49,6 +49,10 @@ include_directories(${CMAKE_SOURCE_DIR}/third/tinyxml2) include_directories(${CMAKE_SOURCE_DIR}/third/asio/include) # angelscript include_directories(${CMAKE_SOURCE_DIR}/third/angelscript/angelscript/include) +# lua +include_directories(${CMAKE_SOURCE_DIR}/third/lua) +# lua bridge +include_directories(${CMAKE_SOURCE_DIR}/third/LuaBridge3/Source) # dl资源文件夹 set(DL_PATH_RES ${CMAKE_SOURCE_DIR}/res) diff --git a/project/dl_test/main.cpp b/project/dl_test/main.cpp index e4384ef0..8559158e 100644 --- a/project/dl_test/main.cpp +++ b/project/dl_test/main.cpp @@ -154,24 +154,24 @@ void Init() //g_factory->LoadModel("axis.glb", "axis"); // 脚本加载 - { - g_as->SetPathRoot("as/"); - std::vector vec; - File::GetPathFileAll("as/", vec, {}, false); - for (auto& iter : vec) - { - g_as->LoadModule(iter); - } - } - // mod加载 - { - std::vector vec; - File::GetPathFileAll("mod/", vec, {}, false); - for (auto& iter : vec) - { - g_mod->LoadMod(iter); - } - } + //{ + // g_as->SetPathRoot("as/"); + // std::vector vec; + // File::GetPathFileAll("as/", vec, {}, false); + // for (auto& iter : vec) + // { + // g_as->LoadModule(iter); + // } + //} + //// mod加载 + //{ + // std::vector vec; + // File::GetPathFileAll("mod/", vec, {}, false); + // for (auto& iter : vec) + // { + // g_mod->LoadMod(iter); + // } + //} g_ui->SetStandardSize({ 800, 600 }); g_ui->RegisterAll("ui/"); diff --git a/project/dl_test/ui_main.cpp b/project/dl_test/ui_main.cpp index 2b9c404f..02d84e7d 100644 --- a/project/dl_test/ui_main.cpp +++ b/project/dl_test/ui_main.cpp @@ -49,8 +49,8 @@ UIMain::UIMain() _ruler = Tool::Ruler::Create(); - g_as->ExcuteFunction("mod管理器", "UI::Panel@ initUI(string)", - _panelMod, std::string{ "dddddddddd" }); + /*g_as->ExcuteFunction("mod管理器", "UI::Panel@ initUI(string)", + _panelMod, std::string{ "dddddddddd" });*/ int x = 3; } diff --git a/res/dl/shader/vert_bone.spv b/res/dl/shader/vert_bone.spv index c30d0463..a5d307a9 100644 Binary files a/res/dl/shader/vert_bone.spv and b/res/dl/shader/vert_bone.spv differ diff --git a/shader/compile_copy.bat b/shader/compile_copy.bat index 075233f0..68c2dd1c 100644 --- a/shader/compile_copy.bat +++ b/shader/compile_copy.bat @@ -1,30 +1,30 @@ ::3d普通 -glslc.exe shader.vert -o vert.spv -glslc.exe shader.frag -o frag.spv -copy vert.spv ..\res\shader\ -copy frag.spv ..\res\shader\ +glslc.exe shader_pbr.vert -o vert.spv +glslc.exe shader_pbr.frag -o frag.spv +copy vert.spv ..\res\dl\shader\ +copy frag.spv ..\res\dl\shader\ del vert.spv del frag.spv ::3d骨骼 -glslc.exe shader.vert -D=BONE -o vert_bone.spv -glslc.exe shader.frag -D=BONE -o frag_bone.spv -copy vert_bone.spv ..\res\shader\ -copy frag_bone.spv ..\res\shader\ +glslc.exe shader_pbr.vert -D=BONE -o vert_bone.spv +glslc.exe shader_pbr.frag -D=BONE -o frag_bone.spv +copy vert_bone.spv ..\res\dl\shader\ +copy frag_bone.spv ..\res\dl\shader\ del vert_bone.spv del frag_bone.spv glslc.exe shader_2d.vert -o vert_2d.spv glslc.exe shader_2d.frag -o frag_2d.spv -copy vert_2d.spv ..\res\shader\ -copy frag_2d.spv ..\res\shader\ +copy vert_2d.spv ..\res\dl\shader\ +copy frag_2d.spv ..\res\dl\shader\ del vert_2d.spv del frag_2d.spv glslc.exe shader_gfx.vert -o vert_gfx.spv glslc.exe shader_gfx.frag -o frag_gfx.spv -copy vert_gfx.spv ..\res\shader\ -copy frag_gfx.spv ..\res\shader\ +copy vert_gfx.spv ..\res\dl\shader\ +copy frag_gfx.spv ..\res\dl\shader\ del vert_gfx.spv del frag_gfx.spv diff --git a/shader/shader.vert b/shader/shader.vert index e4b37822..a49fafe1 100644 --- a/shader/shader.vert +++ b/shader/shader.vert @@ -20,12 +20,14 @@ layout (set = 1, binding = 0) uniform UniformBufferBone layout(location = 0) in vec3 inPosition; -layout(location = 1) in vec2 inTexCoord; -layout(location = 2) in vec3 inNormal; +layout(location = 1) in vec3 inNormal; +layout(location = 2) in vec2 inTexCoord; layout(location = 3) in vec3 inTangent; #ifdef BONE layout(location = 4) in vec4 boneWeight; layout(location = 5) in uvec4 boneIndex; +layout(location = 6) in vec2 inTexCoord1; +layout(location = 7) in vec4 inColor; #endif layout(location = 0) out vec3 fragColor; diff --git a/shader/shader_pbr.vert b/shader/shader_pbr.vert index 1dd9cac7..c53b525c 100644 --- a/shader/shader_pbr.vert +++ b/shader/shader_pbr.vert @@ -19,13 +19,20 @@ layout (set = 1, binding = 0) uniform UniformBufferBone #endif +#ifdef BONE +layout(location = 0) in vec3 inPosition; +layout(location = 1) in vec2 inTexCoord; +layout(location = 2) in vec2 inTexCoord1; +layout(location = 3) in vec3 inNormal; +layout(location = 4) in vec3 inTangent; +layout(location = 5) in vec3 boneWeight; +layout(location = 6) in uvec4 boneIndex; +layout(location = 7) in vec4 inColor; +#else layout(location = 0) in vec3 inPosition; layout(location = 1) in vec2 inTexCoord; layout(location = 2) in vec3 inNormal; layout(location = 3) in vec3 inTangent; -#ifdef BONE -layout(location = 4) in vec3 boneWeight; -layout(location = 5) in uvec4 boneIndex; #endif layout(location = 0) out vec3 fragColor;