6
$\begingroup$

I am trying to implement a laser line that I can move freely along an object to simulate a prototype we are developing. I am following the answer provided at Using Nodes for Laser Line and I have some doubts regarding how it works.

I am familiar with algebra and dot product, but still don't understand how this works. What is the Geometry node output? Is it the vector from every point lighted to the lamp? What is this point it talks about in the documentation: https://docs.blender.org/manual/en/dev/render/cycles/nodes/types/input/geometry.html

I'm assuming it lights a point only if the dot product of the declared vector and the vector from point to lamp are in a 90º angle (hence the "less than") but I intend to do a clipped laser line and I would need confirmation and the documentation is not clear.

$\endgroup$
4
$\begingroup$

In that particular example, the nodes are relating to the Lamp output rather than Material Output - so it’s a bit different.

Normally the Geometry node would relate to the shading point mentioned in the documentation but in the case of the lamp it actually relates to details of the ray eminating from the lamp to illuminate the current shading point in the scene. So the Incoming can really be thought os as the ‘outgoing’ ray from an illumination point of view.

By using the Dot Product and ‘less than’ you are right that it is picking out those rays that are at 90 degrees to the mapped vector - and so generating a circle of light at right-angles to the reference vector.

$\endgroup$
4
$\begingroup$

I find it helpful to think about this as naive, simplified reverse ray-tracing.

So a ray is fired from the camera through a pixel in the screen, and hits a shading point on a visible surface. That ray is then split, and bounced off the surface towards all the lamps it can 'see', asking of each lamp: "what light contribution are you making to my color calculation?" The 'incoming' output of the lamp shader's Geometry node is the vector representing the direction of that last segment of the ray, which hits the lamp. (To or from doesn't matter in this case).

The CombineXYZ, Mapping, and Normalize nodes establish an easily rotated unit vector P, whose origin we can think of as being at the lamp.

The DotProduct and Absolute nodes return the positive dot product of the incoming ray and P. The closer this is to 0, the smaller the angle between the incoming ray and the plane whose normal is P, passing through the lamp. We want the light to emit only if the incoming ray's origin is close to that plane.

The angle won't do. We want a measure of the distance between the origin of the ray and the plane. We don't want our beam to spread as it gets further from the lamp. The Light Path>Ray Length and Multiply nodes multiply the our dot product by the length of the incoming ray, giving us a number which varies linearly with the distance of the ray origin from the plane. (Think similar triangles.)

The Less Than node returns 1 if that distance falls within a threshold, 0 if not.

The Light Falloff>Constant>Strength and Multiply nodes give us a light whose intensity is a constant Strength value, irrespective of the length of the incoming ray, if the threshold requirements are met.

The result: a planar sheet of light, which doesn't decay with distance, with an adjustable rotation, strength, and thickness.

$\endgroup$
  • $\begingroup$ Thanks man! That explanation was super useful and I managed to do a laser line pointing to a specific given direction within an angle range. $\endgroup$ – janonespe Mar 16 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.