SimplexNoise 2D 3D et 4D - V1.0.2

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Guimauve
Messages : 1015
Inscription : mer. 11/févr./2004 0:32
Localisation : Québec, Canada

SimplexNoise 2D 3D et 4D - V1.0.2

Message par Guimauve »

Bonjour à tous

Voici les fonctions de calcul de type SimplexNoise en 2D, 3D et 4D

Link 1 : http://en.wikipedia.org/wiki/Simplex_noise
Link 2 : http://staffwww.itn.liu.se/~stegu/simpl ... xnoise.pdf

Un code similaire à déjà été poster sur le forum anglais http://www.purebasic.fr/english/viewtop ... 4&p=138197 par Hades il y a longtemps.
Je pense que je devrais prendre l'habitude d'utiliser la fonction de recherche du forum avant de me lancer dans l'écriture d'un groupe de commande.

Liste des fonctions :

1. InitializeSimplexNoise()
2. RandomizeSimplexNoisePermutationTable() --> Ajouté V1.0.2
3. DestroySimplexNoise()
4. SimplexNoise2D(x.d, y.d)
5. SimplexNoise3D(x.d, y.d, z.d)
6. SimplexNoise4D(x.d, y.d, z.d, w.d)

A+
Guimauve

Code : Tout sélectionner

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Nom du projet : SimplexNoise
; Nom du fichier : SimplexNoise.pb
; Version du fichier : 1.0.2
; Programmation : OK
; Programmé par : Guimauve
; Date : 15-01-2011
; Mise à jour : 19-01-2011
; Codé pour PureBasic V4.51
; Plateforme : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes :
;
; Code Original par : Stefan Gustavson
;                     Linköping University, Sweden 
;                     (stegu@itn.liu.se), 2005-03-22
;
; Lien 1 : http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
; Lien 2 : http://en.wikipedia.org/wiki/Simplex_noise
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
  
Structure IntVec3
  
  i.l
  j.l
  k.l
  
EndStructure
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Update <<<<<
  
Macro UpdateIntVec3(IntVecA, P_i, P_j, P_k)
  
  IntVecA\i = P_i
  IntVecA\j = P_j
  IntVecA\k = P_k
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Produit Scalaire <<<<<
  
Macro DotProductIntVec3(IntVecA, P_x, P_y, P_z = 0)
  
  (P_x * IntVecA\i + P_y * IntVecA\j + P_z * IntVecA\k)
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
  
Structure IntVec4
  
  i.l
  j.l
  k.l
  l.l
  
EndStructure
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
  
Macro GetIntVec4i(IntVecA)
  
  IntVecA\i
  
EndMacro
  
Macro GetIntVec4j(IntVecA)
  
  IntVecA\j
  
EndMacro
  
Macro GetIntVec4k(IntVecA)
  
  IntVecA\k
  
EndMacro
  
Macro GetIntVec4l(IntVecA)
  
  IntVecA\l
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Update <<<<<
  
Macro UpdateIntVec4(IntVecA, P_i, P_j, P_k, P_l)
  
  GetIntVec4i(IntVecA) = P_i
  GetIntVec4j(IntVecA) = P_j
  GetIntVec4k(IntVecA) = P_k
  GetIntVec4l(IntVecA) = P_l
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Produit Scalaire <<<<<
  
Macro DotProductIntVec4(IntVecA, P_x, P_y, P_z, P_w)
  
  (P_x * GetIntVec4i(IntVecA) + P_y * GetIntVec4j(IntVecA) + P_z * GetIntVec4k(IntVecA) + P_w * GetIntVec4l(IntVecA))
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
  
Structure SimplexNoise
  
  IsInitialized.b
  Grad3.IntVec3[12]
  Grad4.IntVec4[32]
  Perm.l[512]
  Simplex.IntVec4[64]
  
EndStructure
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
  
Macro GetSimplexNoiseIsInitialized(SimplexNoiseA)
  
  SimplexNoiseA\IsInitialized
  
EndMacro
  
Macro GetSimplexNoiseGrad3(SimplexNoiseA, Index)
  
  SimplexNoiseA\Grad3[Index]
  
EndMacro
  
Macro GetSimplexNoiseGrad4(SimplexNoiseA, Index)
  
  SimplexNoiseA\Grad4[Index]
  
EndMacro
  
Macro GetSimplexNoisePerm(SimplexNoiseA, Index)
  
  SimplexNoiseA\Perm[Index]
  
EndMacro
  
Macro GetSimplexNoiseSimplex(SimplexNoiseA, Index)
  
  SimplexNoiseA\Simplex[Index]
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les mutateurs <<<<<
  
Macro SetSimplexNoiseIsInitialized(SimplexNoiseA, P_IsInitialized)
  
  GetSimplexNoiseIsInitialized(SimplexNoiseA) = P_IsInitialized
  
EndMacro
  
Macro SetSimplexNoisePerm(SimplexNoiseA, Index, P_Perm)
  
  GetSimplexNoisePerm(SimplexNoiseA, Index) = P_Perm
  
EndMacro
  
Macro SetSimplexNoisePermEx(SimplexNoiseA, Index, P_Perm)
  
  GetSimplexNoisePerm(SimplexNoiseA, Index) = P_Perm
  GetSimplexNoisePerm(SimplexNoiseA, Index + 256) = P_Perm
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Reset <<<<<
  
Macro ResetSimplexNoise(SimplexNoiseA)
  
  ClearStructure(SimplexNoiseA, SimplexNoise)
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Shortcut like C/C++ language <<<<<
; <<<<< int c1 = (x0 > y0) ? 32 : 0; <<<<<
  
Macro Interrogation(Variable, Test, If_True, If_False)
  
  If Test
    Variable = (If_True)
  Else 
    Variable = (If_False)
  EndIf 
  
EndMacro
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur FastFloor <<<<<
  
Macro FastFloor(Value, x)
  
  If x > 0
    Value = Int((x))
  Else
    Value = Int((x)-1)
  EndIf 
  
EndMacro 
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Initialize <<<<<
  
