save code
This commit is contained in:
@@ -5,6 +5,11 @@ layout (binding = 1) uniform sampler2D samplerColor;
|
|||||||
layout (location = 0) in vec2 inUV;
|
layout (location = 0) in vec2 inUV;
|
||||||
layout (location = 1) in vec3 inNormal;
|
layout (location = 1) in vec3 inNormal;
|
||||||
|
|
||||||
|
layout(push_constant) uniform PushConstantsFS {
|
||||||
|
float ux;
|
||||||
|
float uy;
|
||||||
|
} pc_fs;
|
||||||
|
|
||||||
|
|
||||||
layout (location = 0) out vec4 outFragColor;
|
layout (location = 0) out vec4 outFragColor;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
+38
-40
@@ -660,6 +660,21 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
|||||||
|
|
||||||
vkCmdPushConstants(commandBuffer, m_pipelineLayout_bg, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float), &myFloatValue);
|
vkCmdPushConstants(commandBuffer, m_pipelineLayout_bg, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float), &myFloatValue);
|
||||||
|
|
||||||
|
|
||||||
|
float fsValues[2] = { 0, 0 };
|
||||||
|
if (_curMotionIndex < _curMotions.size())
|
||||||
|
{
|
||||||
|
if (_curFrameIndex < _curMotions[_curMotionIndex].frames.size())
|
||||||
|
{
|
||||||
|
float ux = _curMotions[_curMotionIndex].frames[_curFrameIndex].x;
|
||||||
|
float uy = _curMotions[_curMotionIndex].frames[_curFrameIndex].y;
|
||||||
|
fsValues[0] = ux;
|
||||||
|
fsValues[1] = uy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vkCmdPushConstants(commandBuffer, m_pipelineLayout_bg, VK_SHADER_STAGE_FRAGMENT_BIT, 4, sizeof(fsValues), fsValues);
|
||||||
|
|
||||||
vkCmdDraw(commandBuffer, 6, 1, 0, 0);
|
vkCmdDraw(commandBuffer, 6, 1, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
@@ -1081,13 +1096,17 @@ void FaceApp::setup_descriptor_set_layout_bg()
|
|||||||
pipeline_layout_create_info.pSetLayouts = &m_descriptorSetLayout_bg;
|
pipeline_layout_create_info.pSetLayouts = &m_descriptorSetLayout_bg;
|
||||||
|
|
||||||
|
|
||||||
VkPushConstantRange pushConstantRange{};
|
VkPushConstantRange pushConstantRanges[2];
|
||||||
pushConstantRange.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; // 只在片段着色器中使用
|
pushConstantRanges[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; // 只在片段着色器中使用
|
||||||
pushConstantRange.offset = 0;
|
pushConstantRanges[0].offset = 0;
|
||||||
pushConstantRange.size = sizeof(float); // 或者 sizeof(PushConstants)
|
pushConstantRanges[0].size = sizeof(float); // 或者 sizeof(PushConstants)
|
||||||
|
|
||||||
pipeline_layout_create_info.pushConstantRangeCount = 1;
|
pushConstantRanges[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; // 只在片段着色器中使用
|
||||||
pipeline_layout_create_info.pPushConstantRanges = &pushConstantRange;
|
pushConstantRanges[1].offset = sizeof(float);
|
||||||
|
pushConstantRanges[1].size = 2 * sizeof(float); // 或者 sizeof(PushConstants)
|
||||||
|
|
||||||
|
pipeline_layout_create_info.pushConstantRangeCount = 2;
|
||||||
|
pipeline_layout_create_info.pPushConstantRanges = &pushConstantRanges[0];
|
||||||
|
|
||||||
VK_CHECK(vkCreatePipelineLayout(device, &pipeline_layout_create_info, nullptr, &m_pipelineLayout_bg));
|
VK_CHECK(vkCreatePipelineLayout(device, &pipeline_layout_create_info, nullptr, &m_pipelineLayout_bg));
|
||||||
}
|
}
|
||||||
@@ -1410,13 +1429,8 @@ void FaceApp::loadMotionThread()
|
|||||||
_callback_loadfinish();
|
_callback_loadfinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceApp::changeMotionList(AnimationFinishedCallback callback, bool loop)
|
void FaceApp::doChangeMotion()
|
||||||
{
|
{
|
||||||
if (_isLoadMotion)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock_changeMotion(changeMotionMtx);
|
std::unique_lock<std::mutex> lock_changeMotion(changeMotionMtx);
|
||||||
|
|
||||||
|
|
||||||
@@ -1433,36 +1447,20 @@ void FaceApp::changeMotionList(AnimationFinishedCallback callback, bool loop)
|
|||||||
|
|
||||||
update_descriptor_set(m_texs);
|
update_descriptor_set(m_texs);
|
||||||
_curMotions = _preLoadMotions;
|
_curMotions = _preLoadMotions;
|
||||||
_animationFinishedCallback = callback;
|
|
||||||
_animationLoop = loop;
|
|
||||||
_curFrameIndex = 0;
|
_curFrameIndex = 0;
|
||||||
_curMotionIndex = 0;
|
_curMotionIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FaceApp::changeMotionList(AnimationFinishedCallback callback, bool loop)
|
||||||
|
{
|
||||||
|
if (_isLoadMotion)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_animationFinishedCallback = callback;
|
||||||
|
_animationLoop = loop;
|
||||||
|
_needChangeMotion = true;
|
||||||
|
|
||||||
// for (int i = 0; i < _curMotion.png_names.size(); ++i)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
//#ifdef _WIN32
|
|
||||||
// //string path = _curMotion.type + "/" + _curMotion.technique + "/" + _curMotion.step + "/" + _curMotion.show_type;
|
|
||||||
// string path = "pic";
|
|
||||||
// string path_name = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i];// +std::to_string(i) + ".png";
|
|
||||||
// loadTextureExample(UTF8ToWideString(path_name), m_texs[i], true);
|
|
||||||
// if (kThick)
|
|
||||||
// {
|
|
||||||
// string path_name_ex = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i] + std::to_string(i) + "_thick.png";
|
|
||||||
// loadTextureExample(UTF8ToWideString(path_name_ex), m_texs_ex[i], true);
|
|
||||||
// }
|
|
||||||
//#else
|
|
||||||
// //string path = _curMotion.type + "/" + _curMotion.technique + "/" + _curMotion.step + "/" + _curMotion.show_type;
|
|
||||||
// string path = "pic";
|
|
||||||
// string path_name = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i];// +std::to_string(i) + ".png";
|
|
||||||
// loadTexture(path_name, m_texs[i], true);
|
|
||||||
// if (kThick)
|
|
||||||
// {
|
|
||||||
// loadTexture(path_name, m_texs_ex[i], true);
|
|
||||||
// }
|
|
||||||
//#endif // _WIN32
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
@@ -155,6 +155,8 @@ public:
|
|||||||
void loadMotionThread();
|
void loadMotionThread();
|
||||||
std::thread worker_;
|
std::thread worker_;
|
||||||
bool _isLoadMotion = false;
|
bool _isLoadMotion = false;
|
||||||
|
bool _needChangeMotion = false;
|
||||||
|
void doChangeMotion();
|
||||||
Callback _callback_loadfinish;
|
Callback _callback_loadfinish;
|
||||||
AnimationFinishedCallback _animationFinishedCallback;
|
AnimationFinishedCallback _animationFinishedCallback;
|
||||||
bool _animationLoop = true;
|
bool _animationLoop = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user