![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
Member
Join Date: Aug 2005
Location: Vannes, Brittany, France
Posts: 88
|
Here is an implementation of the improved Perlin noise, for four dimensions. To know more about Perlin noise, see the talk Making noise.
First, a set of gradients, aiming at the center of each edge of a hypercube, is created. Code:
An array dedicated to store random numbers, and a function to fill it are also written. This function has to be called once before using Perlin noise. Code:
We also need a function to return a random number for any interger coordinates, some functions to make interpolations, and a function to return the dot product of two vectors. Note that interpolation is a 5th order polynom, and the vector elements are -1, 0, or 1 (these are part of the improvement over original Perlin noise). Code:
At last, the Perlin noise function gets the eight gradients corresponding to the given coordinates, and interpolate them to find the weight at those coordinates. Code:
The code could probably be shortened and optimised, but at least it is clear. By the way, there is no warranty this code is bug free. :-) Comments are welcomed of course. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
|
This is a very good contribution. Thanks for sharing it!
___________________________________________
"What ever happened to happily ever after?" |
|
|
|
|
|
#4 |
|
New Member
Join Date: Aug 2005
Location: Etten-Leur, The Netherlands
Posts: 21
|
Isn't the GPL a bit radical for such a small code snippet? Anyone using it would have their entire project "infected" by the GPL, which may deter quite a lot people from using it (well, perhaps they would use it and not comply with the license). Perhaps a BSD-style license is more applicable.
|
|
|
|
|
|
#5 | |
|
Member
Join Date: Aug 2005
Location: Vannes, Brittany, France
Posts: 88
|
Quote:
But I think this is fair to give some free code and expect users to do so in return. By the way, it should result very easy to re-write a different (and better ^_^) implementation of this. The problem with BSD like licences is that would allow programmers to simply copy-paste it in some commercial proprietary software, and this is just not the purpose of sharing it. |
|
|
|
|
|
|
#6 |
|
Valued Member
Join Date: Aug 2005
Location: Seoul
Posts: 272
|
"The problem with BSD like licences is that would allow programmers to simply copy-paste it in some commercial proprietary software, and this is just not the purpose of sharing it."
The GPL license is suited for applications and libraries and not for individual code files. This code is probably around 500 lines long so I don't think it's reasonable at all to ask rest of the program in return. Also the success of the commercial product is hardly dependend on a one small code snippet. People who have made decision to release their program under GPL are maybe ok with this, but for anyone else this code is totally useless. GPL enforces that the same license is being applied for the whole program, which is definitely an overkill for this. It would be certainly enough to have a license that requires people publish their modifications only to the code above. I don't think the code snapshot even should allow GPL'ed entries. With all respect, Juhani |
|
|
|
|
|
#7 | |
|
Member
Join Date: Aug 2005
Location: Vannes, Brittany, France
Posts: 88
|
Quote:
|
|
|
|
|
|
|
#8 |
|
New Member
Join Date: Oct 2005
Location: Switzerland, Langenthal
Posts: 23
|
very nice code, thanks!
i did a quick n dirthy optimization if you want to use the code with a constant t and z during frame (you only need to change t and z between two frames to get an animated "plasma") ---- Code:
and your loop could look somehow like this: Code:
have fun! Last edited by Nema : 10-05-2005 at 10:42 AM. |
|
|
|
|
|
#9 |
|
Member
Join Date: Nov 2008
Location: Germany
Posts: 32
|
While googling for new appearances of Perlin Noise out of lazyness, I discovered this thread.
Thanks for that implementation! And everybody who has a problem with the GPL: Just don't use this piece of code, if he wouldn't have released it at all, there wouldn't be a difference (except for that you can still study the code, wink wink). It seems that Non-GPL-People often beef the GPLers far more often than the GPL-People beef the Non-GPLers. Again: If you have a problem with the GPL, go away and don't suck on this thread. The GPL people won't annoy you so much about making your proprietary software free as you bother them. |
|
|
|
|
|
#10 |
|
DevMaster Staff
Join Date: Sep 2005
Location: The Netherlands
Posts: 1,442
|
I'm sorry, but what a load of crap. It isn't about who is bullshiting whom. It isn't even about GPL. It's about how much the code contributes to devmaster. And with a restrictive license (whether that be GPL or the PhresnelLikesToKickOldThreads license) it doesn't do that much good. If you don't want to share your code on non-intrusive terms, don't share it via devmaster.
___________________________________________
C++ addict - Currently working on: the 3D engine for Tomb Raider: Underworld and Deus Ex 3. Last edited by .oisyn : 01-21-2009 at 09:15 AM. |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Oct 2005
Location: Pensacola, FL
Posts: 1,028
|
"... or the PhresnelLikesToKickOldThreads license" - .oisyn
I hate that license! |
|
|
|
|
|
#12 |
|
Member
Join Date: Nov 2008
Location: Germany
Posts: 32
|
DotOisynLovesCamelCaseAndGlue:
The thread wasn't locked. Also, I bet there are actually some people around on devmaster who like copyleft licensery, and who release stuff under such terms, so why not? I must have missed the clause about the "anything that isn't useful to at least 90% of people" embargo when I registered up to devmaster. And as long as there isn't that embargo, wouldn't bashing on copyleft licensed releases be considered vigilante justice by a lawyer? And even if the code is pretty short, if I read it right, isn't the category saying "Code [...] Discussion"? So let's discuss about the code, not the license. edit: Oh, and please feel free to generalise my statements to "If you don't like ..., go away and don't bother bashing.". I wasn't actually talking specifically about GPL in that phrase, but on every license, may it be proprietary or permissive/restrictive open source. (believe it or not, I go away instead of pressuring people to release under terms that I would like.) monjardin: Aha. Last edited by phresnel : 01-22-2009 at 09:53 AM. |
|
|
|
|
|
#13 |
|
DevMaster Staff
Join Date: Sep 2008
Location: Left Of Albakurky
Posts: 734
|
Hmm. I am loathe to jump on a zombie thread.
The GPL is "restrictive", but I balk at calling it intrusive. It is, obviously, more intrusive that dropping snippets into the public domain. OTOH, it is less restrictive than most proprietary licenses. However, the GPL permits you to create and distribute an "aggregate", even when the licenses of the other software are non-free or GPL-incompatible. The problem is that an "aggregate" is not defined anywhere in any technical terms and trying to ensure you don't run afowl of it is hard. See this link for a FAQ answer that addresses this. |
|
|
|
|
|
#14 | |
|
DevMaster Staff
Join Date: Sep 2005
Location: The Netherlands
Posts: 1,442
|
Quote:
And the fact that a thread isn't locked doesn't mean it's ok to kick it if the post has nothing to do with the discussion at hand.
___________________________________________
C++ addict - Currently working on: the 3D engine for Tomb Raider: Underworld and Deus Ex 3. Last edited by .oisyn : 01-23-2009 at 04:48 AM. |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|