Procedure InitializeSimplexNoise()
  
  Shared *SimplexNoiseA.SimplexNoise
  
  *SimplexNoiseA.SimplexNoise = AllocateMemory(SizeOf(SimplexNoise))
  
  If *SimplexNoiseA = #Null
    
    MessageRequester("Fatal Error", "InitializeSimplexNoise() - Impossible to allocate memory !")
    End
    
  Else
    
    SetSimplexNoiseIsInitialized(*SimplexNoiseA, #True)
    
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 00), 1, 1, 0) 
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 01), -1, 1, 0) 
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 02), 1, -1, 0) 
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 03), -1, -1, 0)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 04), 1, 0, 1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 05), -1, 0, 1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 06), 1, 0, -1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 07), -1, 0, -1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 08), 0, 1, 1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 09), 0, -1, 1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 10), 0, 1, -1)
    UpdateIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, 11), 0, -1, -1)
    
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 00), 0,1,1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 01), 0,1,1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 02), 0,1,-1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 03), 0,1,-1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 04), 0,-1,1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 05), 0,-1,1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 06), 0,-1,-1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 07), 0,-1,-1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 08), 1,0,1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 09), 1,0,1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 10), 1,0,-1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 11), 1,0,-1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 12), -1,0,1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 13), -1,0,1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 14), -1,0,-1,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 15), -1,0,-1,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 16), 1,1,0,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 17), 1,1,0,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 18), 1,-1,0,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 19), 1,-1,0,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 20), -1,1,0,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 21), -1,1,0,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 22), -1,-1,0,1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 23), -1,-1,0,-1)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 24), 1,1,1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 25), 1,1,-1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 26), 1,-1,1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 27), 1,-1,-1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 28), -1,1,1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 29), -1,1,-1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 30), -1,-1,1,0)
    UpdateIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, 31), -1,-1,-1,0)
    
    SetSimplexNoisePermEx(*SimplexNoiseA, 000, 151)
    SetSimplexNoisePermEx(*SimplexNoiseA, 001, 160)
    SetSimplexNoisePermEx(*SimplexNoiseA, 002, 137)
    SetSimplexNoisePermEx(*SimplexNoiseA, 003, 091)
    SetSimplexNoisePermEx(*SimplexNoiseA, 004, 090)
    SetSimplexNoisePermEx(*SimplexNoiseA, 005, 015)
    SetSimplexNoisePermEx(*SimplexNoiseA, 006, 131)
    SetSimplexNoisePermEx(*SimplexNoiseA, 007, 013)
    SetSimplexNoisePermEx(*SimplexNoiseA, 008, 201)
    SetSimplexNoisePermEx(*SimplexNoiseA, 009, 095)
    SetSimplexNoisePermEx(*SimplexNoiseA, 010, 096)
    SetSimplexNoisePermEx(*SimplexNoiseA, 011, 053)
    SetSimplexNoisePermEx(*SimplexNoiseA, 012, 194)
    SetSimplexNoisePermEx(*SimplexNoiseA, 013, 233)
    SetSimplexNoisePermEx(*SimplexNoiseA, 014, 007)
    SetSimplexNoisePermEx(*SimplexNoiseA, 015, 225)
    SetSimplexNoisePermEx(*SimplexNoiseA, 016, 140)
    SetSimplexNoisePermEx(*SimplexNoiseA, 017, 036)
    SetSimplexNoisePermEx(*SimplexNoiseA, 018, 103)
    SetSimplexNoisePermEx(*SimplexNoiseA, 019, 030)
    SetSimplexNoisePermEx(*SimplexNoiseA, 020, 069)
    SetSimplexNoisePermEx(*SimplexNoiseA, 021, 142)
    SetSimplexNoisePermEx(*SimplexNoiseA, 022, 008)
    SetSimplexNoisePermEx(*SimplexNoiseA, 023, 099)
    SetSimplexNoisePermEx(*SimplexNoiseA, 024, 037)
    SetSimplexNoisePermEx(*SimplexNoiseA, 025, 240)
    SetSimplexNoisePermEx(*SimplexNoiseA, 026, 021)
    SetSimplexNoisePermEx(*SimplexNoiseA, 027, 010)
    SetSimplexNoisePermEx(*SimplexNoiseA, 028, 023)
    SetSimplexNoisePermEx(*SimplexNoiseA, 029, 190)
    SetSimplexNoisePermEx(*SimplexNoiseA, 030, 006)
    SetSimplexNoisePermEx(*SimplexNoiseA, 031, 148)
    SetSimplexNoisePermEx(*SimplexNoiseA, 032, 247)
    SetSimplexNoisePermEx(*SimplexNoiseA, 033, 120)
    SetSimplexNoisePermEx(*SimplexNoiseA, 034, 234)
    SetSimplexNoisePermEx(*SimplexNoiseA, 035, 075)
    SetSimplexNoisePermEx(*SimplexNoiseA, 036, 000)
    SetSimplexNoisePermEx(*SimplexNoiseA, 037, 026)
    SetSimplexNoisePermEx(*SimplexNoiseA, 038, 197)
    SetSimplexNoisePermEx(*SimplexNoiseA, 039, 062)
    SetSimplexNoisePermEx(*SimplexNoiseA, 040, 094)
    SetSimplexNoisePermEx(*SimplexNoiseA, 041, 252)
    SetSimplexNoisePermEx(*SimplexNoiseA, 042, 219)
    SetSimplexNoisePermEx(*SimplexNoiseA, 043, 203)
    SetSimplexNoisePermEx(*SimplexNoiseA, 044, 117)
    SetSimplexNoisePermEx(*SimplexNoiseA, 045, 035)
    SetSimplexNoisePermEx(*SimplexNoiseA, 046, 011)
    SetSimplexNoisePermEx(*SimplexNoiseA, 047, 032)
    SetSimplexNoisePermEx(*SimplexNoiseA, 048, 057)
    SetSimplexNoisePermEx(*SimplexNoiseA, 049, 177)
    SetSimplexNoisePermEx(*SimplexNoiseA, 050, 033)
    SetSimplexNoisePermEx(*SimplexNoiseA, 051, 088)
    SetSimplexNoisePermEx(*SimplexNoiseA, 052, 237)
    SetSimplexNoisePermEx(*SimplexNoiseA, 053, 149)
    SetSimplexNoisePermEx(*SimplexNoiseA, 054, 056)
    SetSimplexNoisePermEx(*SimplexNoiseA, 055, 087)
    SetSimplexNoisePermEx(*SimplexNoiseA, 056, 174)
    SetSimplexNoisePermEx(*SimplexNoiseA, 057, 020)
    SetSimplexNoisePermEx(*SimplexNoiseA, 058, 125)
    SetSimplexNoisePermEx(*SimplexNoiseA, 059, 136)
    SetSimplexNoisePermEx(*SimplexNoiseA, 060, 171)
    SetSimplexNoisePermEx(*SimplexNoiseA, 061, 168)
    SetSimplexNoisePermEx(*SimplexNoiseA, 062, 068)
    SetSimplexNoisePermEx(*SimplexNoiseA, 063, 175)
    SetSimplexNoisePermEx(*SimplexNoiseA, 064, 074)
    SetSimplexNoisePermEx(*SimplexNoiseA, 065, 165)
    SetSimplexNoisePermEx(*SimplexNoiseA, 066, 071)
    SetSimplexNoisePermEx(*SimplexNoiseA, 067, 134)
    SetSimplexNoisePermEx(*SimplexNoiseA, 068, 139)
    SetSimplexNoisePermEx(*SimplexNoiseA, 069, 048)
    SetSimplexNoisePermEx(*SimplexNoiseA, 070, 027)
    SetSimplexNoisePermEx(*SimplexNoiseA, 071, 166)
    SetSimplexNoisePermEx(*SimplexNoiseA, 072, 077)
    SetSimplexNoisePermEx(*SimplexNoiseA, 073, 146)
    SetSimplexNoisePermEx(*SimplexNoiseA, 074, 158)
    SetSimplexNoisePermEx(*SimplexNoiseA, 075, 231)
    SetSimplexNoisePermEx(*SimplexNoiseA, 076, 083)
    SetSimplexNoisePermEx(*SimplexNoiseA, 077, 111)
    SetSimplexNoisePermEx(*SimplexNoiseA, 078, 229)
    SetSimplexNoisePermEx(*SimplexNoiseA, 079, 122)
    SetSimplexNoisePermEx(*SimplexNoiseA, 080, 060)
    SetSimplexNoisePermEx(*SimplexNoiseA, 081, 211)
    SetSimplexNoisePermEx(*SimplexNoiseA, 082, 133)
    SetSimplexNoisePermEx(*SimplexNoiseA, 083, 230)
    SetSimplexNoisePermEx(*SimplexNoiseA, 084, 220)
    SetSimplexNoisePermEx(*SimplexNoiseA, 085, 105)
    SetSimplexNoisePermEx(*SimplexNoiseA, 086, 092)
    SetSimplexNoisePermEx(*SimplexNoiseA, 087, 041)
    SetSimplexNoisePermEx(*SimplexNoiseA, 088, 055)
    SetSimplexNoisePermEx(*SimplexNoiseA, 089, 046)
    SetSimplexNoisePermEx(*SimplexNoiseA, 090, 245)
    SetSimplexNoisePermEx(*SimplexNoiseA, 091, 040)
    SetSimplexNoisePermEx(*SimplexNoiseA, 092, 244)
    SetSimplexNoisePermEx(*SimplexNoiseA, 093, 102)
    SetSimplexNoisePermEx(*SimplexNoiseA, 094, 143)
    SetSimplexNoisePermEx(*SimplexNoiseA, 095, 054)
    SetSimplexNoisePermEx(*SimplexNoiseA, 096, 065)
    SetSimplexNoisePermEx(*SimplexNoiseA, 097, 025)
    SetSimplexNoisePermEx(*SimplexNoiseA, 098, 063)
    SetSimplexNoisePermEx(*SimplexNoiseA, 099, 161)
    SetSimplexNoisePermEx(*SimplexNoiseA, 100, 001)
    SetSimplexNoisePermEx(*SimplexNoiseA, 101, 216)
    SetSimplexNoisePermEx(*SimplexNoiseA, 102, 080)
    SetSimplexNoisePermEx(*SimplexNoiseA, 103, 073)
    SetSimplexNoisePermEx(*SimplexNoiseA, 104, 209)
    SetSimplexNoisePermEx(*SimplexNoiseA, 105, 076)
    SetSimplexNoisePermEx(*SimplexNoiseA, 106, 132)
    SetSimplexNoisePermEx(*SimplexNoiseA, 107, 187)
    SetSimplexNoisePermEx(*SimplexNoiseA, 108, 208)
    SetSimplexNoisePermEx(*SimplexNoiseA, 109, 089)
    SetSimplexNoisePermEx(*SimplexNoiseA, 110, 018)
    SetSimplexNoisePermEx(*SimplexNoiseA, 111, 169)
    SetSimplexNoisePermEx(*SimplexNoiseA, 112, 200)
    SetSimplexNoisePermEx(*SimplexNoiseA, 113, 196)
    SetSimplexNoisePermEx(*SimplexNoiseA, 114, 135)
    SetSimplexNoisePermEx(*SimplexNoiseA, 115, 130)
    SetSimplexNoisePermEx(*SimplexNoiseA, 116, 116)
    SetSimplexNoisePermEx(*SimplexNoiseA, 117, 188)
    SetSimplexNoisePermEx(*SimplexNoiseA, 118, 159)
    SetSimplexNoisePermEx(*SimplexNoiseA, 119, 086)
    SetSimplexNoisePermEx(*SimplexNoiseA, 120, 164)
    SetSimplexNoisePermEx(*SimplexNoiseA, 121, 100)
    SetSimplexNoisePermEx(*SimplexNoiseA, 122, 109)
    SetSimplexNoisePermEx(*SimplexNoiseA, 123, 198)
    SetSimplexNoisePermEx(*SimplexNoiseA, 124, 173)
    SetSimplexNoisePermEx(*SimplexNoiseA, 125, 186)
    SetSimplexNoisePermEx(*SimplexNoiseA, 126, 003)
    SetSimplexNoisePermEx(*SimplexNoiseA, 127, 064)
    SetSimplexNoisePermEx(*SimplexNoiseA, 128, 052)
    SetSimplexNoisePermEx(*SimplexNoiseA, 129, 217)
    SetSimplexNoisePermEx(*SimplexNoiseA, 130, 226)
    SetSimplexNoisePermEx(*SimplexNoiseA, 131, 250)
    SetSimplexNoisePermEx(*SimplexNoiseA, 132, 124)
    SetSimplexNoisePermEx(*SimplexNoiseA, 133, 123)
    SetSimplexNoisePermEx(*SimplexNoiseA, 134, 005)
    SetSimplexNoisePermEx(*SimplexNoiseA, 135, 202)
    SetSimplexNoisePermEx(*SimplexNoiseA, 136, 038)
    SetSimplexNoisePermEx(*SimplexNoiseA, 137, 147)
    SetSimplexNoisePermEx(*SimplexNoiseA, 138, 118)
    SetSimplexNoisePermEx(*SimplexNoiseA, 139, 126)
    SetSimplexNoisePermEx(*SimplexNoiseA, 140, 255)
    SetSimplexNoisePermEx(*SimplexNoiseA, 141, 082)
    SetSimplexNoisePermEx(*SimplexNoiseA, 142, 085)
    SetSimplexNoisePermEx(*SimplexNoiseA, 143, 212)
    SetSimplexNoisePermEx(*SimplexNoiseA, 144, 207)
    SetSimplexNoisePermEx(*SimplexNoiseA, 145, 206)
    SetSimplexNoisePermEx(*SimplexNoiseA, 146, 059)
    SetSimplexNoisePermEx(*SimplexNoiseA, 147, 227)
    SetSimplexNoisePermEx(*SimplexNoiseA, 148, 047)
    SetSimplexNoisePermEx(*SimplexNoiseA, 149, 016)
    SetSimplexNoisePermEx(*SimplexNoiseA, 150, 058)
    SetSimplexNoisePermEx(*SimplexNoiseA, 151, 017)
    SetSimplexNoisePermEx(*SimplexNoiseA, 152, 182)
    SetSimplexNoisePermEx(*SimplexNoiseA, 153, 189)
    SetSimplexNoisePermEx(*SimplexNoiseA, 154, 028)
    SetSimplexNoisePermEx(*SimplexNoiseA, 155, 042)
    SetSimplexNoisePermEx(*SimplexNoiseA, 156, 223)
    SetSimplexNoisePermEx(*SimplexNoiseA, 157, 183)
    SetSimplexNoisePermEx(*SimplexNoiseA, 158, 170)
    SetSimplexNoisePermEx(*SimplexNoiseA, 159, 213)
    SetSimplexNoisePermEx(*SimplexNoiseA, 160, 119)
    SetSimplexNoisePermEx(*SimplexNoiseA, 161, 248)
    SetSimplexNoisePermEx(*SimplexNoiseA, 162, 152)
    SetSimplexNoisePermEx(*SimplexNoiseA, 163, 002)
    SetSimplexNoisePermEx(*SimplexNoiseA, 164, 044)
    SetSimplexNoisePermEx(*SimplexNoiseA, 165, 154)
    SetSimplexNoisePermEx(*SimplexNoiseA, 166, 163)
    SetSimplexNoisePermEx(*SimplexNoiseA, 167, 070)
    SetSimplexNoisePermEx(*SimplexNoiseA, 168, 221)
    SetSimplexNoisePermEx(*SimplexNoiseA, 169, 153)
    SetSimplexNoisePermEx(*SimplexNoiseA, 170, 101)
    SetSimplexNoisePermEx(*SimplexNoiseA, 171, 155)
    SetSimplexNoisePermEx(*SimplexNoiseA, 172, 167)
    SetSimplexNoisePermEx(*SimplexNoiseA, 173, 043)
    SetSimplexNoisePermEx(*SimplexNoiseA, 174, 172)
    SetSimplexNoisePermEx(*SimplexNoiseA, 175, 009)
    SetSimplexNoisePermEx(*SimplexNoiseA, 176, 129)
    SetSimplexNoisePermEx(*SimplexNoiseA, 177, 022)
    SetSimplexNoisePermEx(*SimplexNoiseA, 178, 039)
    SetSimplexNoisePermEx(*SimplexNoiseA, 179, 253)
    SetSimplexNoisePermEx(*SimplexNoiseA, 180, 019)
    SetSimplexNoisePermEx(*SimplexNoiseA, 181, 098)
    SetSimplexNoisePermEx(*SimplexNoiseA, 182, 108)
    SetSimplexNoisePermEx(*SimplexNoiseA, 183, 110)
    SetSimplexNoisePermEx(*SimplexNoiseA, 184, 079)
    SetSimplexNoisePermEx(*SimplexNoiseA, 185, 113)
    SetSimplexNoisePermEx(*SimplexNoiseA, 186, 224)
    SetSimplexNoisePermEx(*SimplexNoiseA, 187, 232)
    SetSimplexNoisePermEx(*SimplexNoiseA, 188, 178)
    SetSimplexNoisePermEx(*SimplexNoiseA, 189, 185)
    SetSimplexNoisePermEx(*SimplexNoiseA, 190, 112)
    SetSimplexNoisePermEx(*SimplexNoiseA, 191, 104)
    SetSimplexNoisePermEx(*SimplexNoiseA, 192, 218)
    SetSimplexNoisePermEx(*SimplexNoiseA, 193, 246)
    SetSimplexNoisePermEx(*SimplexNoiseA, 194, 097)
    SetSimplexNoisePermEx(*SimplexNoiseA, 195, 228)
    SetSimplexNoisePermEx(*SimplexNoiseA, 196, 251)
    SetSimplexNoisePermEx(*SimplexNoiseA, 197, 034)
    SetSimplexNoisePermEx(*SimplexNoiseA, 198, 242)
    SetSimplexNoisePermEx(*SimplexNoiseA, 199, 193)
    SetSimplexNoisePermEx(*SimplexNoiseA, 200, 238)
    SetSimplexNoisePermEx(*SimplexNoiseA, 201, 210)
    SetSimplexNoisePermEx(*SimplexNoiseA, 202, 144)
    SetSimplexNoisePermEx(*SimplexNoiseA, 203, 012)
    SetSimplexNoisePermEx(*SimplexNoiseA, 204, 191)
    SetSimplexNoisePermEx(*SimplexNoiseA, 205, 179)
    SetSimplexNoisePermEx(*SimplexNoiseA, 206, 162)
    SetSimplexNoisePermEx(*SimplexNoiseA, 207, 241)
    SetSimplexNoisePermEx(*SimplexNoiseA, 208, 081)
    SetSimplexNoisePermEx(*SimplexNoiseA, 209, 051)
    SetSimplexNoisePermEx(*SimplexNoiseA, 210, 145)
    SetSimplexNoisePermEx(*SimplexNoiseA, 211, 235)
    SetSimplexNoisePermEx(*SimplexNoiseA, 212, 249)
    SetSimplexNoisePermEx(*SimplexNoiseA, 213, 014)
    SetSimplexNoisePermEx(*SimplexNoiseA, 214, 239)
    SetSimplexNoisePermEx(*SimplexNoiseA, 215, 107)
    SetSimplexNoisePermEx(*SimplexNoiseA, 216, 049)
    SetSimplexNoisePermEx(*SimplexNoiseA, 217, 192)
    SetSimplexNoisePermEx(*SimplexNoiseA, 218, 214)
    SetSimplexNoisePermEx(*SimplexNoiseA, 219, 031)
    SetSimplexNoisePermEx(*SimplexNoiseA, 220, 181)
    SetSimplexNoisePermEx(*SimplexNoiseA, 221, 199)
    SetSimplexNoisePermEx(*SimplexNoiseA, 222, 106)
    SetSimplexNoisePermEx(*SimplexNoiseA, 223, 157)
    SetSimplexNoisePermEx(*SimplexNoiseA, 224, 184)
    SetSimplexNoisePermEx(*SimplexNoiseA, 225, 084)
    SetSimplexNoisePermEx(*SimplexNoiseA, 226, 204)
    SetSimplexNoisePermEx(*SimplexNoiseA, 227, 176)
    SetSimplexNoisePermEx(*SimplexNoiseA, 228, 115)
    SetSimplexNoisePermEx(*SimplexNoiseA, 229, 121)
    SetSimplexNoisePermEx(*SimplexNoiseA, 230, 050)
    SetSimplexNoisePermEx(*SimplexNoiseA, 231, 045)
    SetSimplexNoisePermEx(*SimplexNoiseA, 232, 127)
    SetSimplexNoisePermEx(*SimplexNoiseA, 233, 004)
    SetSimplexNoisePermEx(*SimplexNoiseA, 234, 150)
    SetSimplexNoisePermEx(*SimplexNoiseA, 235, 254)
    SetSimplexNoisePermEx(*SimplexNoiseA, 236, 138)
    SetSimplexNoisePermEx(*SimplexNoiseA, 237, 236)
    SetSimplexNoisePermEx(*SimplexNoiseA, 238, 205)
    SetSimplexNoisePermEx(*SimplexNoiseA, 239, 093)
    SetSimplexNoisePermEx(*SimplexNoiseA, 240, 222)
    SetSimplexNoisePermEx(*SimplexNoiseA, 241, 114)
    SetSimplexNoisePermEx(*SimplexNoiseA, 242, 067)
    SetSimplexNoisePermEx(*SimplexNoiseA, 243, 029)
    SetSimplexNoisePermEx(*SimplexNoiseA, 244, 024)
    SetSimplexNoisePermEx(*SimplexNoiseA, 245, 072)
    SetSimplexNoisePermEx(*SimplexNoiseA, 246, 243)
    SetSimplexNoisePermEx(*SimplexNoiseA, 247, 141)
    SetSimplexNoisePermEx(*SimplexNoiseA, 248, 128)
    SetSimplexNoisePermEx(*SimplexNoiseA, 249, 195)
    SetSimplexNoisePermEx(*SimplexNoiseA, 250, 078)
    SetSimplexNoisePermEx(*SimplexNoiseA, 251, 066)
    SetSimplexNoisePermEx(*SimplexNoiseA, 252, 215)
    SetSimplexNoisePermEx(*SimplexNoiseA, 253, 061)
    SetSimplexNoisePermEx(*SimplexNoiseA, 254, 156)
    SetSimplexNoisePermEx(*SimplexNoiseA, 255, 180)
    
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 00), 0,1,2,3)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 01), 0,1,3,2)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 02), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 03), 0,2,3,1)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 04), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 05), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 06), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 07), 1,2,3,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 08), 0,2,1,3)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 09), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 10), 0,3,1,2)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 11), 0,3,2,1)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 12), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 13), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 14), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 15), 1,3,2,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 16), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 17), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 18), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 19), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 20), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 21), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 22), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 23), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 24), 1,2,0,3)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 25), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 26), 1,3,0,2)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 27), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 28), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 29), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 30), 2,3,0,1)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 31), 2,3,1,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 32), 1,0,2,3)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 33), 1,0,3,2)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 34), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 35), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 36), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 37), 2,0,3,1)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 38), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 39), 2,1,3,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 40), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 41), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 42), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 43), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 44), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 45), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 46), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 47), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 48), 2,0,1,3)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 49), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 50), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 51), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 52), 3,0,1,2)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 53), 3,0,2,1)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 54), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 55), 3,1,2,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 56), 2,1,0,3)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 57), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 58), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 59), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 60), 3,1,0,2)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 61), 0,0,0,0)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 62), 3,2,0,1)
    UpdateIntVec4(GetSimplexNoiseSimplex(*SimplexNoiseA, 63), 3,2,1,0)
    
  EndIf 
  
