0
Completed

Camera forward vector node

Germain 10 years ago updated 10 years ago 5
So there are many ways of creating a facing geometry shader with Shader Forge. What I mean by facing, is a quad whose surface somehow points at the camera. There is one limitation however : depending on where the object is in the screen the resulting facing vector is different. If the object is perfectly in the middle of the screen, the result vector is the exact opposite of the camera forward vector, a perfect facing result. However, in certain cases, when the object is more toward the corner of the screen, the facing vector can rotate or even flip around its facing vector, giving less than desirable results (this happens when the camera looks down on a facing object).

My solution has always been to simply have the facing object mimic the camera's forward vector. This gives me a consistent and stable facing vector. However, at the moment, i'm unsure if getting the camera's forward vector is actually doable in Shader Forge. My suggestion would be to add a node giving us the camera transform orientation.

Answer

Answer
Completed
This should give you either the camera forward or backward vector: Transform[ View to World ] <- Vector3[ 0, 0, 1 ]
Answer
Completed
This should give you either the camera forward or backward vector: Transform[ View to World ] <- Vector3[ 0, 0, 1 ]
+1
And yeah, there should be a node for this down the line :)
Hey! Thanks for the answer :)

Yeah, I'm already using a Scripting/OnUpdate approach, but using it within the shader would not only simplify things, but get rid of the need for a script entirely.

Cheers!
I wasn't talking about doing it in code - there is a transform node that you can set to transform from view to world
Oh I see. This pretty much solved my problem, thanks!