GLSL material Instancing Geometry Shader Lights

Hi. I’ve been trying to wrap my head around this problem for a couple of days.

I have a pointcloud from a kinect.

I send one point from an Add sop into a convert sop (convert to particle) and then into a geo, and then do the instancing “manually” with GLSL as described in Markus Heckmann’s helpful 2018 glsl turorial (Introduction to GLSL - Markus Heckmann - YouTube).

From here, I’ve added several conditional rules for isolating a subset of the pointcloud, and then sending the surviving points to a geometry shader, which then draws a mesh from each point to each of its neighbors (provided no edges are longer than a certain max length parameter, to break off the isolated object from the background and foreground at the boundary…)

So this all works. the geometry shader takes in the surviving points, and draws triangles between this point and its neighbors…

But what I am struggling with is getting lights to work. Even in Marcus’s tutorial, where we spend time getting the normals to work with the displaced grid, earlier in the tutorial (tbnmatrix, etc.), with the point cloud example, the lights similarly do not work…

So what is the strategy for turning the lights on? I figure I need to compute normals for each of the triangles I’m drawing, by taking the cross product of the two angles. But I’m not sure how to use these normals again in the pixel shader. What is the appropriate method for getting the lights to see my triangles?

If you export a shader from a Phong or PBR MAT, you can see the code that is needed to do lighting, that same code is needed in your pixel shader.

Thanks Malcolm. That is the first thing I tried, since I was following the 2018 tutorial to figure out instancing in GLSL. In the tutorial files all the lighting stuff is erased from the pixel shader and the colorMap is just passed to outcol with out much else. So the first thing I tried was to export a phong mat and reintegrate the lighting stuff. But even by doing this, the lights do not work. I thought the problem had to do then with texcoords and normals etc. But I cannot figure it out…

Simply put: how would you add lights to the pointcloud example in the summit.toe found here?

Any suggestions would be welcome. I am still looking for a solution or even just a basic strategy for achieving this. It seems like someone here should know.

How do you get geometry drawn with a geometry shader to be “seen” by the lights? Currently vertex color is passed through to the geometry, but it seems it is “emit” color rather than diffuse, and so dimming the lights has no effect.

I’m learning opengl so maybe there is something basic I am not understanding.

Thanks in advance!

Ok I’ve gotten it to work! Finally. My normals were not being fed properly through the shader stages. I guess I was overthinking it.