EndProcedure
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Randomize <<<<<
  
Procedure RandomizeSimplexNoisePermutationTable()
  
  Shared *SimplexNoiseA.SimplexNoise
  
  If *SimplexNoiseA = #Null
    
    InitializeSimplexNoise()
    
  Else 
    
    For Index = 0 To 255
      SetSimplexNoisePermEx(*SimplexNoiseA, Index, Random(255))
    Next
    
  EndIf 
  
EndProcedure 
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Destroy <<<<<
  
Procedure DestroySimplexNoise()
  
  Shared *SimplexNoiseA.SimplexNoise
  
  If *SimplexNoiseA <> #Null
    ResetSimplexNoise(*SimplexNoiseA)
    FreeMemory(*SimplexNoiseA)
  EndIf
  
EndProcedure
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Évaluateur SimplexNoise2D <<<<<
  
Procedure.d SimplexNoise2D(x.d, y.d) 
  
  Shared *SimplexNoiseA.SimplexNoise
  
  If *SimplexNoiseA = #Null
    
    InitializeSimplexNoise()
    
  Else 
    
    Sqrt_3.d = Sqr(3.0)
    F2.d = 0.5 * (Sqrt_3 - 1)
    S.d = (x + y) * F2
    G2.d = (3.0 - Sqrt_3) / 6.0
    
    FastFloor(i.l, x + S)
    FastFloor(j.l, y + S)  
    
    t.d = (i + j) * G2
    
    xx0.d = x - (i - t)
    yy0.d = y - (j - t)
    
    If xx0 > yy0
      i1.l = 1
      j1.l = 0
    Else
      i1.l = 0
      j1.l = 1
    EndIf 
    
    xx1.d = xx0 - i1 + G2
    yy1.d = yy0 - j1 + G2
    xx2.d = xx0 - 1.0 + 2.0 * G2
    yy2.d = yy0 - 1.0 + 2.0 * G2  
    
    ii.l = i & 255
    jj.l = j & 255
    gi0.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + GetSimplexNoisePerm(*SimplexNoiseA, jj)) % 12
    gi1.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + i1 + GetSimplexNoisePerm(*SimplexNoiseA, jj + j1)) % 12
    gi2.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + 1 + GetSimplexNoisePerm(*SimplexNoiseA, jj + 1)) % 12
    
    t0.d = 0.5 - xx0 * xx0 - yy0 * yy0
    t1.d = 0.5 - xx1 * xx1 - yy1 * yy1
    t2.d = 0.5 - xx2 * xx2 - yy2 * yy2
    
    If t0 < 0
      n0.d = 0.0
    Else
      t0 = t0 * t0
      n0 = t0 * t0 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi0), xx0, yy0)
    EndIf 
    
    If t1 < 0
      n1.d = 0.0
    Else
      t1 = t1 * t1
      n1 = t1 * t1 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi1), xx1, yy1)
    EndIf 
    
    If t2 < 0
      n2.d = 0.0
    Else
      t2 = t2 * t2
      n2 = t2 * t2 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi2), xx2, yy2)
    EndIf 
  EndIf 
  
  ProcedureReturn 70.0 * (n0 + n1 + n2)
