Author Topic: Port's Perlin Noise  (Read 2008 times)

https://gist.github.com/portify/9544197

It's broken - I told him it's broken like a week ago, and he said he hasn't uploaded the fixed version yet. I keep bugging him about it, but he still hasn't done it.

I've been using zack0wack0's, which works great, but it doesn't have seeds like Port's does. It always generates the same result.

http://upload.zapkraft.net/perlin.cs

I've tried to fix Port's, but this is just gibberish to me. I mean what the forget is th
Code: [Select]
  %h = %hash & 15;
  %u = %h < 8 ? %x : %y;
  %v = %h < 4 ? %y : (%h == 12 || %h == 14 ? %x : %z);
  return ((%h & 1) == 0 ? %u : -%u) + ((%h & 2) == 0 ? %v : -%v);
WHAT IS THAT. WHY.



If anybody is willing to fix it, or has their own perlin noise function, that'd be great. xxoo

brian smith has his own version I think

and didn't zack0wack0's have seeds?
it did the last time I checked
EDIT:
Code: [Select]
%this.pl = "151160\t137\t91\t90\t15\t131\t13\t201\t95\t96\t53\t194\t233\t7\t225\t140\t36\t103\t30\t69\t142\t8\t99\t37\t240\t21\t10\t23\t190\t6\t148\t247\t120\t234\t75\t0\t
26\t197\t62\t94\t252\t219\t203\t117\t35\t11\t32\t57\t177\t33\t88\t237\t149\t56\t87\t174\t20\t125\t136\t171\t168\t68\t175\t74\t165\t71\t134\t139\t48\t27\t166\t7
7\t146\t158\t231\t83\t111\t229\t122\t60\t211\t133\t230\t220\t105\t92\t41\t55\t46\t245\t40\t244\t102\t143\t54\t65\t25\t63\t161\t1\t216\t80\t73\t209\t76\t132\t18
7\t208\t89\t18\t169\t200\t196\t135\t130\t116\t188\t159\t86\t164\t100\t109\t198\t173\t186\t3\t64\t52\t217\t226\t250\t124\t123\t5\t202\t38\t147\t118\t126\t255\t
82\t85\t212\t207\t206\t59\t227\t47\t16\t58\t17\t182\t189\t28\t42\t223\t183\t170\t213\t119\t248\t152\t2\t44\t154\t163\t70\t221\t153\t101\t155\t167\t43\t172\t9\t
129\t22\t39\t253\t19\t98\t108\t110\t79\t113\t224\t232\t178\t185\t112\t104\t218\t246\t97\t228\t251\t34\t242\t193\t238\t210\t144\t12\t191\t179\t162\t241\t81\t51
\t145\t235\t249\t14\t239\t107\t49\t192\t214\t31\t181\t199\t106\t157\t184\t84\t204\t176\t115\t121\t50\t45\t127\t4\t150\t254\t138\t236\t205\t93\t222\t114\t67\t29\t24\t72\t243\t141\t128\t195\t78\t66\t215\t61\t156\t180";
isn't this the seed for it? or am I wrong?

brian smith has his own version I think

brian smith has made like five million generators

brian smith has his own version I think

