Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/render/opengl/shaders/volume_mesh_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,18 @@ const ShaderStageSpecification SLICE_TETS_GEOM_SHADER = {
}
}

// compute gradient of d to orient our sliced faces
vec3 vN[4]; // tet face normal times volume
vN[0] = cross(p[2]-p[1], p[3]-p[1]);
vN[1] = cross(p[3]-p[0], p[2]-p[0]);
vN[2] = cross(p[1]-p[0], p[3]-p[0]);
vN[3] = cross(p[0]-p[1], p[2]-p[1]);

// actually gradient times tet volume, but since we only want the sign, that doesn't really matter
// TODO: fix for inverted tets?
vec3 grad = d[0] * vN[0] + d[1] * vN[1] + d[2] * vN[2] + d[3] * vN[3];
vec3 cross12 = cross(q[1] - q[0], q[2] - q[0]);
if(dot(cross12, u_sliceVector) < 0){
if(dot(cross12, grad) < 0){
int temp = ordering[1];
ordering[1] = ordering[2];
ordering[2] = temp;
Expand All @@ -150,7 +160,7 @@ const ShaderStageSpecification SLICE_TETS_GEOM_SHADER = {
// Emit the vertices as a triangle strip
mat4 toScreen = u_projMatrix * u_modelView;
for (int i = 0; i < n; i++){
a_normalToFrag = cross12;
a_normalToFrag = vec3(toScreen * vec4(cross12, 0.0));
a_barycoordToFrag = vec3(0, 0, 0);
a_barycoordToFrag[i % 3] = 1.0;
${ GEOM_ASSIGNMENTS }$
Expand Down Expand Up @@ -341,8 +351,7 @@ const ShaderReplacementRule SLICE_TETS_VECTOR_COLOR(
vec3 albedoColor = shadeValue;
)"}},
/* uniforms */
{
},
{},
/* attributes */ {},
/* textures */ {});

Expand Down Expand Up @@ -402,4 +411,4 @@ const ShaderReplacementRule SLICE_TETS_PROPAGATE_VALUE(

} // namespace backend_openGL3_glfw
} // namespace render
}; // namespace polyscope
}; // namespace polyscope
2 changes: 0 additions & 2 deletions src/volume_mesh_scalar_quantity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ void VolumeMeshVertexScalarQuantity::setLevelSetVisibleQuantity(std::string name

void VolumeMeshVertexScalarQuantity::buildCustomUI() {
VolumeMeshScalarQuantity::buildCustomUI();
/* TODO disabled for now
if (ImGui::Checkbox("Level Set", &isDrawingLevelSet)) {
setEnabledLevelSet(isDrawingLevelSet);
}
Expand All @@ -205,7 +204,6 @@ void VolumeMeshVertexScalarQuantity::buildCustomUI() {
ImGui::EndMenu();
}
}
*/
}

void VolumeMeshVertexScalarQuantity::refresh() {
Expand Down