Loading gfx/include/gfx/shader_nodes.hpp +10 −6 Original line number Diff line number Diff line Loading @@ -675,7 +675,7 @@ struct ShaderGraph::CosineNode : public Node { }; struct ShaderGraph::SkinningUnlitNode : public Node { SkinningUnlitNode() : Node( SkinningUnlitNode(size_t num_of_joints) : Node( "skinning unlit", "Abstract parent node for skinning algorithms calculating just the position", { Loading @@ -686,14 +686,16 @@ struct ShaderGraph::SkinningUnlitNode : public Node { { {"position", "Vertex position with skinning applied.", { DataType::VEC3 }}, } ) {} ), m_num_of_joints(num_of_joints) {} enum inputs { position, weights, bone_indices }; enum outputs { skinned_position }; protected: size_t m_num_of_joints; }; struct ShaderGraph::SkinningNode : public Node { SkinningNode() : Node( SkinningNode(size_t num_of_joints) : Node( "skinning lit", "Abstract parent node for skinning algorithms taking normals and tangents into consideration as well", { Loading @@ -708,20 +710,22 @@ struct ShaderGraph::SkinningNode : public Node { {"normal", "Vertex normal with skinning applied.", { DataType::VEC3 }}, {"tangent", "Vertex tangent with skinning applied.", { DataType::VEC3 }}, } ) {} ), m_num_of_joints(num_of_joints) {} enum inputs { position, normal, tangent, weights, bone_indices }; enum outputs { skinned_position, skinned_normal, skinned_tangent }; protected: size_t m_num_of_joints; }; struct ShaderGraph::LinearBlendSkinningUnlitNode : public ShaderGraph::SkinningUnlitNode { LinearBlendSkinningUnlitNode() {} LinearBlendSkinningUnlitNode(size_t num_of_joints) : ShaderGraph::SkinningUnlitNode(num_of_joints) {} void add_code(StagesCode &code, Stage stage) const override; }; struct ShaderGraph::LinearBlendSkinningNode : public ShaderGraph::SkinningNode { LinearBlendSkinningNode() {} LinearBlendSkinningNode(size_t num_of_joints) : ShaderGraph::SkinningNode(num_of_joints) {} void add_code(StagesCode &code, Stage stage) const override; }; Loading gfx/src/shader_nodes.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -927,9 +927,8 @@ void ShaderGraph::CosineNode::add_code(StagesCode &code, Stage stage) const { void ShaderGraph::LinearBlendSkinningUnlitNode::add_code(StagesCode &code, Stage stage) const { INVARIANT(stage == Stage::VERTEX); const static auto MAX_BONES = 80; auto decl = R"(layout(std140) uniform BoneMatrices { mat4 bones[)" + std::to_string(MAX_BONES) + R"(]; // MAX_BONES defined in shader mat4 bones[)" + std::to_string(m_num_of_joints) + R"(]; // MAX_BONES defined in shader }; vec3 get_skinned_position(vec3 position, vec4 weights, uvec4 bone_indices) { Loading @@ -954,12 +953,10 @@ vec3 get_skinned_position(vec3 position, vec4 weights, uvec4 bone_indices) { void ShaderGraph::LinearBlendSkinningNode::add_code(StagesCode &code, Stage stage) const { INVARIANT(stage == Stage::VERTEX); const static auto MAX_BONES = 80; std::string decl_flag = "// bone matrix UBO declarations"; if (std::ranges::find(code[stage].decl, decl_flag) == code[stage].decl.end()) { std::string ubo_decl = "layout(std140) uniform BoneMatrices {\n" " mat4 bones[" + std::to_string(MAX_BONES) + "]; // MAX_BONES defined in shader\n" " mat4 bones[" + std::to_string(m_num_of_joints) + "]; // MAX_BONES defined in shader\n" "}"; code[stage].decl.push_back(decl_flag); Loading Loading
gfx/include/gfx/shader_nodes.hpp +10 −6 Original line number Diff line number Diff line Loading @@ -675,7 +675,7 @@ struct ShaderGraph::CosineNode : public Node { }; struct ShaderGraph::SkinningUnlitNode : public Node { SkinningUnlitNode() : Node( SkinningUnlitNode(size_t num_of_joints) : Node( "skinning unlit", "Abstract parent node for skinning algorithms calculating just the position", { Loading @@ -686,14 +686,16 @@ struct ShaderGraph::SkinningUnlitNode : public Node { { {"position", "Vertex position with skinning applied.", { DataType::VEC3 }}, } ) {} ), m_num_of_joints(num_of_joints) {} enum inputs { position, weights, bone_indices }; enum outputs { skinned_position }; protected: size_t m_num_of_joints; }; struct ShaderGraph::SkinningNode : public Node { SkinningNode() : Node( SkinningNode(size_t num_of_joints) : Node( "skinning lit", "Abstract parent node for skinning algorithms taking normals and tangents into consideration as well", { Loading @@ -708,20 +710,22 @@ struct ShaderGraph::SkinningNode : public Node { {"normal", "Vertex normal with skinning applied.", { DataType::VEC3 }}, {"tangent", "Vertex tangent with skinning applied.", { DataType::VEC3 }}, } ) {} ), m_num_of_joints(num_of_joints) {} enum inputs { position, normal, tangent, weights, bone_indices }; enum outputs { skinned_position, skinned_normal, skinned_tangent }; protected: size_t m_num_of_joints; }; struct ShaderGraph::LinearBlendSkinningUnlitNode : public ShaderGraph::SkinningUnlitNode { LinearBlendSkinningUnlitNode() {} LinearBlendSkinningUnlitNode(size_t num_of_joints) : ShaderGraph::SkinningUnlitNode(num_of_joints) {} void add_code(StagesCode &code, Stage stage) const override; }; struct ShaderGraph::LinearBlendSkinningNode : public ShaderGraph::SkinningNode { LinearBlendSkinningNode() {} LinearBlendSkinningNode(size_t num_of_joints) : ShaderGraph::SkinningNode(num_of_joints) {} void add_code(StagesCode &code, Stage stage) const override; }; Loading
gfx/src/shader_nodes.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -927,9 +927,8 @@ void ShaderGraph::CosineNode::add_code(StagesCode &code, Stage stage) const { void ShaderGraph::LinearBlendSkinningUnlitNode::add_code(StagesCode &code, Stage stage) const { INVARIANT(stage == Stage::VERTEX); const static auto MAX_BONES = 80; auto decl = R"(layout(std140) uniform BoneMatrices { mat4 bones[)" + std::to_string(MAX_BONES) + R"(]; // MAX_BONES defined in shader mat4 bones[)" + std::to_string(m_num_of_joints) + R"(]; // MAX_BONES defined in shader }; vec3 get_skinned_position(vec3 position, vec4 weights, uvec4 bone_indices) { Loading @@ -954,12 +953,10 @@ vec3 get_skinned_position(vec3 position, vec4 weights, uvec4 bone_indices) { void ShaderGraph::LinearBlendSkinningNode::add_code(StagesCode &code, Stage stage) const { INVARIANT(stage == Stage::VERTEX); const static auto MAX_BONES = 80; std::string decl_flag = "// bone matrix UBO declarations"; if (std::ranges::find(code[stage].decl, decl_flag) == code[stage].decl.end()) { std::string ubo_decl = "layout(std140) uniform BoneMatrices {\n" " mat4 bones[" + std::to_string(MAX_BONES) + "]; // MAX_BONES defined in shader\n" " mat4 bones[" + std::to_string(m_num_of_joints) + "]; // MAX_BONES defined in shader\n" "}"; code[stage].decl.push_back(decl_flag); Loading