Skip to content

Commit

Permalink
Inside view: Making switching between the dummy raytracing data causi…
Browse files Browse the repository at this point in the history
…ng the "non-geomtric" texture to show and the real raytracing data more robust.
  • Loading branch information
unhyperbolic committed Nov 2, 2023
1 parent 14d73eb commit 4667240
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
4 changes: 4 additions & 0 deletions opengl/CyOpenGL.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,10 @@ ELSE:
print(" OpenGL: 3.2 %s" % get_gl_string('GL_VERSION'))
print(" GLSL: 1.50 %s" % get_gl_string('GL_SHADING_LANGUAGE_VERSION'))

if False:
if fragment_shader_source:
open('/tmp/fragment.glsl', 'wb').write(fragment_shader_source)

def _compile_and_link(self, name):
if not _compile_shader(self._vertex_shader, name, 'vertex'):
return False
Expand Down
24 changes: 17 additions & 7 deletions python/raytracing/ideal_raytracing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def from_manifold(manifold,
areas=None, insphere_scale=0.05, weights=None):

if manifold.solution_type() != 'all tetrahedra positively oriented':
return NonGeometricRaytracingData(
t3m.Mcomplex(manifold))
return NonGeometricRaytracingData.from_manifold(manifold)

num_cusps = manifold.num_cusps()

Expand Down Expand Up @@ -354,13 +353,24 @@ def cusp_view_state_and_scale(self, which_cusp):


class NonGeometricRaytracingData(McomplexEngine):
def __init__(self, mcomplex):
@staticmethod
def from_manifold(manifold):
mcomplex = t3m.Mcomplex(manifold)
r = NonGeometricRaytracingData(mcomplex, manifold)
z = manifold.tetrahedra_shapes('rect')[0]
r.RF = z.real().parent()
return r

def __init__(self, mcomplex, manifold):
super().__init__(mcomplex)
self.manifold = manifold

def get_compile_time_constants(self):
return {
b'##num_tets##' : len(self.mcomplex.Tetrahedra),
b'##num_cusps##' : len(self.mcomplex.Vertices)
b'##num_cusps##' : len(self.mcomplex.Vertices),
b'##num_edges##' : len(self.mcomplex.Edges),
b'##finiteTrig##' : 0,
}

def get_uniform_bindings(self):
Expand All @@ -381,9 +391,9 @@ def initial_view_state(self):

def update_view_state(self, boost_tet_num_and_weight,
m=matrix([[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])):
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])):
boost, tet_num, weight = boost_tet_num_and_weight
boost = boost * m
return boost, tet_num, weight
Expand Down
4 changes: 2 additions & 2 deletions python/raytracing/inside_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def push_fillings_to_manifold(self):
self.widget.manifold.dehn_fill(
self.filling_dict['fillings'][1])

self.widget.recompute_raytracing_data_and_redraw()
self.widget.recompute_raytracing_data_update_shader_and_redraw()
self.update_volume_label()
self.reset_geodesics()

Expand All @@ -672,7 +672,7 @@ def push_fillings_to_manifold(self):
def recompute_hyperbolic_structure(self):
self.widget.manifold.init_hyperbolic_structure(
force_recompute=True)
self.widget.recompute_raytracing_data_and_redraw()
self.widget.recompute_raytracing_data_update_shader_and_redraw()

# Should we reset the view state since it might
# be corrupted?
Expand Down
6 changes: 3 additions & 3 deletions python/raytracing/raytracing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def get_compile_time_constants(self):

def update_view_state(self, boost_tet_num_and_weight,
m=matrix([[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])):
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])):
boost, tet_num, weight = boost_tet_num_and_weight

boost = matrix(boost, ring=self.RF)
Expand Down
6 changes: 6 additions & 0 deletions python/raytracing/raytracing_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ def recompute_raytracing_data_and_redraw(self):
self.fix_view_state()
self.redraw_if_initialized()

def recompute_raytracing_data_update_shader_and_redraw(self):
self._initialize_raytracing_data()
self._update_shader()
self.fix_view_state()
self.redraw_if_initialized()

def compute_translation_and_inverse_from_pick_point(
self, size, frag_coord, depth):

Expand Down
2 changes: 1 addition & 1 deletion python/raytracing/shaders/fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ vec3 sampleNonGeometricTexture(vec2 fragCoord)

void main(){

// Show text "Non-geoemtric"
// Show text "Non-geometric"
if (isNonGeometric) {
out_FragColor = vec4(sampleNonGeometricTexture(gl_FragCoord.xy), 1.0);
return;
Expand Down

0 comments on commit 4667240

Please sign in to comment.