We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it possible to check the amount of light (directionalLight()) that hits a surface so we can use that values? I am trying to implement a simple shaded wireframe view and I want to be able to colour my lines the same colour the Shapes get when hit by my directionalLight. It seems to me that should be very easy, since Processing is already calculating the normals of all surfaces and interpolating along the surface to colour it... I only need the colour at the vertices.
Any ideas? Thanks!
Answers
anyone? :)>-
How are you drawing the wires. OpenGL calculates the amount of reflected light from a surface based on direction of light and the surface normal. A line in 3D does not have a distinct normal, in fact it has an infinite number of normals so I am not convinced it is as simple as you think.
Well I have a parametrized surface from which I calculated the normals. So I have the normals, and I checked them against my light vector. The problem is that this way I can't detect if the surface is shading itself, which happens very often, so I get very weird results. That's why I was wondering if it would be possible to extract a float from the light that hits each Surface (I drew triangles), and pass it as an argument to the color of my lines (the ones that define the triangle). I would only need to calculate this once and store it...
Does it make sense? Thanks in advance!
Yes that makes sense but I don't know the answer. Sorry
i can't tell from what you've written whether you don't know how to do it manually or if you just want an automatic way to do it.
the normal of a plane is easy enough to work out (3points, cross product). and the amount of light hitting that plane is also easy enough (dot product of light vector and normal). PVector class has methods for both these. result colour is just the light colour * the amount of light (which will be 0 to 1).
(but then you've got potential -ve values where the plane the line is attached to is facing away, complications like that. lines that are on the join of two different planes...)
Thanks Koogs, I already did that. As commented before, I have all the information on the surface, the tricky part is that if the geometry shades itself or shades other geometries -again, this happens all the time-, this method does not account for that.
That's why I thought there should be a way to extract this light information which is calculated automatically by Processing provided a light and surfaces to be hit. This way, areas that are shaded by other geometries remain shaded. I don't know how to scratch that information from the Shapes.
by shaded do you mean shadows? i'd be surprised if the standard processing lighting did shadows.
code or an image would be useful.
Well actually, you may be right. Maybe its only the effect of the tessellation that gives this appearance. Difficult to say. I will give it a try my way. Thanks! http://www.mediafire.com/view/kheb4st8hl4j9qx/sample.jpg
the filled bit looks fine to me, nice bit of flat shading.
the light bits at the bottom left are lines that you don't see in the filled because they are facing away and / or have other triangles in front of them. and the closer together they are the lighter they appear...
Yes, I think its overall ok. It only gets tricky when you have manifolds and you have to check changes in curvature to flip the normals. But it would work for simple geometries!