Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

per-fragment phong shading for mesh visual #10

Merged
merged 7 commits into from
Jul 14, 2015

Conversation

bollu
Copy link

@bollu bollu commented Jun 28, 2015

Screenshot:

screenshot from 2015-06-29 01-55-50

Are these needed?

  • use blinn-phong for optimization?
  • pass varying by using vispy's Varying class directly to the fragment shader

@bollu
Copy link
Author

bollu commented Jun 28, 2015

API questions:

Light

How does the user specify lights? Possibilities:

1 . create a Mesh.add_light function?

  1. create a full-blown LightSource class? What about other kinds of lights? (Cone, directional, global)
  2. Will lights be a global Vispy feature? i.e, will lighting eventually become a part of the rendering pipeline? or will it be a one-shot thing for Mesh

I'm undecided. I think I would prefer having Light in a separate class, just for neatness' sake. As for it being global, that would impact a lot of things, and I don't think that overhead is necessary for a plotting library like vispy.

Material

  1. create a custom Material class that holds all our material coefficients, then have defaults (metal, dull, ...)
  2. create a Mesh.set_material_property(**kwargs) member

Again, I'd prefer to separate out Material properties, so we can do really nice things like bump mapping and normal mapping if we want to later. However, I'm not sure how viable / required this is.

Also, if we have a Material class, it could also address the issue of the texturing API for MeshVisual. Link to issue of texture mapping

ping @rossant, @Eric89GXL, @campagnola

@campagnola
Copy link
Owner

Here is the plan so far:

Lights:

  1. MeshVisual will have simple methods for setting light parameters like add_light(pos, color), remove_light(id), etc.
  2. Create a Light(Node) class that has a color property and can be placed anywhere in a scene.
  3. Mesh can then automatically detect all lights in its subscene and add them as well as keep them updated when the lights change. Optionally, the user may specify exactly which lights should be used for each mesh.
  4. Volume will follow the same pattern, and Markers will have attachments that require lighting as well (for example, show a phong-shaded sphere for each point). Most other visuals will not need to know about lights.

Materials:

  1. Materials can be implemented as visual filters. (eventually, the phong shading code should become a filter as well)
  2. The user can attach any number of filters allowing texturing, bump/normal/specular mapping, etc.
  3. We will probably also want an easy way for the user to access the most commonly used materials without having to manually construct the entire set of filters.

All this should be left for future PRs, though..

@campagnola
Copy link
Owner

This is looking better. Try out examples/basics/scene/surface_plot.py--that doesn't look right to me.

use blinn-phong for optimization?

This is not needed for the current PR, but it would be another nice addition later on.

pass varying by using vispy's Varying class directly to the fragment shader

Unnecessary for now. This approach is only needed if a separate function needs to introduce a varying that was not in the original vertex/fragment code.

@bollu
Copy link
Author

bollu commented Jun 30, 2015

What exactly looks "wrong" in the surface_plot? One thing that I noticed is that the specular highlights occur in the bottom of the plot, and doesn't change whatever light direction you set. But, what else is wrong with the example?

Also, what about texturing? What will be the API for specifying uv coordinates?

@campagnola
Copy link
Owner

the specular highlights occur in the bottom of the plot, and doesn't change whatever light direction you set.

That's it :)
Also at some angles the specular highlights seem to appear at the edges of the mesh (where the mesh normal is perpendicular to the eye vector).

I haven't given the texturing API much thought yet; let's leave that for another PR.

@bollu
Copy link
Author

bollu commented Jul 1, 2015

@campagnola Can you check it out now? I still think there's something fishy going on with the normals, but it is better now I guess.

Also, what do I port next? AGG / Textures for the MeshVisual was what I was thinking. Plus, AxisVisual, Colorbar?

@campagnola
Copy link
Owner

Looks the same to me:
mona_lisa_sm1

@campagnola
Copy link
Owner

Yeah, any of those would be great. AxisVisual has already been done, but Colorbar still has not.

@bollu
Copy link
Author

bollu commented Jul 13, 2015

@campagnola do you have any idea as to why the shader isn't working properly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants