karlis 2023-03-15 20:10:18 +08:00
commit b9c8624dae
5 changed files with 17 additions and 14 deletions

View File

@ -1352,8 +1352,8 @@ 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(1,1,1, -1); vec4 color = vec4(1,1,1, -1);
vec2 metallicRoughness = vec2(0, 0.8); vec2 metallicRoughness = vec2(0, 0.8);
stack.top = 0; stack.top = 0;
uint index = 0, visitTime = 0; uint index = 0, visitTime = 0;
@ -1423,7 +1423,7 @@ void main()
imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1)); imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1));
imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1)); imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1));
//return; return;
if (/*color.a!=-1&&*/ debugBVH == vec3(0)) if (/*color.a!=-1&&*/ debugBVH == vec3(0))
{ {
// imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1)); // imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1));

View File

@ -14,6 +14,7 @@ uniform mat4 projection;
void main() void main()
{ {
TexCoords = aTexCoords; TexCoords = aTexCoords;
TexCoords.y = -TexCoords.y;
WorldPos = vec3(model * vec4(aPos, 1.0)); WorldPos = vec3(model * vec4(aPos, 1.0));
Normal = mat3(model) * aNormal; Normal = mat3(model) * aNormal;

View File

@ -8,7 +8,7 @@ PixelPath SimpleElement::getPaintObject() const
{ {
PixelPath result; PixelPath result;
result.addPath(painterPath); result.addPath(painterPath);
qDebug() << result.getPainterPath(); //qDebug() << result.getPainterPath();
return result; return result;
} }
@ -65,7 +65,8 @@ PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>
std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke std::dynamic_pointer_cast<StrokeElementLayerStyle>(style)->materialStyles[0]->materialStroke
)->materialMap[1.0].color;*/ )->materialMap[1.0].color;*/
} }
auto [img, mov] = renderer->drawElement(painterPath, *style, 1.0);
auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, *style, 1.0);
//qDebug() << img << " ------"; //qDebug() << img << " ------";
result.addImage(img, mov); result.addImage(img, mov);
result.addPath(painterPath); result.addPath(painterPath);
@ -149,7 +150,7 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const vector<
scale /= transform.m33(); scale /= transform.m33();
double maxScale = std::max(scale.x(), scale.y()); double maxScale = std::max(scale.x(), scale.y());
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio(); double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
auto [img, mov] = renderer->drawElement(painterPath, *style, pixelRatio); auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, *style, pixelRatio);
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio)); painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
//img = img.scaled(img.width() / pixelRatio, img.height() / pixelRatio, Qt::KeepAspectRatio, Qt::SmoothTransformation); //img = img.scaled(img.width() / pixelRatio, img.height() / pixelRatio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
painter->drawImage(mov, img); painter->drawImage(mov, img);

View File

@ -268,7 +268,7 @@ void FolderLayerWrapper::paint(QPainter* painter, QTransform transform)
{ {
LayerWrapper::paint(painter, transform); LayerWrapper::paint(painter, transform);
transform = property.transform * transform; transform = property.transform * transform;
qDebug() << transform; //qDebug() << transform;
for (auto& child : children) for (auto& child : children)
child->paint(painter, transform); child->paint(painter, transform);
} }
@ -277,7 +277,7 @@ void LeafLayerWrapper::paint(QPainter* painter, QTransform transform)
{ {
LayerWrapper::paint(painter, transform); LayerWrapper::paint(painter, transform);
transform = property.transform * transform; transform = property.transform * transform;
qDebug() << transform; //qDebug() << transform;
if (wrappedElement != nullptr) if (wrappedElement != nullptr)
{ {
wrappedElement->paint(painter, transform, styles); wrappedElement->paint(painter, transform, styles);

View File

@ -34,7 +34,6 @@ QJsonObject PaintingUtil::readJsonFile(QString jsonFilePath) {
Painting PaintingUtil::transfromToPainting(QString jsonFilePath) { Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
Painting painting; Painting painting;
QTransform transform;
glm::bvec2 flip(0, 0); glm::bvec2 flip(0, 0);
QJsonObject jsonObj = readJsonFile(jsonFilePath); QJsonObject jsonObj = readJsonFile(jsonFilePath);
qDebug() << jsonObj; qDebug() << jsonObj;
@ -47,7 +46,7 @@ Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
queue<LayerNode> layerQueue; queue<LayerNode> layerQueue;
LayerWrapper* root = layerManager->getRoot(); LayerWrapper* root = layerManager->getRoot();
root->getCache(); root->getCache();
layerQueue.push({ root, transform, flip }); layerQueue.push({ root, root->property.transform, flip });
while (!layerQueue.empty()) { while (!layerQueue.empty()) {
auto layerNode = layerQueue.front(); auto layerNode = layerQueue.front();
layerQueue.pop(); layerQueue.pop();
@ -71,8 +70,10 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
if (leafLayer != nullptr) { if (leafLayer != nullptr) {
GroupElement* wrapperElement = dynamic_cast<GroupElement*>(leafLayer->wrappedElement); GroupElement* wrapperElement = dynamic_cast<GroupElement*>(leafLayer->wrappedElement);
if (wrapperElement != nullptr) if (wrapperElement != nullptr) {
transform = wrapperElement->sourceLayer->property.transform * transform;
return wrapperElement->sourceLayer; return wrapperElement->sourceLayer;
}
PixelPath pixelPath = nowLayer->getCache(); PixelPath pixelPath = nowLayer->getCache();
QPainterPath painterPath = pixelPath.getPainterPath(); QPainterPath painterPath = pixelPath.getPainterPath();
@ -90,7 +91,7 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
qDebug() << trans.map(painterPath); qDebug() << trans.map(painterPath);
element.contour = std::make_shared<vector<vector<Renderer::Point> >>(PainterPathUtil::transformToLines(trans.map(painterPath))); element.contour = std::make_shared<vector<vector<Renderer::Point> >>(PainterPathUtil::transformToLines(trans.map(painterPath)));
QSize screenSize = pixelPath.getPixmap().size(); QSize screenSize = QSize(1024, 1024);
element.style = std::make_shared<Renderer::ElementStyleStrokeDemo>(0.06); element.style = std::make_shared<Renderer::ElementStyleStrokeDemo>(0.06);
@ -105,8 +106,8 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
qDebug() << elementTrans.center.x << elementTrans.center.y; qDebug() << elementTrans.center.x << elementTrans.center.y;
decomposeTransform(transform, elementTrans.rotation, elementTrans.scale); decomposeTransform(transform, elementTrans.rotation, elementTrans.scale);
elementTrans.scale = glm::vec2( elementTrans.scale = glm::vec2(
bound.width() / screenSize.width(), bound.width() * 2 / screenSize.width(),
bound.height() / screenSize.height() bound.height() * 2 / screenSize.height()
); );
elementTrans.flip = glm::bvec2( elementTrans.flip = glm::bvec2(
nowLayer->property.flipHorizontally, nowLayer->property.flipHorizontally,