and didn't zack0wack0's have seeds?
it did the last time I checked
EDIT:
Code: [Select]
%this.pl = "151160\t137\t91\t90\t15\t131\t13\t201\t95\t96\t53\t194\t233\t7\t225\t140\t36\t103\t30\t69\t142\t8\t99\t37\t240\t21\t10\t23\t190\t6\t148\t247\t120\t234\t75\t0\t
26\t197\t62\t94\t252\t219\t203\t117\t35\t11\t32\t57\t177\t33\t88\t237\t149\t56\t87\t174\t20\t125\t136\t171\t168\t68\t175\t74\t165\t71\t134\t139\t48\t27\t166\t7
7\t146\t158\t231\t83\t111\t229\t122\t60\t211\t133\t230\t220\t105\t92\t41\t55\t46\t245\t40\t244\t102\t143\t54\t65\t25\t63\t161\t1\t216\t80\t73\t209\t76\t132\t18
7\t208\t89\t18\t169\t200\t196\t135\t130\t116\t188\t159\t86\t164\t100\t109\t198\t173\t186\t3\t64\t52\t217\t226\t250\t124\t123\t5\t202\t38\t147\t118\t126\t255\t
82\t85\t212\t207\t206\t59\t227\t47\t16\t58\t17\t182\t189\t28\t42\t223\t183\t170\t213\t119\t248\t152\t2\t44\t154\t163\t70\t221\t153\t101\t155\t167\t43\t172\t9\t
129\t22\t39\t253\t19\t98\t108\t110\t79\t113\t224\t232\t178\t185\t112\t104\t218\t246\t97\t228\t251\t34\t242\t193\t238\t210\t144\t12\t191\t179\t162\t241\t81\t51
\t145\t235\t249\t14\t239\t107\t49\t192\t214\t31\t181\t199\t106\t157\t184\t84\t204\t176\t115\t121\t50\t45\t127\t4\t150\t254\t138\t236\t205\t93\t222\t114\t67\t29\t24\t72\t243\t141\t128\t195\t78\t66\t215\t61\t156\t180";
isn't this the seed for it? or am I wrong?
Wow, didn't realize. How many fields is in that string, 256?

Wow, didn't realize. How many fields is in that string, 256?
I would think, since the for loop next to it goes up to 256

I would think, since the for loop next to it goes up to 256
I set the seed to 256 random numbers tabbed together, and it caused the same exact 1-dimensional wave pattern that happens in Port's.

please refer to this on how to implement perm tables (%this.pl)

please refer to this on how to implement perm tables (%this.pl)
Thanks!

IIRC the fixed version is in an unsaved ST3 tab on my laptop somewhere. I'll get it once I can actually be bothered to use my laptop. The only broken part in the version you posted is this:

 %a  = %this.p[%x    ] + %y;
  %aa = %this.p[%a    ] + %z;
  %ab = %this.p[%a + 1] + %z;
  %b  = %this.p[%x + 1] + %y;
  %ba = %this.p[%b    ] + %z;
  %bb = %this.p[%b + 1] + %z;


Some of those need to be %xx instead of %x, %yy instead of %y, etc. (though not all of them).


meh, just fixed it again

https://gist.github.com/portify/9849512
« Last Edit: March 29, 2014, 02:20:17 AM by Port »



Just curious - how come this part of your guys' code are like the exact same?
Code: (Port's) [Select]
function fade(%t)
{
return %t * %t * %t * (%t * (%t * 6 - 15) + 10);
}
 
function lerp(%t, %a, %b)
{
return %a + %t * (%b - %a);
}
 
function grad(%hash, %x, %y, %z)
{
%h = %hash & 15;
%u = %h < 8 ? %x : %y;
%v = %h < 4 ? %y : (%h == 12 || %h == 14 ? %x : %z);
return ((%h & 1) == 0 ? %u : -%u) + ((%h & 2) == 0 ? %v : -%v);
}
Code: (Zack0Wack0's) [Select]
function PerlinNoise::fade(%this,%t)
{
return %t * %t * %t * (%t * (%t * 6 - 15) + 10);
}
function PerlinNoise::lerp(%this,%t,%a,%b)
{
return %a + %t * (%b - %a);
}
function PerlinNoise::grad(%this,%hash,%x,%y,%z)
{
%h = %hash & 15;
%u = %h < 8 ? %x : %y;
%v = %h < 4 ? %y : %h == 12 || %h == 14 ? %x : %z;
return ((%h & 1) == 0 ? %u : -%u) + ((%h & 2) == 0 ? %v : -%v);
}

Same reference or something?

Asking that is a bit like asking why a certain implementation of A* pathfinding looks exactly the same as another one. Because it's the same algorithm.

At least Zack0's has the functions in a class scope.  Port's would cause conflicts with other mods if someone else wanted to use the (extremely general) function name of "fade".