I'm looking for a method that compares two vectors in order to use a mix color/shader.
Example : If the camera looks at the object from atop (as the two vectors align) it should select material A. As the camera moves to a different angle away for top of the object, the material gradually change for B.
What I want to do :
- It has to be based on the object orientation and not the world origin (x,y,z).
- It should allow to select any angle as an input. This means calculations with the object orientation and the input vector.
- It cannot be a Facing as it is based on face Normals and wouldn't select the material for the whole object but only for faces.
I thought I had to get:
- Camera angle
- Object Angle (pivot) + Any angle I choose (as an input)
Input>Camera Data is the one for the camera (obviously).
I cannot find the orientation of the object (or something related). The nodes
input>Object data do not seem to provide that data.
Converter>Vector Math seemed to be a good candidate.
Basically I thought a subtract or a Vec1,Vec2 angle comparison would be ok.
But everything I try is not working. Not even close. Any help is welcomed.
I hope those images will help understand the question.
EDIT 'going further with @Shady' @Shady puck has provided step one solution. When the camera aligns with the Z axis of Suzanne the material is properly selected. I made a blend file and attached it here to document it properly.
more testing on solution A by @Shady puck
Edit 'Going further with batFINGER'
Remarkable. The concept of using one object to provide the necessary data is good as it provides levers (sort of) that can be easily manipulated in the scene. I did implement your solution and did some tests. I only took the liberty of changing some names in your script. Also I took care of respecting name conventions (sort of speak).
A/ It seems I have to select the control object (in this case the yellow cone) before using the animation slider to be able to see a change. It non the less render.
B/ It seems when I press space (B2.80) the animation has trouble changing the colors unless I move the mouse cursor over the custom panel/TextInput named “angle” (in and out). Rendering it, doesn’t seems to work.
C/ If I clear all links and then “link” Suzanne and the Camera, it works but only sometimes and I don’t know why. Selecting one or the other isn’t a guaranty of success. Which makes me wondering about A a little more. Rendering in EEVEE also make the material flicker between 2 colors when I’m luck to see any change.