EndProcedure 
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Évaluateur SimplexNoise3D <<<<<
  
Procedure.d SimplexNoise3D(x.d, y.d, z.d) 
  
  Shared *SimplexNoiseA.SimplexNoise
  
  If *SimplexNoiseA = #Null
    
    InitializeSimplexNoise()
    
  Else 
    
    F3.d = 1.0/3.0
    S.d = (x + y + z) * F3
    
    FastFloor(i.l, x + S)
    FastFloor(j.l, y + S)  
    FastFloor(k.l, z + S)  
    
    G3.d = 1.0/6.0
    t.d = (i + j + k) * G3
    
    xx0.d = x - (i - t)
    yy0.d = y - (j - t)
    zz0.d = z - (k - t)
    
    If xx0 >= yy0
      
      If yy0 >= zz0
        i1.l = 1
        j1.l = 0
        k1.l = 0
        i2.l = 1
        j2.l = 1
        k2.l = 0
      ElseIf xx0 >= zz0
        i1 = 1
        j1 = 0
        k1 = 0
        i2 = 1
        j2 = 0
        k2 = 1
      Else
        i1 = 0
        j1 = 0
        k1 = 1
        i2 = 1
        j2 = 0
        k2 = 1
      EndIf 
      
    Else
      
      If yy0 >= zz0
        i1 = 0
        j1 = 0
        k1 = 1
        i2 = 0
        j2 = 1
        k2 = 1
      ElseIf xx0 < zz0
        i1 = 0
        j1 = 1
        k1 = 0
        i2 = 0
        j2 = 1
        k2 = 1
      Else
        i1 = 0
        j1 = 1
        k1 = 0
        i2 = 1
        j2 = 1
        k2 = 0
      EndIf 
      
    EndIf 
    
    xx1.d = xx0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
    yy1.d = yy0 - j1 + G3;
    zz1.d = zz0 - k1 + G3;
    xx2.d = xx0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
    yy2.d = yy0 - j2 + 2.0 * G3;
    zz2.d = zz0 - k2 + 2.0 * G3;
    xx3.d = xx0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
    yy3.d = yy0 - 1.0 + 3.0 * G3;
    zz3.d = zz0 - 1.0 + 3.0 * G3;
    
    ii.l = i & 255;
    jj.l = j & 255;
    kk.l = k & 255;
    
    gi0.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + GetSimplexNoisePerm(*SimplexNoiseA, jj + GetSimplexNoisePerm(*SimplexNoiseA, kk))) % 12
    gi1.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + i1 + GetSimplexNoisePerm(*SimplexNoiseA, jj + j1 + GetSimplexNoisePerm(*SimplexNoiseA, kk + k1))) % 12
    gi2.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + i2 + GetSimplexNoisePerm(*SimplexNoiseA, jj + j2 + GetSimplexNoisePerm(*SimplexNoiseA, kk + k2))) % 12
    gi3.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + 1 + GetSimplexNoisePerm(*SimplexNoiseA, jj + 1 + GetSimplexNoisePerm(*SimplexNoiseA, kk + 1))) % 12
    
    t0.d = 0.6 - xx0 * xx0 - yy0 * yy0 - zz0 * zz0
    t1.d = 0.6 - xx1 * xx1 - yy1 * yy1 - zz1 * zz1
    t2.d = 0.6 - xx2 * xx2 - yy2 * yy2 - zz2 * zz2
    t3.d = 0.6 - xx3 * xx3 - yy3 * yy3 - zz3 * zz3
    
    If t0 < 0
      n0.d = 0.0
    Else
      t0 = t0 * t0
      n0 = t0 * t0 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi0), xx0, yy0, zz0)
    EndIf 
    
    If t1 < 0
      n1.d = 0.0
    Else
      t1 = t1 * t1
      n1 = t1 * t1 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi1), xx1, yy1, zz1)
    EndIf 
    
    If t2 < 0
      n2.d = 0.0
    Else
      t2 = t2 * t2
      n2 = t2 * t2 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi2), xx2, yy2, zz2)
    EndIf 
    
    If t3 < 0
      n3.d = 0.0
    Else
      t3 = t3 * t3
      n3 = t3 * t3 * DotProductIntVec3(GetSimplexNoiseGrad3(*SimplexNoiseA, gi3), xx3, yy3, zz3)
    EndIf
    
  EndIf
  
  ProcedureReturn 32.0 * (n0 + n1 + n2 + n3)
