Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mitsuba-shapenet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hardik Jain
mitsuba-shapenet
Commits
4ce69602
Commit
4ce69602
authored
10 years ago
by
johannes hanika
Committed by
Wenzel Jakob
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
hslt: util.h: add boilerplate coordinate derivative function
parent
4a0d0aa6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/mitsuba/core/util.h
+8
-0
8 additions, 0 deletions
include/mitsuba/core/util.h
src/libcore/util.cpp
+24
-0
24 additions, 0 deletions
src/libcore/util.cpp
src/librender/trimesh.cpp
+2
-2
2 additions, 2 deletions
src/librender/trimesh.cpp
with
34 additions
and
2 deletions
include/mitsuba/core/util.h
+
8
−
0
View file @
4ce69602
...
@@ -329,6 +329,14 @@ extern MTS_EXPORT_CORE bool solveLinearSystem2x2(const Float a[2][2], const Floa
...
@@ -329,6 +329,14 @@ extern MTS_EXPORT_CORE bool solveLinearSystem2x2(const Float a[2][2], const Floa
*/
*/
extern
MTS_EXPORT_CORE
void
coordinateSystem
(
const
Vector
&
a
,
Vector
&
b
,
Vector
&
c
);
extern
MTS_EXPORT_CORE
void
coordinateSystem
(
const
Vector
&
a
,
Vector
&
b
,
Vector
&
c
);
/**
* \brief Derivatives of a frame formed by coordinateSystem
* \param n Source tangent frame that was created with coordinateSystem
* \param ds derivative of the frame with respect to s. ds.n should already contain normal derivative along s
* \param dt derivative of the frame with respect to t. dt.n should already contain normal derivative along t
*/
extern
MTS_EXPORT_CORE
void
coordinateSystemDerivatives
(
const
Frame
&
frame
,
Frame
&
ds
,
Frame
&
dt
);
/**
/**
* \brief Generate (optionally jittered) stratified 1D samples
* \brief Generate (optionally jittered) stratified 1D samples
* \param random Source of random numbers
* \param random Source of random numbers
...
...
This diff is collapsed.
Click to expand it.
src/libcore/util.cpp
+
24
−
0
View file @
4ce69602
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include
<mitsuba/core/random.h>
#include
<mitsuba/core/random.h>
#include
<mitsuba/core/quad.h>
#include
<mitsuba/core/quad.h>
#include
<mitsuba/core/sse.h>
#include
<mitsuba/core/sse.h>
#include
<mitsuba/core/frame.h>
#include
<boost/bind.hpp>
#include
<boost/bind.hpp>
#include
<stdarg.h>
#include
<stdarg.h>
#include
<iomanip>
#include
<iomanip>
...
@@ -599,6 +600,29 @@ void coordinateSystem(const Vector &a, Vector &b, Vector &c) {
...
@@ -599,6 +600,29 @@ void coordinateSystem(const Vector &a, Vector &b, Vector &c) {
b
=
cross
(
c
,
a
);
b
=
cross
(
c
,
a
);
}
}
void
coordinateSystemDerivatives
(
const
Frame
&
frame
,
Frame
&
ds
,
Frame
&
dt
)
{
const
Vector
n
=
frame
.
n
;
const
Vector
s
=
frame
.
s
;
if
(
std
::
abs
(
n
.
x
)
>
std
::
abs
(
n
.
y
))
{
const
Float
invLen
=
1
/
std
::
sqrt
(
n
.
x
*
n
.
x
+
n
.
z
*
n
.
z
);
ds
.
s
=
Vector
(
ds
.
n
.
z
*
invLen
,
0
,
-
ds
.
n
.
x
*
invLen
);
ds
.
s
-=
s
*
dot
(
ds
.
s
,
s
);
dt
.
s
=
Vector
(
dt
.
n
.
z
*
invLen
,
0
,
-
dt
.
n
.
x
*
invLen
);
dt
.
s
-=
s
*
dot
(
dt
.
s
,
s
);
}
else
{
const
Float
invLen
=
1
/
std
::
sqrt
(
n
.
y
*
n
.
y
+
n
.
z
*
n
.
z
);
ds
.
s
=
Vector
(
0
,
ds
.
n
.
z
*
invLen
,
-
ds
.
n
.
y
*
invLen
);
ds
.
s
-=
s
*
dot
(
ds
.
s
,
s
);
dt
.
s
=
Vector
(
0
,
dt
.
n
.
z
*
invLen
,
-
dt
.
n
.
y
*
invLen
);
dt
.
s
-=
s
*
dot
(
dt
.
s
,
s
);
}
dt
.
t
=
cross
(
s
,
ds
.
n
)
+
cross
(
dt
.
s
,
n
);
ds
.
t
=
cross
(
s
,
dt
.
n
)
+
cross
(
ds
.
s
,
n
);
}
Point2
toSphericalCoordinates
(
const
Vector
&
v
)
{
Point2
toSphericalCoordinates
(
const
Vector
&
v
)
{
Point2
result
(
Point2
result
(
std
::
acos
(
v
.
z
),
std
::
acos
(
v
.
z
),
...
...
This diff is collapsed.
Click to expand it.
src/librender/trimesh.cpp
+
2
−
2
View file @
4ce69602
...
@@ -40,7 +40,7 @@ MTS_NAMESPACE_BEGIN
...
@@ -40,7 +40,7 @@ MTS_NAMESPACE_BEGIN
TriMesh
::
TriMesh
(
const
std
::
string
&
name
,
size_t
triangleCount
,
TriMesh
::
TriMesh
(
const
std
::
string
&
name
,
size_t
triangleCount
,
size_t
vertexCount
,
bool
hasNormals
,
bool
hasTexcoords
,
size_t
vertexCount
,
bool
hasNormals
,
bool
hasTexcoords
,
bool
hasVertexColors
,
bool
flipNormals
,
bool
faceNormals
)
bool
hasVertexColors
,
bool
flipNormals
,
bool
faceNormals
)
:
Shape
(
Properties
()),
m_triangleCount
(
triangleCount
),
:
Shape
(
Properties
()),
m_triangleCount
(
triangleCount
),
m_vertexCount
(
vertexCount
),
m_flipNormals
(
flipNormals
),
m_vertexCount
(
vertexCount
),
m_flipNormals
(
flipNormals
),
m_faceNormals
(
faceNormals
)
{
m_faceNormals
(
faceNormals
)
{
m_name
=
name
;
m_name
=
name
;
...
@@ -762,7 +762,7 @@ void TriMesh::getNormalDerivative(const Intersection &its,
...
@@ -762,7 +762,7 @@ void TriMesh::getNormalDerivative(const Intersection &its,
/* Recompute the barycentric coordinates, since 'its.uv' may have been
/* Recompute the barycentric coordinates, since 'its.uv' may have been
overwritten with coordinates of the texture "parameterization". */
overwritten with coordinates of the texture "parameterization". */
Vector
rel
=
its
.
p
-
p0
,
du
=
p1
-
p0
,
dv
=
p2
-
p0
;
Vector
rel
=
its
.
p
-
p0
,
du
=
p1
-
p0
,
dv
=
p2
-
p0
;
Float
b1
=
dot
(
du
,
rel
),
b2
=
dot
(
dv
,
rel
),
/* Normal equations */
Float
b1
=
dot
(
du
,
rel
),
b2
=
dot
(
dv
,
rel
),
/* Normal equations */
a11
=
dot
(
du
,
du
),
a12
=
dot
(
du
,
dv
),
a11
=
dot
(
du
,
du
),
a12
=
dot
(
du
,
dv
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment