[URP][SG] Noise and World position not working in scene as in preview ?

Hi everyone,

I’m working on a “fake” sun shaft shader for URP with Shader Graph in Unity 2019.4.0f1 (but also tested in 2020.1.6f1).
I need help understanding why my shader is not using the “world” position in scene while it’s working in preview.
I tried putting the object in XYZ = 0,0,0 for scale, rotation and position (same as in the preview) but it’s still not working.
It’s doing the same effect as if the position node was set as Object.
Let me know if there is a proper way to do this or if there is any workaround.


What exactly are you expecting to see?

Well in my preview I’m not seeing the deformation of the texture like in the second screenshot. The texture is supposed to be world spaced but it’s streched.

That is because Tiling and Offset working with 2D space. So in result you clamped z axis. You could fix it by creating your own tiling that will work with 3D vector. You can do it different ways:

  • Add new subnode that will do it
  • Split vector3 and work independently
  • Use some code with custom function node (Code sample: Position * Tiling + Offset)

You are right ! Why did I not thought about it !
I’ll test this and hope I can close this thread.
But still I don’t understand why it’s working in SG preview then.

Also is it possible that because my noise is in 2d it’s creating issue ? Should I look into 3d noise instead ?

Or use an Add node, since that is quite literally all the Tiling Offset node is doing here; adding Time to the world position.

But that won’t fix the problem, since the Noise node is also 2D. Shader Graph does not have a built in 3D noise node. There are some online that other people have made, but there’s no guarantee any of those will work with the version of URP you’re using since Shader Graph keeps changing and breaking stuff.

What you see in the preview and what you see in the scene is identical. The difference is the Shader Graph preview uses an unrotated camera view. Basically it’s a nearly orthographic 2D view of a sphere mesh. If you had your camera’s rotation zeroed out and aligned with the sphere in the scene you’d see the same thing.

Thanks both of you for the answers !
I’ll try a couple of things on my side and post the final answer here later.

Ok I think I managed it out, or at least it’s visualy fixed enough for my purpose.
First I created an approximative 3D Noise subgraph :

It’s a portage of this C# methode :
6790526--786773--3DNoise_Code.PNG

Then I added imy World pos and time node to move across the 3D perlin noise in my Time node:

In the end I think it’s good enough for me.
Feel free to add your comments and feedback and thanks again for the pointers.