显示bvh
parent
ad3fe46efe
commit
0004db2aa2
|
@ -1209,14 +1209,15 @@ void main()
|
||||||
{
|
{
|
||||||
uint zIndex = bvhChildren[index].y >> 18;
|
uint zIndex = bvhChildren[index].y >> 18;
|
||||||
bvec2 flip = bvec2(bvhChildren[index].y & (1<<16), bvhChildren[index].y & (1<<17));
|
bvec2 flip = bvec2(bvhChildren[index].y & (1<<16), bvhChildren[index].y & (1<<17));
|
||||||
float angle = (float(bvhChildren[index].y) / 65535.0 - zIndex) * 2 * PI;
|
float angle = (float(bvhChildren[index].y&((1<<16)-1)) / 65535.0) * 2 * PI;
|
||||||
mat2 rotation = {{cos(angle), -sin(angle)}, {sin(angle), cos(angle)}};
|
mat2 rotation = {{cos(angle), -sin(angle)}, {sin(angle), cos(angle)}};
|
||||||
vec2 localUV = uv - (bound.xy + bound.zw) / 2;
|
vec2 localUV = uv - (bound.xy + bound.zw) / 2;
|
||||||
localUV = rotation * localUV;
|
localUV = rotation * localUV;
|
||||||
localUV /= (bound.zw - bound.xy) / 2;
|
localUV /= (bound.zw - bound.xy) / 2;
|
||||||
if (all(lessThan(vec2(-1), localUV)) && all(lessThan(localUV, vec2(1))) && zIndex>color.w)
|
if (all(lessThan(vec2(-1), localUV)) && all(lessThan(localUV, vec2(1))) && zIndex>color.w)
|
||||||
{
|
{
|
||||||
if (any(greaterThan(bound.xy+vec2(0.005), uv)) || any(greaterThan(uv, bound.zw-vec2(0.005))))
|
//if (any(greaterThan(bound.xy+vec2(0.005), uv)) || any(greaterThan(uv, bound.zw-vec2(0.005))))
|
||||||
|
if (any(greaterThan(vec2(-1)+vec2(0.005), localUV)) || any(greaterThan(localUV, vec2(1)-vec2(0.005))))
|
||||||
debugBVH.g += 0.3;
|
debugBVH.g += 0.3;
|
||||||
//uint elementIndex = leftChild - bvhLength;
|
//uint elementIndex = leftChild - bvhLength;
|
||||||
//debugBVH.bg += 0.5 * (localUV + vec2(1));
|
//debugBVH.bg += 0.5 * (localUV + vec2(1));
|
||||||
|
@ -1257,7 +1258,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));
|
||||||
|
|
|
@ -411,7 +411,7 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
// //rootBvhTreeData.push_back(BvhTreeData(QVector4D(x, y, z, w), 0, encodeZIndexAngle(1, (float)rand() / RAND_MAX * 360)));
|
// //rootBvhTreeData.push_back(BvhTreeData(QVector4D(x, y, z, w), 0, encodeZIndexAngle(1, (float)rand() / RAND_MAX * 360)));
|
||||||
// painting.addElement(element[i%3], QVector4D(x, y, z, w), (float)rand() / RAND_MAX * 360, 1);
|
// painting.addElement(element[i%3], QVector4D(x, y, z, w), (float)rand() / RAND_MAX * 360, 1);
|
||||||
//}
|
//}
|
||||||
painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(true, false), 0 });
|
painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.5,-0.45), glm::vec2(0.6,0.7), 45, glm::bvec2(true, false), 0 });
|
||||||
painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45,0.45), glm::vec2(0.5,0.5), 0, glm::bvec2(false), 0 });
|
painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45,0.45), glm::vec2(0.5,0.5), 0, glm::bvec2(false), 0 });
|
||||||
painting.addElement(*element[2], ElementTransform{ glm::vec2(0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(false), 0 });
|
painting.addElement(*element[2], ElementTransform{ glm::vec2(0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(false), 0 });
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ vector<BvhTreeData> LineTree::getPointLineAndBvhTree(vector<float>& resPoints, v
|
||||||
for (auto& nowTreeNode : restOfTreeNodes) {
|
for (auto& nowTreeNode : restOfTreeNodes) {
|
||||||
BvhTreeData oneData;
|
BvhTreeData oneData;
|
||||||
oneData.leftSon = resLines.size();
|
oneData.leftSon = resLines.size();
|
||||||
//oneData.rightSon = rightSon;
|
oneData.rightSon = 0;
|
||||||
oneData.bound = nowTreeNode.bound;
|
oneData.bound = nowTreeNode.bound;
|
||||||
std::cout << nowTreeNode.lineSet.size() << ' ';
|
std::cout << nowTreeNode.lineSet.size() << ' ';
|
||||||
resLines.push_back(nowTreeNode.lineSet.size());
|
resLines.push_back(nowTreeNode.lineSet.size());
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace UnitTest
|
||||||
{1.00, Material{QColor(255,255,0)}},
|
{1.00, Material{QColor(255,255,0)}},
|
||||||
};
|
};
|
||||||
return { BaseStyle(std::make_shared<TransformStyle>(),
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||||
std::make_shared<MaterialStyleStroke>(4, StrokeType::kLeftSide, StrokeEndType::kRound,
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kLeftSide, StrokeEndType::kRound,
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, true))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, true))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
|
|
|
@ -29,15 +29,15 @@ namespace UnitTest
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
QQuickSvgParser::parsePathDataFast("M100,100C-.5,100,0,100.5,0,0L40,.07C40,59.5,39.5,60,100,60Z", path);
|
QQuickSvgParser::parsePathDataFast("M100,100C-.5,100,0,100.5,0,0L40,.07C40,59.5,39.5,60,100,60Z", path);
|
||||||
/*QTransform transform;
|
QTransform transform;
|
||||||
transform.scale(10, 10);
|
transform.scale(5, 5);
|
||||||
transform.map(path);*/
|
path = transform.map(path);
|
||||||
float pixelRatio = 30;
|
float pixelRatio = devicePixelRatioF();
|
||||||
auto [img, pos] = renderer.drawElement(path, style, pixelRatio, false);
|
auto [img, pos] = renderer.drawElement(path, style, pixelRatio, false);
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
painter.drawImage(QRectF(QPointF(0, 0), img.size()/devicePixelRatioF()), img);
|
painter.drawImage(QRectF(QPointF(0, 0), img.size()/pixelRatio), img);
|
||||||
};
|
};
|
||||||
void resizeGL(int w, int h) override {};
|
void resizeGL(int w, int h) override {};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue