Skip to content

Matcaps (material captures aka environment maps) in Viewer#1482

Merged
jdumas merged 4 commits intomasterfrom
matcap
May 2, 2020
Merged

Matcaps (material captures aka environment maps) in Viewer#1482
jdumas merged 4 commits intomasterfrom
matcap

Conversation

@alecjacobson
Copy link
Copy Markdown
Contributor

Texture slot can be used as a material capture (also known as environment map). Swapping in a matcap from an image is very simple.

Here's a minimal example

#include <igl/opengl/glfw/Viewer.h>
#include <igl/read_triangle_mesh.h>
#include <igl/png/readPNG.h>

int main(int argc, char *argv[])
{
  igl::opengl::glfw::Viewer v;
  Eigen::MatrixXd V;
  Eigen::MatrixXi F;
  igl::read_triangle_mesh(argv[1],V,F);
  Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> R,G,B,A;
  igl::png::readPNG(argv[2],R,G,B,A);
  v.data().set_mesh(V,F);
  v.data().set_texture(R,G,B,A);
  v.data().use_matcap = true;
  v.data().show_lines = false;
  v.launch();
}

For example, then
./main beetle.off Chrome.png will produce

Screen Shot 2020-04-12 at 8 30 59 PM

Chrome.png.zip

Note: I've disabled the automatic call to grid_texture() in ViewerData. I wonder if this was really being used as is like this. I made the judgement call that putting a default matcap in the texture is more useful (and that leaving the V_uv empty is more correct).

related posts:

@jdumas jdumas added the viewer label Apr 13, 2020
Copy link
Copy Markdown
Collaborator

@jdumas jdumas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool! But I'm wondering if there's a use-case for showing a textured material with a matcap (e.g. to show a shiny heat equation solution or smth). If so, we should use different texture slots maybe?

grid_texture();
// Alec: is anyone really using this default? It uses trivial UVs and
// produces an anisotropic checkerboard...
//grid_texture();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think this may be confusing to new users. If I enable textures I'd expect to see a (crappy) checkerboard more than a matcap I think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't imagine a circumstance where I want to see nonsense UVs + checkboard by default. Maybe we can trigger checkerboard texture generation if set_UV is called and use_matcap is (still) false?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said in my latest answer, I think we can kill the grid_texture() function, and as default behavior maybe do nothing? That way = no surprise.

@alecjacobson
Copy link
Copy Markdown
Contributor Author

alecjacobson commented Apr 13, 2020 via email

@jdumas
Copy link
Copy Markdown
Collaborator

jdumas commented Apr 13, 2020

Sounds good. I'd still vote for keeping the grid_texture() by default though, otherwise lgtm.

@alecjacobson
Copy link
Copy Markdown
Contributor Author

alecjacobson commented Apr 13, 2020 via email

@jdumas
Copy link
Copy Markdown
Collaborator

jdumas commented Apr 13, 2020

Oh right, I had in mind the grid from tutorial 501. It doesn't look like grid_texture() is very useful at all, maybe we should remove the method altogether? In that case I think the default behavior should be to not generate any UV/texture at all. Calling normal_matcap() by default would change the behavior of tutorial 501, and show the normal texture instead of the default checkerboard, which I think is a bit weird (if I load a mesh with a UV texture I'd rather see the checkerboard atlas than the mesh normal).

Do you think this matcap tick is worth a new tutorial entry btw?

Copy link
Copy Markdown
Collaborator

@jdumas jdumas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the grid_texture() function to only generate a checkerboard texture, but without UVs. Removing it entirely breaks tutorial 501.

@jdumas jdumas merged commit 29b7579 into master May 2, 2020
@jdumas jdumas deleted the matcap branch May 2, 2020 20:04
@jdumas jdumas added the feature label May 2, 2020
@jdumas
Copy link
Copy Markdown
Collaborator

jdumas commented May 2, 2020

Do you think it's worth a tutorial entry btw?

@alecjacobson
Copy link
Copy Markdown
Contributor Author

alecjacobson commented May 2, 2020 via email

skoch9 pushed a commit to skoch9/libigl that referenced this pull request Jun 3, 2020
* matcap from texture, default normal image matcap

* update grid_texture() to generate checkerboard texture, but without UVs

Co-authored-by: Jérémie Dumas <jeremie.dumas@ens-lyon.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants