0

I would like to make a material that displays the line of sight vector using the RGB channels : for example, here, let's say i am looking from the camera, the line of sight vector would be : →E(X=0; Y=1; Z=0)

so the sphere should appear all green. enter image description here

Also, i wanna precise that I don't want it to use the camera (the object) orientation but the viewport.

I think the vector transform node would help, i found this thread in which the material displayed the rotation of the object so i think it could help : Change color with object rotation

alexth 91
  • 23
  • 1
  • 3

2 Answers2

1

Use a camera data/view vector node. Because this provides a camera space vector, you can use a vector transform node to transform it into a world space vector like you want.

enter image description here

The "camera" being referred to here is not the camera I have in the scene-- notice the axes and camera position, notice that the same sphere is different colors in different viewports. The camera being referred to is whatever eye is looking at the scene. In the case of a render, that's the camera, but in the case of a viewport, it's whatever your viewport is using as a "virtual" camera.

Another way to do this, in Eevee, is to use geometry/incoming, then reverse the vector. In Eevee, the incoming is vector is always the view vector (but reversed, to point at the camera.) In Cycles, this vector doesn't always refer to the view vector, but instead refers to the most recent direction any particular ray that hit the object took.

Nathan
  • 24,535
  • 1
  • 22
  • 68
1

If you just want the line of sight of the camera, (regardless of where the sphere is in the view,) this will do it:

enter image description here

But, of course, the colors will go black when the line of sight goes negative. You may want to map the -1 to 1 range in each dimension to something more to your liking.

Robin Betts
  • 76,260
  • 8
  • 77
  • 190
  • It works well, thanks to both of you. (lol the thread i linked gave a really close setup) – alexth 91 Apr 09 '21 at 18:19
  • @alexth91 I was just thinking.. you could signify 'negative' with a texture, or transparency, or someting other than color. – Robin Betts Apr 09 '21 at 18:23
  • aight thx, english isn't my native language so sometimes i have trouble explaining things like this one (also how do i give a reputation point ?) – alexth 91 Apr 09 '21 at 18:26
  • Click the little up and down triangles next to the answer, and tick the answer you think best meets your requirements. – Robin Betts Apr 09 '21 at 18:30