From 6fb326038e3be7dc11b893655ffbd9522daeb453 Mon Sep 17 00:00:00 2001 From: johannes hanika Date: Mon, 3 Nov 2014 17:40:20 +0100 Subject: [PATCH] hslt: misc improved functionality: texture formats matrix 2x2 inversion special case (wasn't called before) more meaningful flags on vertex. --- include/mitsuba/bidir/util.h | 2 +- include/mitsuba/bidir/vertex.h | 4 ++-- include/mitsuba/core/frame.h | 6 ++++++ include/mitsuba/core/matrix.h | 30 +++++++++++++++++++++++------- include/mitsuba/core/ray.h | 9 ++++++++- src/libhw/gltexture.cpp | 13 ++++++++++++- 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/include/mitsuba/bidir/util.h b/include/mitsuba/bidir/util.h index 9fc42cf7..981561a7 100644 --- a/include/mitsuba/bidir/util.h +++ b/include/mitsuba/bidir/util.h @@ -75,7 +75,7 @@ struct RestoreMeasureHelper { : vertex(vertex), measure(vertex->measure) { } ~RestoreMeasureHelper() { vertex->measure = measure; } PathVertex *vertex; - uint8_t measure; + EMeasure measure; }; MTS_NAMESPACE_END diff --git a/include/mitsuba/bidir/vertex.h b/include/mitsuba/bidir/vertex.h index 25bd73f2..68bf8216 100644 --- a/include/mitsuba/bidir/vertex.h +++ b/include/mitsuba/bidir/vertex.h @@ -91,7 +91,7 @@ struct MTS_EXPORT_BIDIR PathVertex { * * \sa EVertexType */ - uint8_t type : 7; + EVertexType type : 7; /** * \brief Denotes whether this vertex \a only supports @@ -129,7 +129,7 @@ struct MTS_EXPORT_BIDIR PathVertex { * * \sa EMeasure */ - uint8_t measure; + EMeasure measure : 8; /** * \brief When the current vertex supports sampling diff --git a/include/mitsuba/core/frame.h b/include/mitsuba/core/frame.h index 0e952682..13f3e73b 100644 --- a/include/mitsuba/core/frame.h +++ b/include/mitsuba/core/frame.h @@ -96,6 +96,12 @@ struct Frame { return v.z; } + /** \brief Assuming that the given direction is in the local coordinate + * system, return the u and v coordinates of the vector 'v' */ + inline static Vector2 uv(const Vector &v) { + return Vector2(v.x, v.y); + } + /** \brief Assuming that the given direction is in the local coordinate * system, return the squared sine of the angle between the normal and v */ inline static Float sinTheta2(const Vector &v) { diff --git a/include/mitsuba/core/matrix.h b/include/mitsuba/core/matrix.h index c14f0c97..37016264 100644 --- a/include/mitsuba/core/matrix.h +++ b/include/mitsuba/core/matrix.h @@ -37,7 +37,7 @@ public: /** * \brief Construct a new MxN matrix without initializing it. * - * This construtor is useful when the matrix will either not + * This constructor is useful when the matrix will either not * be used at all (it might be part of a larger data structure) * or initialized at a later point in time. Always make sure * that one of the two is the case! Otherwise your program will do @@ -291,7 +291,7 @@ public: * and a permutation vector piv of length m so that A(piv,:) = L*U. * If m < n, then L is m-by-m and U is m-by-n. * - * The LU decompostion with pivoting always exists, even if the matrix is + * The LU decomposition with pivoting always exists, even if the matrix is * singular, so the constructor will never fail. * The primary use of the * @@ -361,7 +361,7 @@ public: T cholDet() const; - /// Check if the matrix is identically zeor + /// Check if the matrix is identically zero inline bool isZero() const { for (int i=0; i { } /// Matrix-vector multiplication - inline Vector4 operator*(const Vector4 &v) const { + inline Vector4 operator*(const Vector4 &v) const { return Vector4( m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w, m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w, diff --git a/include/mitsuba/core/ray.h b/include/mitsuba/core/ray.h index 5ee42b1b..492bf305 100644 --- a/include/mitsuba/core/ray.h +++ b/include/mitsuba/core/ray.h @@ -165,7 +165,14 @@ struct RayDifferential : public Ray { ryOrigin = o + (ryOrigin - o) * amount; rxDirection = d + (rxDirection - d) * amount; ryDirection = d + (ryDirection - d) * amount; - } + } + + void scaleDifferentialUV(const Vector2 amountUV) { + rxOrigin = o + (rxOrigin - o) * amountUV.x; + ryOrigin = o + (ryOrigin - o) * amountUV.y; + rxDirection = d + (rxDirection - d) * amountUV.x; + ryDirection = d + (ryDirection - d) * amountUV.y; + } inline void operator=(const RayDifferential &ray) { o = ray.o; diff --git a/src/libhw/gltexture.cpp b/src/libhw/gltexture.cpp index 925cc39c..e6278ea4 100644 --- a/src/libhw/gltexture.cpp +++ b/src/libhw/gltexture.cpp @@ -362,7 +362,18 @@ void GLTexture::lookupGLConstants() { return; } - if (m_componentFormat == EFloat16) { + if (m_componentFormat == EUInt8) { + switch (m_pixelFormat) { + case ELuminance: m_internalFormat = GL_LUMINANCE8; break; + case ELuminanceAlpha: m_internalFormat = GL_LUMINANCE8_ALPHA8; break; + case ERGB: m_internalFormat = GL_RGB8; break; + case ERGBA: m_internalFormat = GL_RGBA8; break; + default: + Log(EError, "Unknown/unsupported pixel format!"); + return; + } + } + else if (m_componentFormat == EFloat16) { switch (m_pixelFormat) { case ELuminance: m_internalFormat = GL_LUMINANCE16F_ARB; break; case ELuminanceAlpha: m_internalFormat = GL_LUMINANCE_ALPHA16F_ARB; break;