Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Fix/enable surface normals #14

Open
OlehKSS opened this issue May 31, 2018 · 10 comments
Open

Fix/enable surface normals #14

OlehKSS opened this issue May 31, 2018 · 10 comments
Assignees
Projects

Comments

@OlehKSS
Copy link
Collaborator

OlehKSS commented May 31, 2018

Surface normals should fix/smooth out the appearance of individual triangles.

An example of a OpenGL-ES2 compatible Phong shading (at least I think it works properly):

https://github.com/vispy/vispy/blob/master/vispy/visuals/mesh.py#L21

Surface normals calculation will be added with pull request #31, ipyvolume support for the smooth shading should be added later.

@OlehKSS OlehKSS added this to To do in GSOC-2018 via automation Jun 15, 2018
@OlehKSS OlehKSS self-assigned this Jun 15, 2018
@OlehKSS
Copy link
Collaborator Author

OlehKSS commented Jun 19, 2018

@larsoner I have added this issue according to your comment in the pull request. I have been studying the PySurfer code and I am not sure I understand correctly how surface normals are used in PySurfer. Have you implied vertex normals that are used for shading corrections, so the surface does not look triangulated (flat vs smooth shading)?

@OlehKSS
Copy link
Collaborator Author

OlehKSS commented Jun 19, 2018

By the way, inflated surface does not seem as much triangulated as pial surface.

@larsoner
Copy link
Member

Yes vertex normals are used for smooth shading. There should be a way to enable it for the WebGL meshes. To compute the vertex normals (surf['nn'])we have complete_surface_info in MNE:

https://github.com/mne-tools/mne-python/blob/master/mne/surface.py#L291

@OlehKSS
Copy link
Collaborator Author

OlehKSS commented Jun 19, 2018

I am not sure whether simple enabling in WebGL will help, since ipyvolume uses custom vertex and surface shaders for implementing its plot_mesh/plot_trisurf functions.

@larsoner
Copy link
Member

ipyvolume uses custom vertex and surface shaders for implementing its plot_mesh/plot_trisurf functions.

If it uses smooth shading / lighting, it should already make use of the vertex normals (IIUC it is standard to do so)

@OlehKSS
Copy link
Collaborator Author

OlehKSS commented Jun 19, 2018

This is the source code for the shaders I was talking about:

I am not sure whether this is exactly vertex normal implementation, what do you think? I would need ask in ipyvolume chat or smth.

@larsoner
Copy link
Member

I would ask the ipyvolume folks

@OlehKSS
Copy link
Collaborator Author

OlehKSS commented Jun 20, 2018

According to ipyvolume folks they use flat shading.

@larsoner
Copy link
Member

You could ask about the possibility of using smooth shading. It's worth a PR to ipyvolume if it's not too much work

@OlehKSS
Copy link
Collaborator Author

OlehKSS commented Jun 20, 2018

Yes, it will be possible to add smooth shading to ipyvolume.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
GSOC-2018
  
To do
Development

No branches or pull requests

2 participants