Is it possible to "freeze" or sample the data from the Position Node?

Odd title, I know; I’ll explain.

I have spent a few days learning Shader Graph and putting together a fog-of-war prototype. One element of the system involves projecting a texture onto a flat plane from the point of view of the camera so that the angles look right (orthographic camera locked at 45 degrees relative to the plane). I achieve this by feeding a Postion(Space - View) node into the Sample Texture node’s UV slot via a Tile and Offset Node. The flaw, completely obvious to me now, is that the projection moves with the camera, which breaks my system.

So, my question is, is there a way to sample/freeze the initial value from the Position Node, and continue to project the texture from that angle, allowing me to move the camera without the texture following?

I am not even sure what kind of data exactly the Position Node is feeding. Considering my camera is locked at a specific angle all the time can I just feed a hard-coded value into the UV without using that node at all; any idea how I would generate that value?

It’s an unlit graph in URP by the way, though I doubt that matters for this.

I will be very, very sad if all the work I have done on this system can’t be saved for the sake of this one issue - please help.

Thanks!

You could expose a “view offset” property and add it to your Position in the shader, call material SetVector(“_viewOffset”, currentViewOffset) whenever the camera position changes - there’s probably a way to do it in the shader itself though.

1 Like

Oh, interest! What value would I feed, a vector representing the difference between the camera’s original position and its current position? Or the inverse of that, I suppose?

Yeah - just be sure that the difference you’re passing is also in view space.

It took a bit of fiddling but I worked it out. Here was my eventual solution, for anyone finding this later: Imgur: The magic of the Internet

1 Like