I made this demo, but it is not giving me that clouds like look that I expected. I know the PerlinNoise function is returning correctly, but I did notice that Processing must use one of the older noise functions as it gives different results than the Improved Perlin Noise function.
This takes sometime at first. I was hoping to do animations with the PerlinNoise function, but it is not fast enough with my implementation.
Unfortunately this demo is nothing to look at. Just something to give some code for others perhaps to come up with something.
Uses "TBGL"
#INCLUDE "%APP_INCLUDEPATH%thinbasic_gl.inc" ' to use glColor4d function
#INCLUDE "https://raw.githubusercontent.com/kryton9/thinBasic-PerlinNoise/master/PerlinNoise.tbasicu"
DWord hWnd = 0
Long x = 0
Long y = 0
Double frameRate = 0.0
Long interval = 0
Long width = 250 'larger the longer it takes to calculate
Long height = 100 'larger the longer it takes to calculate
Long numPoints = width * height
String winTitle = "Calculating " + numPoints + " Noise Values, This can take Some time."
Double noise ( width, height )
Double yOff = 0.0
Double xOff = 0.0
Double noiseZoom = 0.1 'good ranges : 0.1 to 0.001
hWnd = TBGL_CreateWindowEx ( "PerlinNoise 2D GL Demo", width, height, 32, %TBGL_WS_WINDOWED )
TBGL_ShowWindow
TBGL_SetWindowTitle ( hWnd, winTitle)
For y = 1 To height
yOff += noiseZoom
winTitle = "Calculating " + Str$ (x * y) + " of " + numPoints + " Noise Values, working away."
TBGL_SetWindowTitle ( hWnd, winTitle)
For x = 1 To width
xOff += noiseZoom
noise(x, y) = PerlinNoise xOff, yOff, 7
Next
Next
TBGL_BlendFunc %GL_SRC_ALPHA , %GL_ONE
TBGL_UseBlend %TRUE
TBGL_RenderMatrix2D ( 1, height, width, 1 )
While TBGL_IsWindow ( hWnd )
FrameRate = TBGL_GetFrameRate
Incr interval
If interval > 5 Then
TBGL_SetWindowTitle ( hWnd, "PerlinNoise 2D GL Demo FPS: " + Str$ ( FrameRate, 4 ) )
interval = 0
EndIf
TBGL_ClearFrame
TBGL_PushMatrix
TBGL_BeginPoly %GL_POINTS
For y = 1 To height
For x = 1 To width
glColor4d 255, 255, 255, noise ( x, y )
TBGL_Vertex x, y
Next
Next
TBGL_EndPoly
TBGL_PopMatrix
TBGL_DrawFrame
If TBGL_GetWindowKeyState( hWnd, %VK_ESCAPE ) Then Exit While
Wend
TBGL_DestroyWindow
NoiseGLDemo.png
Bookmarks