0
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ It works well, thanks to both of you. (lol the thread i linked gave a really close setup) $\endgroup$
    – alexth 91
    Apr 9 at 18:19
  • $\begingroup$ @alexth91 I was just thinking.. you could signify 'negative' with a texture, or transparency, or someting other than color. $\endgroup$ Apr 9 at 18:23
  • $\begingroup$ 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 ?) $\endgroup$
    – alexth 91
    Apr 9 at 18:26
  • $\begingroup$ Click the little up and down triangles next to the answer, and tick the answer you think best meets your requirements. $\endgroup$ Apr 9 at 18:30
1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ thank you @Nathan but with this node setup the object doesn't have a single color : image $\endgroup$
    – alexth 91
    Apr 9 at 17:27
  • $\begingroup$ what i would like is that the object only has a single color on it $\endgroup$
    – alexth 91
    Apr 9 at 17:49

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.