GLMeshItem, setting up light source and shading

651 views
Skip to first unread message

michiel....@gmail.com

unread,
Mar 20, 2013, 9:37:10 AM3/20/13
to pyqt...@googlegroups.com
Hi,

I am trying to use GLMeshItem for displaying a 3d object based on vertexes and triangles. I have difficultly to define shading on the object. I would like to use for istance phong shading but can not find any reference to this. In addition, where do I define a light source for this scene? Any help or clear examples would be appreciated.

Thanks,

M.

Luke Campagnola

unread,
Mar 20, 2013, 10:44:50 AM3/20/13
to pyqt...@googlegroups.com
On Wed, Mar 20, 2013 at 9:37 AM, <michiel....@gmail.com> wrote:
Hi,

I am trying to use GLMeshItem for displaying a 3d object based on vertexes and triangles. I have difficultly to define shading on the object. I would like to use for istance phong shading but can not find any reference to this. In addition, where do I define a light source for this scene? Any help or clear examples would be appreciated.

Hi,
There is no lighting in pyqtgraph at present; the 3D system is still pretty rudimentary. If you run the 'shaders' example, though, you can see some of the surface shaders that are currently available. One of these does a very basic lighting scheme with fixed light location. It wouldn't be too difficult to modify the shader to use a variable light location. There are also many examples of phong shaders implemented in GLSL on the web (here one: http://www.ozone3d.net/tutorials/glsl_lighting_phong_p2.php). If you would like to try to implement something like this, I'd be happy to walk you through the shader system in pyqtgraph.

Luke 

 

Barrett Anderies

unread,
Aug 20, 2016, 2:55:49 PM8/20/16
to pyqtgraph
Hi Luke,

I'm currently trying to render an STL object in a glViewWidget, and everything seems to be working fine except for the lighting. All of the shaders except "shaded" are fine. When I use the "shaded" shader, the outside of my object is very dark and the inside is well-lit. It's almost as if the light is inside the object (no matter how I scale the object either before or after adding the item to the glViewWidget). I would like to add some lighting functionality to this shader, but I am not very familiar with modern OpenGL (I've never used a shader). I've used older OpenGL (ie. glBegin and glEnd) and was able to add lights, and I was hoping that you would be able either help me fix the current lighting situation or add my own lighting tools. When I run the shaders example, the lighting appears to be working fine on the "shaded" object (the light moves with the camera, correct?), so I don't know why it isn't working for my object. Is there something simple I could do to ensure that the outside of my object receives more light? Below are some screenshots. The first two are view from the outside (very dark and difficult to see details) and the third is a view from the inside (well-lit)


I would appreciate any advice, and I would be open to learning and adding more lighting/shading tools with some help (where to start, what functions to modify, etc.).

Thanks,

Barrett
Reply all
Reply to author
Forward
0 new messages