EndProcedure 
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Évaluateur SimplexNoise4D <<<<<
  
Procedure.d SimplexNoise4D(x.d, y.d, z.d, w.d) 
  
  Shared *SimplexNoiseA.SimplexNoise
  
  If *SimplexNoiseA = #Null
    
    InitializeSimplexNoise()
    
  Else 
    
    sqrt_5.d = Sqr(5.0)
    
    F4.d = (sqrt_5 - 1.0) / 4.0
    G4.d = (5.0 - sqrt_5) / 20.0
    S.d = (x + y + z + w) * F4
    
    FastFloor(i.l, x + S)
    FastFloor(j.l, y + S)  
    FastFloor(k.l, z + S)  
    FastFloor(l.l, w + S)  
    
    t.d = (i + j + k + l) * G4
    
    xx0.d = x - (i - t)
    yy0.d = y - (j - t)
    zz0.d = z - (k - t)
    ww0.d = w - (l - t)
    
    Interrogation(c1.l, xx0 > yy0, 32, 0)
    Interrogation(c2.l, xx0 > zz0, 16, 0)
    Interrogation(c3.l, yy0 > zz0, 8, 0)
    Interrogation(c4.l, xx0 > ww0, 4, 0)
    Interrogation(c5.l, yy0 > ww0, 2, 0)
    Interrogation(c6.l, zz0 > ww0, 1, 0)
    
    c.l = c1 + c2 + c3 + c4 + c5 + c6
    
    Interrogation(i1.l, GetIntVec4i(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 3, 1, 0)
    Interrogation(j1.l, GetIntVec4j(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 3, 1, 0)
    Interrogation(k1.l, GetIntVec4k(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 3, 1, 0)
    Interrogation(l1.l, GetIntVec4l(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 3, 1, 0)
    
    Interrogation(i2.l, GetIntVec4i(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 2, 1, 0)
    Interrogation(j2.l, GetIntVec4j(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 2, 1, 0)
    Interrogation(k2.l, GetIntVec4k(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 2, 1, 0)
    Interrogation(l2.l, GetIntVec4l(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 2, 1, 0)  
    
    Interrogation(i3.l, GetIntVec4i(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 1, 1, 0)
    Interrogation(j3.l, GetIntVec4j(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 1, 1, 0)
    Interrogation(k3.l, GetIntVec4k(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 1, 1, 0)
    Interrogation(l3.l, GetIntVec4l(GetSimplexNoiseSimplex(*SimplexNoiseA, c)) >= 1, 1, 0)    
    
    xx1.d = xx0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
    yy1.d = yy0 - j1 + G4;
    zz1.d = zz0 - k1 + G4;
    ww1.d = ww0 - l1 + G4;
    xx2.d = xx0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
    yy2.d = yy0 - j2 + 2.0 * G4;
    zz2.d = zz0 - k2 + 2.0 * G4;
    ww2.d = ww0 - l2 + 2.0 * G4;
    xx3.d = xx0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
    yy3.d = yy0 - j3 + 3.0 * G4;
    zz3.d = zz0 - k3 + 3.0 * G4;
    ww3.d = ww0 - l3 + 3.0 * G4;
    xx4.d = xx0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
    yy4.d = yy0 - 1.0 + 4.0 * G4;
    zz4.d = zz0 - 1.0 + 4.0 * G4;
    ww4.d = ww0 - 1.0 + 4.0 * G4;
    
    ii.l = i & 255;
    jj.l = j & 255;
    kk.l = k & 255;
    ll.l = l & 255;
    
    gi0.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + GetSimplexNoisePerm(*SimplexNoiseA, jj + GetSimplexNoisePerm(*SimplexNoiseA, kk + GetSimplexNoisePerm(*SimplexNoiseA, ll)))) % 32
    gi1.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + i1 + GetSimplexNoisePerm(*SimplexNoiseA, jj + j1 + GetSimplexNoisePerm(*SimplexNoiseA, kk + k1 + GetSimplexNoisePerm(*SimplexNoiseA, ll + l1)))) % 32
    gi2.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + i2 + GetSimplexNoisePerm(*SimplexNoiseA, jj + j2 + GetSimplexNoisePerm(*SimplexNoiseA, kk + k2 + GetSimplexNoisePerm(*SimplexNoiseA, ll + l2)))) % 32
    gi3.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + i3 + GetSimplexNoisePerm(*SimplexNoiseA, jj + j3 + GetSimplexNoisePerm(*SimplexNoiseA, kk + k3 + GetSimplexNoisePerm(*SimplexNoiseA, ll + l3)))) % 32
    gi4.l = GetSimplexNoisePerm(*SimplexNoiseA, ii + 1 + GetSimplexNoisePerm(*SimplexNoiseA, jj + 1 + GetSimplexNoisePerm(*SimplexNoiseA, kk + 1 + GetSimplexNoisePerm(*SimplexNoiseA, ll + 1)))) % 32
    
    t0.d = 0.6 - xx0 * xx0 - yy0 * yy0 - zz0 * zz0 - ww0 * ww0
    t1.d = 0.6 - xx1 * xx1 - yy1 * yy1 - zz1 * zz1 - ww1 * ww1
    t2.d = 0.6 - xx2 * xx2 - yy2 * yy2 - zz2 * zz2 - ww2 * ww2
    t3.d = 0.6 - xx3 * xx3 - yy3 * yy3 - zz3 * zz3 - ww3 * ww3
    t4.d = 0.6 - xx4 * xx4 - yy4 * yy4 - zz4 * zz4 - ww4 * ww4
    
    If t0 < 0
      n0.d = 0.0
    Else
      t0 = t0 * t0
      n0 = t0 * t0 * DotProductIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, gi0), xx0, yy0, zz0, ww0)
    EndIf 
    
    If t1 < 0
      n1.d = 0.0
    Else
      t1 = t1 * t1
      n1 = t1 * t1 * DotProductIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, gi1), xx1, yy1, zz1, ww2)
    EndIf 
    
    If t2 < 0
      n2.d = 0.0
    Else
      t2 = t2 * t2
      n2 = t2 * t2 * DotProductIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, gi2), xx2, yy2, zz2, ww2)
    EndIf 
    
    If t3 < 0
      n3.d = 0.0
    Else
      t3 = t3 * t3
      n3 = t3 * t3 * DotProductIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, gi3), xx3, yy3, zz3, ww3)
    EndIf 
    
    If t4 < 0
      n4.d = 0.0
    Else
      t4 = t4 * t4
      n4 = t4 * t4 * DotProductIntVec4(GetSimplexNoiseGrad4(*SimplexNoiseA, gi4), xx4, yy4, zz4, ww4)
    EndIf 
    
  EndIf 
  
  ProcedureReturn 27.0 * (n0 + n1 + n2 + n3 + n4)
