Skip to content

Commit a176efa

Browse files
committed
Add partial derivative AOVs
1 parent 2c1b63f commit a176efa

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/integrators/aov.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Currently, the following AOVs types are available:
5656
- :monosp:`uv`: UV coordinates.
5757
- :monosp:`geo_normal`: Geometric normal.
5858
- :monosp:`sh_normal`: Shading normal.
59+
- :monosp:`dp_du`, :monosp:`dp_dv`: Position partials wrt. the UV parameterization.
60+
- :monosp:`duv_dx`, :monosp:`duv_dy`: UV partials wrt. changes in screen-space.
5961
6062
*/
6163

@@ -71,6 +73,10 @@ class AOVIntegrator final : public SamplingIntegrator<Float, Spectrum> {
7173
UV,
7274
GeometricNormal,
7375
ShadingNormal,
76+
dPdU,
77+
dPdV,
78+
dUVdx,
79+
dUVdy,
7480
IntegratorRGBA
7581
};
7682

@@ -105,6 +111,24 @@ class AOVIntegrator final : public SamplingIntegrator<Float, Spectrum> {
105111
m_aov_names.push_back(item[0] + ".X");
106112
m_aov_names.push_back(item[0] + ".Y");
107113
m_aov_names.push_back(item[0] + ".Z");
114+
} else if (item[1] == "dp_du") {
115+
m_aov_types.push_back(Type::dPdU);
116+
m_aov_names.push_back(item[0] + ".X");
117+
m_aov_names.push_back(item[0] + ".Y");
118+
m_aov_names.push_back(item[0] + ".Z");
119+
} else if (item[1] == "dp_dv") {
120+
m_aov_types.push_back(Type::dPdV);
121+
m_aov_names.push_back(item[0] + ".X");
122+
m_aov_names.push_back(item[0] + ".Y");
123+
m_aov_names.push_back(item[0] + ".Z");
124+
} else if (item[1] == "duv_dx") {
125+
m_aov_types.push_back(Type::dUVdx);
126+
m_aov_names.push_back(item[0] + ".U");
127+
m_aov_names.push_back(item[0] + ".V");
128+
} else if (item[1] == "duv_dy") {
129+
m_aov_types.push_back(Type::dUVdy);
130+
m_aov_names.push_back(item[0] + ".U");
131+
m_aov_names.push_back(item[0] + ".V");
108132
} else {
109133
Throw("Invalid AOV type \"%s\"!", item[1]);
110134
}
@@ -172,6 +196,28 @@ class AOVIntegrator final : public SamplingIntegrator<Float, Spectrum> {
172196
*aovs++ = si.sh_frame.n.z();
173197
break;
174198

199+
case Type::dPdU:
200+
*aovs++ = si.dp_du.x();
201+
*aovs++ = si.dp_du.y();
202+
*aovs++ = si.dp_du.z();
203+
break;
204+
205+
case Type::dPdV:
206+
*aovs++ = si.dp_dv.x();
207+
*aovs++ = si.dp_dv.y();
208+
*aovs++ = si.dp_dv.z();
209+
break;
210+
211+
case Type::dUVdx:
212+
*aovs++ = si.duv_dx.x();
213+
*aovs++ = si.duv_dx.y();
214+
break;
215+
216+
case Type::dUVdy:
217+
*aovs++ = si.duv_dy.x();
218+
*aovs++ = si.duv_dy.y();
219+
break;
220+
175221
case Type::IntegratorRGBA: {
176222
std::pair<Spectrum, Mask> result_sub =
177223
m_integrators[ctr].first->sample(scene, sampler, ray, aovs, active);

0 commit comments

Comments
 (0)