compute_triangle_info及dispatch_primitive的若干问题


template \u0026lt;int N\u0026gt;
void compute_derivative_n(vs_output\u0026amp; ddx, vs_output\u0026amp; ddy, vs_output const\u0026amp; e01, vs_output const\u0026amp; e02, float inv_area)
{
问题03:tri_info-\u0026gt;ddx的计算公式难以理解,
根据之前的解释,ddx是f对于x的一阶偏微分,
但是看到下面的公式不知道怎么对应微分方程?
compute_triangle_info及dispatch_primitive的若干问题

直接根据edge01和edge02得到ddx
\t// ddx = (e02 * e01.position.y - e02.position.y * e01) * inv_area;
\t// ddy = (e01 * e02.position.x - e01.position.x * e02) * inv_area;
}


void rasterizer::threaded_dispatch_primitive(thread_context const* thread_ctx)
{
if (3 == prim_size_)
{
\tvec4 const* edge_factors = tri_infos_.edge_factors;

\tbool const mark_x =
\t{
\t\tedge_factors.x() \u0026gt; 0, edge_factors.x() \u0026gt; 0, edge_factors.x() \u0026gt; 0
\t};

\tbool const mark_y =
\t{
\t\tedge_factors.y() \u0026gt; 0, edge_factors.y() \u0026gt; 0, edge_factors.y() \u0026gt; 0
\t};
问题04:在dispatch primitive阶段判断tri属于哪个tile的
时候,无法理解具体判断的实现思路
对rejection和acception的概念无法理解
tri的索引 i 在push_back进去的时候为什么还要左移一位
\tfloat step_x;
\tfloat step_y;
\tfloat rej_to_acc;
\tfor (int e = 0; e \u0026lt; 3; ++ e)
\t{
\t\tstep_x = TILE_SIZE * edge_factors.x();
\t\tstep_y = TILE_SIZE * edge_factors.y();
\t\trej_to_acc = -abs(step_x) - abs(step_y);
\t}

\tfor (int y = sy; y \u0026lt; ey; ++ y)
\t{
\t\tfor (int x = sx; x \u0026lt; ex; ++ x)
\t\t{
【compute_triangle_info及dispatch_primitive的若干问题】 \t\t\tint rejection = 0;
\t\t\tint acception = 1;

\t\t\t// Trival rejection \u0026amp; acception
\t\t for (int e = 0; e \u0026lt; 3; ++ e)
\t\t\t{
\t\t\t\tfloat evalue = https://www.zhihu.com/api/v4/questions/264001649/edge_factors.z() - ((x + mark_x) * TILE_SIZE * edge_factors.x() + (y + mark_y) * TILE_SIZE * edge_factors.y());
\t\t\t\trejection |= (0 \u0026lt; evalue);
\t\t\t\tacception \u0026amp;= (rej_to_acc \u0026gt;= evalue);
\t\t\t}

\t\t\tif (!rejection)
\t\t\t{
\t\t\t\ttiled_prims.push_back((i \u0026lt;\u0026lt; 1) | acception);
\t\t\t}
\t\t}
\t}
}


    推荐阅读