添加圆心遮罩
This commit is contained in:
+12
-8
@@ -546,7 +546,7 @@ void FaceApp::setup_descriptor_set_layout()
|
||||
VkPushConstantRange pushConstantRanges[1];
|
||||
pushConstantRanges[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT| VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
pushConstantRanges[0].offset = 0;
|
||||
pushConstantRanges[0].size = sizeof(float)*3;
|
||||
pushConstantRanges[0].size = sizeof(PushConstants);
|
||||
|
||||
//pushConstantRanges[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
//pushConstantRanges[1].offset = sizeof(float);
|
||||
@@ -691,7 +691,7 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
||||
|
||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout_bg, 0, 1, &m_descriptor_set_bg, 0, NULL);
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline_bg);
|
||||
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(pushConstants), &pushConstants);
|
||||
|
||||
|
||||
|
||||
@@ -713,21 +713,21 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
||||
// vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &m_descriptor_sets_right[_curMotionIndex], 0, NULL);
|
||||
//}
|
||||
|
||||
float fsValues[3] = { myFloatValue, 0 , 0};
|
||||
//float fsValues[3] = { myFloatValue, 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[1] = ux;
|
||||
fsValues[2] = uy;
|
||||
pushConstants.ux = ux;
|
||||
pushConstants.uy = uy;
|
||||
}
|
||||
}
|
||||
//fsValues[1] = 0;
|
||||
//fsValues[2] = 360;
|
||||
|
||||
vkCmdPushConstants(commandBuffer, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT| VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fsValues), &fsValues);
|
||||
vkCmdPushConstants(commandBuffer, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT| VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConstants), &pushConstants);
|
||||
//vkCmdPushConstants(commandBuffer, m_pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fsValues), fsValues);
|
||||
|
||||
|
||||
@@ -1169,7 +1169,7 @@ void FaceApp::setup_descriptor_set_layout_bg()
|
||||
VkPushConstantRange pushConstantRanges[1];
|
||||
pushConstantRanges[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
pushConstantRanges[0].offset = 0;
|
||||
pushConstantRanges[0].size = sizeof(float);
|
||||
pushConstantRanges[0].size = sizeof(PushConstants);
|
||||
|
||||
pipeline_layout_create_info.pushConstantRangeCount = 1;
|
||||
pipeline_layout_create_info.pPushConstantRanges = &pushConstantRanges[0];
|
||||
@@ -1372,7 +1372,11 @@ void FaceApp::cleanup()
|
||||
void FaceApp::SetInitArg(const char* arg)
|
||||
{
|
||||
_initArg = json::parse(arg);
|
||||
|
||||
pushConstants.zoom = _initArg.zoom;
|
||||
pushConstants.r = _initArg.r;
|
||||
pushConstants.g = _initArg.g;
|
||||
pushConstants.b = _initArg.b;
|
||||
pushConstants.radius = _initArg.radius;
|
||||
}
|
||||
|
||||
void FaceApp::drawFrame(long long frameTime)
|
||||
|
||||
+14
-3
@@ -38,13 +38,23 @@ struct InitArg
|
||||
{
|
||||
int action_fps;
|
||||
float zoom;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float radius;
|
||||
//Motion motion;
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(InitArg, action_fps, zoom);
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(InitArg, action_fps, zoom, r, g, b, radius);
|
||||
};
|
||||
|
||||
|
||||
struct PushConstants {
|
||||
float myValue;
|
||||
float zoom = 0.5f;
|
||||
float r = 0;
|
||||
float g = 0;
|
||||
float b = 0;
|
||||
float radius = 240;
|
||||
float ux = 0;
|
||||
float uy = 0;
|
||||
};
|
||||
|
||||
using Callback = std::function<void()>;
|
||||
@@ -149,7 +159,8 @@ private:
|
||||
|
||||
|
||||
|
||||
float myFloatValue = 1.5f;
|
||||
//float myFloatValue = 1.5f;
|
||||
PushConstants pushConstants;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -150,6 +150,10 @@ int main() {
|
||||
|
||||
init_arg.action_fps = 10;
|
||||
init_arg.zoom = 1.5f;
|
||||
init_arg.r = 1;
|
||||
init_arg.g = 0;
|
||||
init_arg.b = 0;
|
||||
init_arg.radius = 240;
|
||||
|
||||
string json_str = json(init_arg).dump();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user