Skip to content

Commit

Permalink
Raytracing: some renames for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
unhyperbolic committed May 2, 2024
1 parent 9c25c31 commit 17a967d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
35 changes: 17 additions & 18 deletions python/raytracing/ideal_raytracing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def from_manifold(manifold,
r.peripheral_gluing_equations = snappy_trig.gluing_equations()[
snappy_trig.num_tetrahedra():]

r.log_shapes = [
tet.ShapeParameters[e].log()
for tet in c.mcomplex.Tetrahedra
for e in [ t3m.E01, t3m.E02, t3m.E03 ] ]

r._add_complex_vertices()
r._add_R13_vertices()
r._add_O13_matrices_to_faces()
Expand All @@ -112,7 +117,7 @@ def from_manifold(manifold,
r._add_cusp_to_tet_matrices()
r._add_margulis_tube_ends()
r._add_inspheres()
r._add_log_holonomies()
r._add_to_standard_torus_matrices()

r._add_cusp_triangle_vertex_positions()

Expand Down Expand Up @@ -200,23 +205,23 @@ def _add_inspheres(self):

tet.cosh_sqr_inradius = tmp.cosh() ** 2

def _add_log_holonomies_to_cusp(self, cusp, shapes):
def _add_to_standard_torus_matrix(self, cusp):
i = cusp.Index

if cusp.is_complete:
m_param, l_param = cusp.Translations
else:
m_param, l_param = (
sum(shape * expo
for shape, expo
in zip(shapes, self.peripheral_gluing_equations[2 * i + j]))
sum(log_shape * expo
for log_shape, expo
in zip(self.log_shapes, self.peripheral_gluing_equations[2 * i + j]))
for j in range(2) )

a, c = m_param.real(), m_param.imag()
b, d = l_param.real(), l_param.imag()

det = a*d - b * c
cusp.mat_log = matrix([[d,-b], [-c, a]]) / det
cusp.to_standard_torus_matrix = matrix([[d,-b], [-c, a]]) / det

if cusp.is_complete:
cusp.margulisTubeRadiusParam = 0.0
Expand All @@ -228,15 +233,9 @@ def _add_log_holonomies_to_cusp(self, cusp, shapes):
rSqr = 1 + (x ** 2 + (1 - y) ** 2) / (2 * y)
cusp.margulisTubeRadiusParam = 0.25 * (1.0 + rSqr)

def _add_log_holonomies(self):
shapes = [
tet.ShapeParameters[e].log()
for tet in self.mcomplex.Tetrahedra
for e in [ t3m.E01, t3m.E02, t3m.E03 ] ]

for cusp, cusp_info in zip(self.mcomplex.Vertices,
self.snappy_manifold.cusp_info()):
self._add_log_holonomies_to_cusp(cusp, shapes)
def _add_to_standard_torus_matrices(self):
for cusp in self.mcomplex.Vertices:
self._add_to_standard_torus_matrix(cusp)

def get_uniform_bindings(self):
# _check_consistency(self.mcomplex)
Expand Down Expand Up @@ -294,8 +293,8 @@ def get_uniform_bindings(self):
for V in t3m.ZeroSubsimplices
]

mat_logs = [
tet.Class[V].mat_log
toStandardTorusMatrices = [
tet.Class[V].to_standard_torus_matrix
for tet in self.mcomplex.Tetrahedra
for V in t3m.ZeroSubsimplices ]

Expand All @@ -316,7 +315,7 @@ def get_uniform_bindings(self):
d['cuspTranslations'] = ('mat2[]', cusp_translations)
d['logAdjustments'] = ('vec2[]', logAdjustments)
d['cuspTriangleVertexPositions'] = ('mat3x2[]', cuspTriangleVertexPositions)
d['matLogs'] = ('mat2[]', mat_logs)
d['toStandardTorusMatrices'] = ('mat2[]', toStandardTorusMatrices)
d['insphereRadiusParams'] = ('float[]', insphereRadiusParams)
d['isNonGeometric'] = ('bool', isNonGeometric)
d['nonGeometricTexture'] = ('int', 0)
Expand Down
6 changes: 3 additions & 3 deletions python/raytracing/shaders/fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ layout (std140) uniform TetCuspMatrices
};

uniform vec2 logAdjustments[4 * ##num_tets##];
uniform mat2 matLogs[4 * ##num_tets##];
uniform mat2 toStandardTorusMatrices[4 * ##num_tets##];

const float peripheralCurveThickness = 0.015;

Expand Down Expand Up @@ -725,7 +725,7 @@ MLCoordinatesForRayHit(RayHit rayHit)
z = complexLog(z) + logAdjustments[index];
}

return z * matLogs[index];
return z * toStandardTorusMatrices[index];
}

int
Expand Down Expand Up @@ -1537,7 +1537,7 @@ leaveVertexNeighborhood(inout RayHit rayHit)
// Compute suitable multiple of merdian and longitude translation
// bringing the exit point into the fundamental parallelogram
// near zero.
vec2 c = -round(ml) * inverse(matLogs[index]);
vec2 c = -round(ml) * inverse(toStandardTorusMatrices[index]);

mat4 tsfmCuspSpace =
(rayHit.object_type == object_type_horosphere_exit)
Expand Down

0 comments on commit 17a967d

Please sign in to comment.