World Space Light Pos node confusion
Posted: Wed Jan 17, 2018 9:25 pm
Hey there! Thanks for the awesome plugin, it's incredibly useful!
I'm working on a shader and trying to calculate the angle between the light direction to the game object and the camera direction to the game object. I'm using the World Position node to get the coordinates of the surface, the World Space Camera Pos node to get the coordinates of the camera and the World Space Light Pos node to get the coordinates of the light. I'm calculating the direction vectors and angle between them using the values from those nodes.
World Position and World Space Camera Pos nodes seem to be giving me a 1 to 1 position vector of those objects in my scene. However, World Space Light Pos does not seem to be providing a 1 to 1 position vector of my light in my scene.
As a very simple test setup, I have a single spot light in my scene, a camera and a cube. If I put the camera at position (1, 0, 1) and use World Space Camera Pos node with the X output connected to Emission in my shader output, the cube glows white with full emission. If I connect the Y output from that node to emission, it's 0 and the cube is black. The same test works when I use World Position node with my cube at position (1, 0, 1) and connecting those outputs to emission.
When I try the same test with my light at position (1, 0, 1), the cube is always black no matter which output I connect to emission. As a side test, I connect the Type output from World Space Light Pos directly to emission (which should be 0 or 1 according to the docs, and 1 for all lights other than directional), the cube is also just black.
Am I misunderstanding the World Space Light Pos node in some way? What I really want, is the 1 to 1 position vector of the light in world space in my scene. In this possible in any other way?
Thank you very much, please let me know if I can provide more info.
Max.
I'm working on a shader and trying to calculate the angle between the light direction to the game object and the camera direction to the game object. I'm using the World Position node to get the coordinates of the surface, the World Space Camera Pos node to get the coordinates of the camera and the World Space Light Pos node to get the coordinates of the light. I'm calculating the direction vectors and angle between them using the values from those nodes.
World Position and World Space Camera Pos nodes seem to be giving me a 1 to 1 position vector of those objects in my scene. However, World Space Light Pos does not seem to be providing a 1 to 1 position vector of my light in my scene.
As a very simple test setup, I have a single spot light in my scene, a camera and a cube. If I put the camera at position (1, 0, 1) and use World Space Camera Pos node with the X output connected to Emission in my shader output, the cube glows white with full emission. If I connect the Y output from that node to emission, it's 0 and the cube is black. The same test works when I use World Position node with my cube at position (1, 0, 1) and connecting those outputs to emission.
When I try the same test with my light at position (1, 0, 1), the cube is always black no matter which output I connect to emission. As a side test, I connect the Type output from World Space Light Pos directly to emission (which should be 0 or 1 according to the docs, and 1 for all lights other than directional), the cube is also just black.
Am I misunderstanding the World Space Light Pos node in some way? What I really want, is the 1 to 1 position vector of the light in world space in my scene. In this possible in any other way?
Thank you very much, please let me know if I can provide more info.
Max.