EndProcedure 
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
; <<<<< !!! WARNING - YOU ARE NOW IN A TESTING ZONE - WARNING !!! <<<<< 
; <<<<< !!! WARNING - THIS CODE SHOULD BE COMMENTED - WARNING !!! <<<<< 
; <<<<< !!! WARNING - BEFORE THE FINAL COMPILATION. - WARNING !!! <<<<< 
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
  
InitializeSimplexNoise()
Debug SimplexNoise2D(2.0, 3.5) 
Debug SimplexNoise3D(2.0, 4.5, 5.0)
Debug SimplexNoise4D(2.0, 3.5, 3.5, 2.0)
DestroySimplexNoise()
  
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< FIN DU FICHIER <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Re: SimplexNoise 2D 3D et 4D - V1.0.2

Message par Ollivier »

Bonjour Guimauve,

Je dois t'avouer que je n'ai rien compris! Pourtant, j'ai réussi à faire fonctionner la fonction 2D. ça donne un rendu aléatoire assez propre.
(représentation de nuages, de littoraux, etc...)

Sur le Net, ils disent que cette formule offre toute sa fiabilité en 3D et 4D. J'espère que tu auras le temps de poster quelques infos sur son utilisation.

En tout cas, merci pour ce partage d'un niveau mathématique stratosphérique.

