Date
1 - 2 of 2
Add derivatives to I in shader globals (issue186262)
aco...@...
Reviewers: osl-dev_googlegroups.com,
Description: We were missing the derivatives in the I field which is important for background shader. This little patch fixes the problem. Please review this at http://codereview.appspot.com/186262/show Affected files: src/include/oslexec.h src/liboslexec/exec.cpp Index: src/include/oslexec.h =================================================================== --- src/include/oslexec.h (revision 538) +++ src/include/oslexec.h (working copy) @@ -195,6 +195,7 @@ public: VaryingRef<Vec3> P; ///< Position VaryingRef<Vec3> dPdx, dPdy; ///< Partials VaryingRef<Vec3> I; ///< Incident ray + VaryingRef<Vec3> dIdx, dIdy; ///< Partial derivatives for I VaryingRef<Vec3> N; ///< Shading normal VaryingRef<Vec3> Ng; ///< True geometric normal VaryingRef<float> u, v; ///< Surface parameters Index: src/liboslexec/exec.cpp =================================================================== --- src/liboslexec/exec.cpp (revision 538) +++ src/liboslexec/exec.cpp (working copy) @@ -195,8 +195,16 @@ ShadingExecution::bind (ShadingContext *context, ShaderUse use, sym.data (globals->P.ptr()); sym.step (globals->P.step()); } } else if (sym.name() == Strings::I) { - sym.has_derivs (false); - sym.data (globals->I.ptr()); sym.step (globals->I.step()); + if (globals->dIdx.ptr() && globals->dIdy.ptr()) { + sym.has_derivs (true); + void *addr = m_context->heap_allot (sym, true); + VaryingRef<Dual2<Vec3> > I ((Dual2<Vec3> *)addr, sym.step()); + for (int i = 0; i < npoints(); ++i) + I[i].set (globals->I[i], globals->dIdx[i], globals->dIdy[i]); + } else { + sym.has_derivs (false); + sym.data (globals->I.ptr()); sym.step (globals->I.step()); + } } else if (sym.name() == Strings::N) { sym.has_derivs (false); sym.data (globals->N.ptr()); sym.step (globals->N.step()); |
|
cku...@...
|
|