• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ausLancaster · Aug 03, 2017 at 08:21 AM · shaderprocedural generationperlin noisehash

Perlin Noise not working properly when using offset

I'm trying to write a shader that uses Perlin Noise. I am using the function noise with an offset that will change with time. All good so far:

 float offset = 0;
 float noise1 = noise((IN.worldPos.xz + offset)) + 0.5;
 return noise1*float3(1, 1, 1);

alt text

However, when the offset exceeds around 500 the noise doesn't work properly.

 float offset = 500;
 float noise1 = noise((IN.worldPos.xz + offset)) + 0.5;
 return noise1*float3(1, 1, 1);

alt text

Why is this? Here is the noise and hash function I am using:

         float2 hash(float2 x)
         {
             const float2 k = float2(0.3183099, 0.3678794);
             x = x*k + k.yx;
             return -1.0 + 2.0*frac(16.0 * k*frac(x.x*x.y*(x.x + x.y)));
         }
 
         float noise(in float2 p)
         {
             float2 i = floor(p);
             float2 f = frac(p);
 
             float2 u = f*f*(3.0 - 2.0*f);
 
             return lerp(lerp(dot(hash(i + float2(0.0, 0.0)), f - float2(0.0, 0.0)),
                 dot(hash(i + float2(1.0, 0.0)), f - float2(1.0, 0.0)), u.x),
                 lerp(dot(hash(i + float2(0.0, 1.0)), f - float2(0.0, 1.0)),
                     dot(hash(i + float2(1.0, 1.0)), f - float2(1.0, 1.0)), u.x), u.y);
         }


noise-normal-small.png (128.2 kB)
noise-buggy-small.png (106.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

104 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Procedural Generation in Unity 0 Answers

Strange texture2d behaviour 0 Answers

Advice on 2D Surface Terrain Generation Using Noise 1 Answer

Procedural Shader Cost/Draw Calls 1 Answer

How to force the compilation of a shader in Unity? 4 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges