# Positional noise changes in Unity Editor vs compiled

I have a surface shader that adds a bit of positional noise, using the following code:

float2 uv_main = IN.uv_MainTex +
float2(
tex2D(_PosNoise, IN.uv_MainTex).r - 0.5,
tex2D(_PosNoise, IN.uv_MainTex).r - 0.5
) / float2(_Width, _Height) * _MovementOffset;
o.Albedo = tex2D(_MainTex, uv_main);


_MovementOffset is a float, the _Width and _Height are the size of the map in world coordinates. _PosNoise is a texture that is the same for both versions.

The problem I'm seeing is that the effective noise changes between how the image looks in the Unity Editor vs when it is compiled. The effect is such that I need to multiply the MovementOffset by a factor of 2-3 to have the same effect in the compiled version.

Unity:

Compiled:

I don't understand what could be causing this, and am having some real difficulties figuring it out. Any suggestions on where to look? Thanks!

• maybe float2(_Width, _Height) is causing scaling difference when your window size is bigger? – Jimmy Jul 25 '17 at 20:46
• They are world coordinates, and don't change on window size. Also, I have verified that varying the editor game window size doesn't affect the result. – PearsonArtPhoto Jul 25 '17 at 21:23
• What kind of format and compression are you using on your noise texture? – DMGregory Jul 25 '17 at 21:27
• The noise feature is generated at run time. – PearsonArtPhoto Jul 25 '17 at 21:34