Merge branch 'main' of http://101.34.228.45:3000/BigC/ArchitectureColoredPainting
commit
3edca0287b
148
4_L0.json
148
4_L0.json
|
@ -330,6 +330,146 @@
|
||||||
"y": 1
|
"y": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-10",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": 610,
|
||||||
|
"y": -3
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-11",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": 614,
|
||||||
|
"y": 200
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-12",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": 617,
|
||||||
|
"y": 405
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-13",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": -3,
|
||||||
|
"y": -202
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-14",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": 200,
|
||||||
|
"y": -203
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-15",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": 402,
|
||||||
|
"y": -205
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"element": 4,
|
||||||
|
"is-folder": false,
|
||||||
|
"name": "子图层-16",
|
||||||
|
"styles": [
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"filpX": false,
|
||||||
|
"filpY": false,
|
||||||
|
"offset": {
|
||||||
|
"x": 606,
|
||||||
|
"y": -206
|
||||||
|
},
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": {
|
||||||
|
"x": 1,
|
||||||
|
"y": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is-folder": true,
|
"is-folder": true,
|
||||||
|
@ -339,13 +479,13 @@
|
||||||
"filpX": false,
|
"filpX": false,
|
||||||
"filpY": false,
|
"filpY": false,
|
||||||
"offset": {
|
"offset": {
|
||||||
"x": 195,
|
"x": 116,
|
||||||
"y": 170
|
"y": 288
|
||||||
},
|
},
|
||||||
"rotation": 60,
|
"rotation": 60,
|
||||||
"scale": {
|
"scale": {
|
||||||
"x": 1,
|
"x": 1.85202,
|
||||||
"y": 1
|
"y": 1.85202
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,11 @@ layout(location = 0) uniform ivec2 pixelOffset;
|
||||||
|
|
||||||
layout(std140, binding = 1) uniform ubo
|
layout(std140, binding = 1) uniform ubo
|
||||||
{
|
{
|
||||||
vec3 backgroundColor;
|
float backgroundRed;
|
||||||
|
float backgroundGreen;
|
||||||
|
float backgroundBlue;
|
||||||
|
float backgroundMetallic;
|
||||||
|
float backgroundRoughness;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(rgba8, binding = 0) uniform image2D gBaseColor;
|
layout(rgba8, binding = 0) uniform image2D gBaseColor;
|
||||||
|
@ -1247,8 +1251,7 @@ bool strokeElement(vec2 localUV, uint contourIndex, uint linesOffset, uint point
|
||||||
if (onBegin)
|
if (onBegin)
|
||||||
hit = hit && shouldFillBeginCap(localUV, onVeryBegin, endType, p[0], tangentBegin, tangentEndLast);
|
hit = hit && shouldFillBeginCap(localUV, onVeryBegin, endType, p[0], tangentBegin, tangentEndLast);
|
||||||
if (onEnd)
|
if (onEnd)
|
||||||
hit = hit && shouldFillEndCap(localUV, onVeryEnd, endType, p[3], tangentEnd,
|
hit = hit && shouldFillEndCap(localUV, onVeryEnd, endType, p[3], tangentEnd, tangentBeginNext);
|
||||||
tangentBeginNext);
|
|
||||||
if (hit)
|
if (hit)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1371,8 +1374,11 @@ void main()
|
||||||
vec3 debugBVH = vec3(0);
|
vec3 debugBVH = vec3(0);
|
||||||
// bool debugHit = false;
|
// bool debugHit = false;
|
||||||
// vec4 color = vec4(0.76, 0.33, 0.15, -1);
|
// vec4 color = vec4(0.76, 0.33, 0.15, -1);
|
||||||
vec4 color = vec4(backgroundColor, -1);
|
vec4 color = vec4(backgroundRed, backgroundGreen, backgroundBlue, -1);
|
||||||
vec2 metallicRoughness = vec2(0, 0.8);
|
vec2 metallicRoughness = vec2(backgroundMetallic, backgroundRoughness);
|
||||||
|
int zIndex = 1<<15;
|
||||||
|
// vec4 color = vec4(0.72f, 0.66f, 0.55f, -1);
|
||||||
|
// vec2 metallicRoughness = vec2(0,0.5);
|
||||||
stack.top = 0;
|
stack.top = 0;
|
||||||
uint index = 0, visitTime = 0;
|
uint index = 0, visitTime = 0;
|
||||||
// uint bvhLength = paintingOffsets[paintingIndex-1].y;
|
// uint bvhLength = paintingOffsets[paintingIndex-1].y;
|
||||||
|
@ -1391,24 +1397,25 @@ void main()
|
||||||
debugBVH.g += 0.3;
|
debugBVH.g += 0.3;
|
||||||
|
|
||||||
if (leftChild >= bvhLength)
|
if (leftChild >= bvhLength)
|
||||||
|
{
|
||||||
|
uint elementZIndex = bvhChildren[index].y >> 18;
|
||||||
|
if (elementZIndex <= zIndex)
|
||||||
{
|
{
|
||||||
uint transformIndex = leftChild - 0x80000000;
|
uint transformIndex = leftChild - 0x80000000;
|
||||||
uint zIndex = bvhChildren[index].y >> 18;
|
uint elementIndex = bvhChildren[index].y - elementZIndex;
|
||||||
uint elementIndex = bvhChildren[index].y - zIndex;
|
|
||||||
mat3x2 transform = elementTranform[transformIndex];
|
mat3x2 transform = elementTranform[transformIndex];
|
||||||
vec2 localUV =
|
vec2 localUV =
|
||||||
(mat3(vec3(transform[0], 0), vec3(transform[1], 0), vec3(transform[2], 1)) * vec3(uv, 1)).xy;
|
(mat3(vec3(transform[0], 0), vec3(transform[1], 0), vec3(transform[2], 1)) * vec3(uv, 1))
|
||||||
|
.xy;
|
||||||
|
|
||||||
vec3 elementColor;
|
vec3 elementColor;
|
||||||
vec2 elementMetallicRoughness;
|
vec2 elementMetallicRoughness;
|
||||||
if (drawElement(elementIndex, localUV, elementColor, elementMetallicRoughness, debugBVH))
|
if (drawElement(elementIndex, localUV, elementColor, elementMetallicRoughness, debugBVH))
|
||||||
{
|
{
|
||||||
color = vec4(elementColor, zIndex);
|
color = vec4(elementColor, elementZIndex);
|
||||||
metallicRoughness = elementMetallicRoughness;
|
metallicRoughness = elementMetallicRoughness;
|
||||||
}
|
}
|
||||||
// if(elementIndex == 1 && transformIndex==1)
|
}
|
||||||
// color = vec4(1,1,0,1);
|
|
||||||
|
|
||||||
index = bvhLength;
|
index = bvhLength;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -32,10 +32,9 @@ QJsonObject PaintingUtil::readJsonFile(QString jsonFilePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
|
Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
|
||||||
Painting painting;
|
|
||||||
glm::bvec2 flip(0, 0);
|
|
||||||
QJsonObject jsonObj = readJsonFile(jsonFilePath);
|
QJsonObject jsonObj = readJsonFile(jsonFilePath);
|
||||||
qDebug() << jsonObj;
|
//qDebug() << jsonObj;
|
||||||
|
Painting painting(Renderer::Material(jsonObj.value("background-color").toVariant().value<QColor>()));
|
||||||
shared_ptr<ElementManager> elementManager = make_shared<ElementManager>(jsonObj, QFileInfo(jsonFilePath).absolutePath());
|
shared_ptr<ElementManager> elementManager = make_shared<ElementManager>(jsonObj, QFileInfo(jsonFilePath).absolutePath());
|
||||||
shared_ptr<LayerManager> layerManager = make_shared<LayerManager>(jsonObj, elementManager.get());
|
shared_ptr<LayerManager> layerManager = make_shared<LayerManager>(jsonObj, elementManager.get());
|
||||||
//qDebug() << elementManager->toJson();
|
//qDebug() << elementManager->toJson();
|
||||||
|
|
|
@ -244,8 +244,7 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
return iter->second;
|
return iter->second;
|
||||||
|
|
||||||
Painting painting;
|
Painting painting;
|
||||||
//path = "../test.json";
|
if (auto file = QFileInfo(directory.filePath(path.c_str())); file.isFile())
|
||||||
if (auto file = QFileInfo(QString(path.c_str())); file.isFile())
|
|
||||||
painting = PaintingUtil::transfromToPainting(file.filePath());
|
painting = PaintingUtil::transfromToPainting(file.filePath());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -280,13 +279,13 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
std::make_shared<Element>(Element{ contours[2].first, style[0], contours[2].second}),
|
std::make_shared<Element>(Element{ contours[2].first, style[0], contours[2].second}),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (path == "0.json")
|
if (path == "0.json" && false)
|
||||||
{
|
{
|
||||||
//painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.45,-0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
//painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.45,-0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
||||||
//painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45, 0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
//painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45, 0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
||||||
//painting.addElement(*element[2], ElementTransform{ glm::vec2(0.50,-0.45), glm::vec2(0.6,0.7) / 2.f, 0, glm::bvec2(false), 0 });
|
//painting.addElement(*element[2], ElementTransform{ glm::vec2(0.50,-0.45), glm::vec2(0.6,0.7) / 2.f, 0, glm::bvec2(false), 0 });
|
||||||
}
|
}
|
||||||
else if (path == "1.json")
|
else if (path == "1.json" || true)
|
||||||
{
|
{
|
||||||
//painting.backgroundColor = QColor(196, 81, 35);
|
//painting.backgroundColor = QColor(196, 81, 35);
|
||||||
float widths[] = { 0.22, 0.22 * 0.25 / 0.15, 0.22 * 0.25 / 0.15 };
|
float widths[] = { 0.22, 0.22 * 0.25 / 0.15, 0.22 * 0.25 / 0.15 };
|
||||||
|
|
|
@ -9,7 +9,7 @@ using namespace Renderer;
|
||||||
|
|
||||||
constexpr int kMaxLineCount = 20;
|
constexpr int kMaxLineCount = 20;
|
||||||
|
|
||||||
Painting::Painting(QColor backgroundColor) : backgroundColor(backgroundColor)
|
Painting::Painting(Material background) : background(background)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void Painting::generateBuffers(QOpenGLFunctions_4_5_Core* glFunc)
|
||||||
elementData.insert(elementData.end(), encodedStyle.begin(), encodedStyle.end());
|
elementData.insert(elementData.end(), encodedStyle.begin(), encodedStyle.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & i : elementTransformPool)
|
for (auto& i : elementTransformPool)
|
||||||
elementTransform.emplace_back(i.first);
|
elementTransform.emplace_back(i.first);
|
||||||
|
|
||||||
for (auto& i : elementPool)
|
for (auto& i : elementPool)
|
||||||
|
@ -142,8 +142,8 @@ void Painting::generateBuffers(QOpenGLFunctions_4_5_Core* glFunc)
|
||||||
glFunc->glNamedBufferData(buffers[3], elementOffsets.size() * sizeof(elementOffsets[0]), elementOffsets.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[3], elementOffsets.size() * sizeof(elementOffsets[0]), elementOffsets.data(), GL_STATIC_READ);
|
||||||
glFunc->glNamedBufferData(buffers[4], elementIndex.size() * sizeof(elementIndex[0]), elementIndex.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[4], elementIndex.size() * sizeof(elementIndex[0]), elementIndex.data(), GL_STATIC_READ);
|
||||||
glFunc->glNamedBufferData(buffers[5], elementData.size() * sizeof(elementData[0]), elementData.data(), GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[5], elementData.size() * sizeof(elementData[0]), elementData.data(), GL_STATIC_READ);
|
||||||
glm::vec3 color(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF());
|
GLfloat backgroundBuffer[] = { (GLfloat)background.color.redF(), (GLfloat)background.color.greenF(), (GLfloat)background.color.blueF(), background.metallicF(), background.roughnessF() };
|
||||||
glFunc->glNamedBufferData(buffers[6], sizeof(glm::vec3), &color, GL_STATIC_READ);
|
glFunc->glNamedBufferData(buffers[6], 5 * sizeof(GLfloat), backgroundBuffer, GL_STATIC_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint Renderer::Painting::getElementCount()
|
GLuint Renderer::Painting::getElementCount()
|
||||||
|
|
|
@ -54,9 +54,10 @@ namespace Renderer
|
||||||
std::vector<GLfloat> elementData;
|
std::vector<GLfloat> elementData;
|
||||||
int paintingId = 0;
|
int paintingId = 0;
|
||||||
std::array<GLuint, 7> buffers;
|
std::array<GLuint, 7> buffers;
|
||||||
QColor backgroundColor;
|
//QColor backgroundColor;
|
||||||
|
Material background;
|
||||||
|
|
||||||
Painting(QColor backgroundColor = Qt::white);
|
Painting(Material background = Material(Qt::white));
|
||||||
void addElement(const BaseElement& element, const ElementTransform& transform);
|
void addElement(const BaseElement& element, const ElementTransform& transform);
|
||||||
void generateBuffers(QOpenGLFunctions_4_5_Core* glFunc);
|
void generateBuffers(QOpenGLFunctions_4_5_Core* glFunc);
|
||||||
GLuint getElementCount();
|
GLuint getElementCount();
|
||||||
|
|
Loading…
Reference in New Issue