0
\$\begingroup\$

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:

Unity Editor

Compiled:

Compiled Version

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!

\$\endgroup\$
4
  • \$\begingroup\$ maybe float2(_Width, _Height) is causing scaling difference when your window size is bigger? \$\endgroup\$ Commented Jul 25, 2017 at 20:46
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 25, 2017 at 21:23
  • \$\begingroup\$ What kind of format and compression are you using on your noise texture? \$\endgroup\$ Commented Jul 25, 2017 at 21:27
  • \$\begingroup\$ The noise feature is generated at run time. \$\endgroup\$ Commented Jul 25, 2017 at 21:34

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.