Ollivier
Guimauve
Messages : 1015
Inscription : mer. 11/févr./2004 0:32
Localisation : Québec, Canada

Re: SimplexNoise 2D 3D et 4D - V1.0.2

Message par Guimauve »

Ollivier a écrit :Bonjour Guimauve,

Je dois t'avouer que je n'ai rien compris! Pourtant, j'ai réussi à faire fonctionner la fonction 2D. ça donne un rendu aléatoire assez propre.
(représentation de nuages, de littoraux, etc...)

Sur le Net, ils disent que cette formule offre toute sa fiabilité en 3D et 4D. J'espère que tu auras le temps de poster quelques infos sur son utilisation.

En tout cas, merci pour ce partage d'un niveau mathématique stratosphérique.

Ollivier
L'idée générale est de partir d'une géode contenant quelques milliers de triangle composé de 3 points en 3D. Dans le cas d'une géode inscrite dans une sphère de rayon 1 chacun des points se trouve sur cette sphère et donc chacun des points est en fait un rayon de la sphère. Voir ici : http://fr.wikipedia.org/wiki/G%C3%A9ode

La fonction SimplexNoise2D() permet de dessiner une image avec des points foncés, moins foncés, moins clairs, clairs. Tu semble à voir bien compris l'astuce en 2D. En 3D c'est la même chose sauf que l'on ne dessine pas sur une image, on déforme la géode en modifiant la position des vertex. Comment on fait ça ? Simple on prend la liste des vertex et on passe les coordonnées {x,y,z} 1 à 1 en paramètre à la fonction SimplexNoise3D(). Celle-ci retourne une valeur entre -1.000000 et 1.000000. Ici il faut limiter les valeurs entre disons -0.35000 et 0.35000 par ce que la déformation serait trop importante. Ensuite avec 1.0000 + la valeur modifiée trouvée par la fonction SimplexNoise3D() cela donne le facteur d'échelle pour le rayon passant par le centre de la géode et le vertex en question.

Produit d'une vecteur par un scalaire : Vertex{x,y,z} * Scale

Et voilà le vertex à changé de place, si le Scale est < 1.00, il a été enfoncé (point foncé avec SimplexNoise2D) et si le Scale > 1.00 le point est tirée (point clair avec SimplexNoise2D())

Le résultat ressemble à que l'on peut voir ici : http://caffeineabuse.blogspot.com/2008/ ... eroid.html

J'espère que c'est un peu plus claire.

A+
Guimauve
Répondre