From 69d47c6767a823f9f8f7d6d72afae0212bdbd020 Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Fri, 23 Oct 2020 23:06:34 +0200 Subject: [PATCH] cleanup, and minor performance improvements, but overal using doubles instead of floats in the fragment shader, rendering speed has gone down, but now you can zoom further --- README.md | 2 + src/mandelbrot/mandelbrot.nim | 35 ++- src/mandelbrot/shader.frag | 517 +++++++++++++++++----------------- 3 files changed, 280 insertions(+), 274 deletions(-) diff --git a/README.md b/README.md index d1eb944..6cbe1f9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ * my first nim project https://nim-lang.org/ * also: my first opengl project, manually translated from c++ found in https://physicspython.wordpress.com/2020/02/16/visualizing-the-mandelbrot-set-using-opengl-part-1/ * works at least on my mac +* start with `nimble run` +* use arrow keys to navigate en ESC to quit \ No newline at end of file diff --git a/src/mandelbrot/mandelbrot.nim b/src/mandelbrot/mandelbrot.nim index 2c137b8..fa9d3a0 100644 --- a/src/mandelbrot/mandelbrot.nim +++ b/src/mandelbrot/mandelbrot.nim @@ -1,25 +1,22 @@ import nimgl/[glfw, opengl] - +# keeps track of the GL program and the shaders, to interact with GL var GLData: tuple[program, vertexShader, fragmentShader: uint32] const WIN_WIDTH = 1000 WIN_HEIGHT = 800 +# navigation parameters var center_x = 0.0f center_y = 0.0f zoom:float64 = 1.0 - dx=0.0 - dy=0.0 - zf=0.99 + dx = -0.001 + dy = 0.0 + zf = 0.999 +# handle keys proc keyProc(window: GLFWWindow, key: int32, scancode: int32, action: int32, mods: int32): void {.cdecl.} = -# if key == GLFWKey.ESCAPE and action == GLFWPress: -# window.setWindowShouldClose(true) - - -# proc process_input(window: GLFWwindow) if action == GLFWPress: if key == GLFWKey.ESCAPE: window.setWindowShouldClose(true) @@ -32,7 +29,7 @@ proc keyProc(window: GLFWWindow, key: int32, scancode: int32, action: int32, mod if key == GLFWKey.RIGHT: dx += 0.001f; - +# prints an error message if necessary (if the shader won't) proc logShaderCompilationFailure(shader: uint32, shader_path:string) = var logSize: int32 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, logSize.addr) @@ -46,6 +43,7 @@ proc logShaderCompilationFailure(shader: uint32, shader_path:string) = dealloc(logStr) quit(-1) +# prints an error message if necessary proc logProgramLinkingError() = var logSize: int32 glGetProgramiv(GLData.program, GL_INFO_LOG_LENGTH, logSize.addr) @@ -57,6 +55,7 @@ proc logProgramLinkingError() = dealloc(logStr) quit(-1) +# compiles a shader given a source file and a type proc addShader(shader_path: string, shader_type: GLenum):uint32 = let shadercode = readFile(shader_path) @@ -72,6 +71,7 @@ proc addShader(shader_path: string, shader_type: GLenum):uint32 = return shader +# loads program and shaders proc initShaders(vertex_shader_path: string, fragment_shader_path: string) = GLData.program = glCreateProgram() GLData.vertexShader = addShader(vertex_shader_path, GL_VERTEX_SHADER) @@ -83,6 +83,7 @@ proc initShaders(vertex_shader_path: string, fragment_shader_path: string) = if success == 0: logProgramLinkingError() +# pass data to the fragment shader proc set_float(name: string, value:float) = glUniform1f(glGetUniformLocation(GLData.program, name.cstring()), value.cfloat()); @@ -107,6 +108,7 @@ proc main() = assert glInit() + # two triangles that together make up the entire window var vertices = @[ -1.0f, -1.0f, -0.0f, 1.0f, 1.0f, -0.0f, @@ -120,6 +122,7 @@ proc main() = # | .' | # 0'---3 + # load the data into GL var mesh: tuple[vao,vbo,ebo: uint32] glGenVertexArrays(1, mesh.vao.addr) @@ -141,11 +144,13 @@ proc main() = glBindVertexArray(mesh.vao) initShaders("src/mandelbrot/shader.vert", "src/mandelbrot/shader.frag") + glUseProgram(GLData.program) + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) + glBindVertexArray(mesh.vao) + + # main loop while not window.windowShouldClose: - glClearColor(0.2, 0.2, 0.2, 0.5) - glUseProgram(GLData.program) - glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) - + # update zoom params zoom *= zf if zf < 0.0: zf = 0.0 center_y += dy * zoom @@ -155,11 +160,11 @@ proc main() = if center_x > 1.0f: center_x = 1.0f if center_x < -1.0f: center_x = -1.0f + # pass the data to the shader set_float("zoom", zoom) set_float("center_x", center_x) set_float("center_y", center_y) - glBindVertexArray(mesh.vao) glDrawElements(GL_TRIANGLES, indices.len.cint, GL_UNSIGNED_INT, nil) window.swapBuffers() glfwPollEvents() diff --git a/src/mandelbrot/shader.frag b/src/mandelbrot/shader.frag index f74017a..565e91f 100644 --- a/src/mandelbrot/shader.frag +++ b/src/mandelbrot/shader.frag @@ -2,7 +2,6 @@ in vec4 gl_FragCoord; out vec4 fragColor; -//out float gl_FragDepth; uniform float center_x; uniform float center_y; @@ -11,268 +10,268 @@ uniform float zoom; #define MAX_ITERATIONS 600 const vec3 colors[256] = vec3[256]( -vec3(0.0,0.0,0.0), -vec3(128.0,0.0,0.0), -vec3(0.0,128.0,0.0), -vec3(128.0,128.0,0.0), -vec3(0.0,0.0,128.0), -vec3(128.0,0.0,128.0), -vec3(0.0,128.0,128.0), -vec3(192.0,192.0,192.0), -vec3(128.0,128.0,128.0), -vec3(255.0,0.0,0.0), -vec3(0.0,255.0,0.0), -vec3(255.0,255.0,0.0), -vec3(0.0,0.0,255.0), -vec3(255.0,0.0,255.0), -vec3(0.0,255.0,255.0), -vec3(255.0,255.0,255.0), -vec3(0.0,0.0,0.0), -vec3(0.0,0.0,95.0), -vec3(0.0,0.0,135.0), -vec3(0.0,0.0,175.0), -vec3(0.0,0.0,215.0), -vec3(0.0,0.0,255.0), -vec3(0.0,95.0,0.0), -vec3(0.0,95.0,95.0), -vec3(0.0,95.0,135.0), -vec3(0.0,95.0,175.0), -vec3(0.0,95.0,215.0), -vec3(0.0,95.0,255.0), -vec3(0.0,135.0,0.0), -vec3(0.0,135.0,95.0), -vec3(0.0,135.0,135.0), -vec3(0.0,135.0,175.0), -vec3(0.0,135.0,215.0), -vec3(0.0,135.0,255.0), -vec3(0.0,175.0,0.0), -vec3(0.0,175.0,95.0), -vec3(0.0,175.0,135.0), -vec3(0.0,175.0,175.0), -vec3(0.0,175.0,215.0), -vec3(0.0,175.0,255.0), -vec3(0.0,215.0,0.0), -vec3(0.0,215.0,95.0), -vec3(0.0,215.0,135.0), -vec3(0.0,215.0,175.0), -vec3(0.0,215.0,215.0), -vec3(0.0,215.0,255.0), -vec3(0.0,255.0,0.0), -vec3(0.0,255.0,95.0), -vec3(0.0,255.0,135.0), -vec3(0.0,255.0,175.0), -vec3(0.0,255.0,215.0), -vec3(0.0,255.0,255.0), -vec3(95.0,0.0,0.0), -vec3(95.0,0.0,95.0), -vec3(95.0,0.0,135.0), -vec3(95.0,0.0,175.0), -vec3(95.0,0.0,215.0), -vec3(95.0,0.0,255.0), -vec3(95.0,95.0,0.0), -vec3(95.0,95.0,95.0), -vec3(95.0,95.0,135.0), -vec3(95.0,95.0,175.0), -vec3(95.0,95.0,215.0), -vec3(95.0,95.0,255.0), -vec3(95.0,135.0,0.0), -vec3(95.0,135.0,95.0), -vec3(95.0,135.0,135.0), -vec3(95.0,135.0,175.0), -vec3(95.0,135.0,215.0), -vec3(95.0,135.0,255.0), -vec3(95.0,175.0,0.0), -vec3(95.0,175.0,95.0), -vec3(95.0,175.0,135.0), -vec3(95.0,175.0,175.0), -vec3(95.0,175.0,215.0), -vec3(95.0,175.0,255.0), -vec3(95.0,215.0,0.0), -vec3(95.0,215.0,95.0), -vec3(95.0,215.0,135.0), -vec3(95.0,215.0,175.0), -vec3(95.0,215.0,215.0), -vec3(95.0,215.0,255.0), -vec3(95.0,255.0,0.0), -vec3(95.0,255.0,95.0), -vec3(95.0,255.0,135.0), -vec3(95.0,255.0,175.0), -vec3(95.0,255.0,215.0), -vec3(95.0,255.0,255.0), -vec3(135.0,0.0,0.0), -vec3(135.0,0.0,95.0), -vec3(135.0,0.0,135.0), -vec3(135.0,0.0,175.0), -vec3(135.0,0.0,215.0), -vec3(135.0,0.0,255.0), -vec3(135.0,95.0,0.0), -vec3(135.0,95.0,95.0), -vec3(135.0,95.0,135.0), -vec3(135.0,95.0,175.0), -vec3(135.0,95.0,215.0), -vec3(135.0,95.0,255.0), -vec3(135.0,135.0,0.0), -vec3(135.0,135.0,95.0), -vec3(135.0,135.0,135.0), -vec3(135.0,135.0,175.0), -vec3(135.0,135.0,215.0), -vec3(135.0,135.0,255.0), -vec3(135.0,175.0,0.0), -vec3(135.0,175.0,95.0), -vec3(135.0,175.0,135.0), -vec3(135.0,175.0,175.0), -vec3(135.0,175.0,215.0), -vec3(135.0,175.0,255.0), -vec3(135.0,215.0,0.0), -vec3(135.0,215.0,95.0), -vec3(135.0,215.0,135.0), -vec3(135.0,215.0,175.0), -vec3(135.0,215.0,215.0), -vec3(135.0,215.0,255.0), -vec3(135.0,255.0,0.0), -vec3(135.0,255.0,95.0), -vec3(135.0,255.0,135.0), -vec3(135.0,255.0,175.0), -vec3(135.0,255.0,215.0), -vec3(135.0,255.0,255.0), -vec3(175.0,0.0,0.0), -vec3(175.0,0.0,95.0), -vec3(175.0,0.0,135.0), -vec3(175.0,0.0,175.0), -vec3(175.0,0.0,215.0), -vec3(175.0,0.0,255.0), -vec3(175.0,95.0,0.0), -vec3(175.0,95.0,95.0), -vec3(175.0,95.0,135.0), -vec3(175.0,95.0,175.0), -vec3(175.0,95.0,215.0), -vec3(175.0,95.0,255.0), -vec3(175.0,135.0,0.0), -vec3(175.0,135.0,95.0), -vec3(175.0,135.0,135.0), -vec3(175.0,135.0,175.0), -vec3(175.0,135.0,215.0), -vec3(175.0,135.0,255.0), -vec3(175.0,175.0,0.0), -vec3(175.0,175.0,95.0), -vec3(175.0,175.0,135.0), -vec3(175.0,175.0,175.0), -vec3(175.0,175.0,215.0), -vec3(175.0,175.0,255.0), -vec3(175.0,215.0,0.0), -vec3(175.0,215.0,95.0), -vec3(175.0,215.0,135.0), -vec3(175.0,215.0,175.0), -vec3(175.0,215.0,215.0), -vec3(175.0,215.0,255.0), -vec3(175.0,255.0,0.0), -vec3(175.0,255.0,95.0), -vec3(175.0,255.0,135.0), -vec3(175.0,255.0,175.0), -vec3(175.0,255.0,215.0), -vec3(175.0,255.0,255.0), -vec3(215.0,0.0,0.0), -vec3(215.0,0.0,95.0), -vec3(215.0,0.0,135.0), -vec3(215.0,0.0,175.0), -vec3(215.0,0.0,215.0), -vec3(215.0,0.0,255.0), -vec3(215.0,95.0,0.0), -vec3(215.0,95.0,95.0), -vec3(215.0,95.0,135.0), -vec3(215.0,95.0,175.0), -vec3(215.0,95.0,215.0), -vec3(215.0,95.0,255.0), -vec3(215.0,135.0,0.0), -vec3(215.0,135.0,95.0), -vec3(215.0,135.0,135.0), -vec3(215.0,135.0,175.0), -vec3(215.0,135.0,215.0), -vec3(215.0,135.0,255.0), -vec3(215.0,175.0,0.0), -vec3(215.0,175.0,95.0), -vec3(215.0,175.0,135.0), -vec3(215.0,175.0,175.0), -vec3(215.0,175.0,215.0), -vec3(215.0,175.0,255.0), -vec3(215.0,215.0,0.0), -vec3(215.0,215.0,95.0), -vec3(215.0,215.0,135.0), -vec3(215.0,215.0,175.0), -vec3(215.0,215.0,215.0), -vec3(215.0,215.0,255.0), -vec3(215.0,255.0,0.0), -vec3(215.0,255.0,95.0), -vec3(215.0,255.0,135.0), -vec3(215.0,255.0,175.0), -vec3(215.0,255.0,215.0), -vec3(215.0,255.0,255.0), -vec3(255.0,0.0,0.0), -vec3(255.0,0.0,95.0), -vec3(255.0,0.0,135.0), -vec3(255.0,0.0,175.0), -vec3(255.0,0.0,215.0), -vec3(255.0,0.0,255.0), -vec3(255.0,95.0,0.0), -vec3(255.0,95.0,95.0), -vec3(255.0,95.0,135.0), -vec3(255.0,95.0,175.0), -vec3(255.0,95.0,215.0), -vec3(255.0,95.0,255.0), -vec3(255.0,135.0,0.0), -vec3(255.0,135.0,95.0), -vec3(255.0,135.0,135.0), -vec3(255.0,135.0,175.0), -vec3(255.0,135.0,215.0), -vec3(255.0,135.0,255.0), -vec3(255.0,175.0,0.0), -vec3(255.0,175.0,95.0), -vec3(255.0,175.0,135.0), -vec3(255.0,175.0,175.0), -vec3(255.0,175.0,215.0), -vec3(255.0,175.0,255.0), -vec3(255.0,215.0,0.0), -vec3(255.0,215.0,95.0), -vec3(255.0,215.0,135.0), -vec3(255.0,215.0,175.0), -vec3(255.0,215.0,215.0), -vec3(255.0,215.0,255.0), -vec3(255.0,255.0,0.0), -vec3(255.0,255.0,95.0), -vec3(255.0,255.0,135.0), -vec3(255.0,255.0,175.0), -vec3(255.0,255.0,215.0), -vec3(255.0,255.0,255.0), -vec3(8.0,8.0,8.0), -vec3(18.0,18.0,18.0), -vec3(28.0,28.0,28.0), -vec3(38.0,38.0,38.0), -vec3(48.0,48.0,48.0), -vec3(58.0,58.0,58.0), -vec3(68.0,68.0,68.0), -vec3(78.0,78.0,78.0), -vec3(88.0,88.0,88.0), -vec3(98.0,98.0,98.0), -vec3(108.0,108.0,108.0), -vec3(118.0,118.0,118.0), -vec3(128.0,128.0,128.0), -vec3(138.0,138.0,138.0), -vec3(148.0,148.0,148.0), -vec3(158.0,158.0,158.0), -vec3(168.0,168.0,168.0), -vec3(178.0,178.0,178.0), -vec3(188.0,188.0,188.0), -vec3(198.0,198.0,198.0), -vec3(208.0,208.0,208.0), -vec3(218.0,218.0,218.0), -vec3(228.0,228.0,228.0), -vec3(238.0,238.0,238.0) + vec3(0.0,0.0,0.0), + vec3(0.5,0.0,0.0), + vec3(0.0,0.5,0.0), + vec3(0.5,0.5,0.0), + vec3(0.0,0.0,0.5), + vec3(0.5,0.0,0.5), + vec3(0.0,0.5,0.5), + vec3(0.75,0.75,0.75), + vec3(0.5,0.5,0.5), + vec3(0.99609375,0.0,0.0), + vec3(0.0,0.99609375,0.0), + vec3(0.99609375,0.99609375,0.0), + vec3(0.0,0.0,0.99609375), + vec3(0.99609375,0.0,0.99609375), + vec3(0.0,0.99609375,0.99609375), + vec3(0.99609375,0.99609375,0.99609375), + vec3(0.0,0.0,0.0), + vec3(0.0,0.0,0.37109375), + vec3(0.0,0.0,0.52734375), + vec3(0.0,0.0,0.68359375), + vec3(0.0,0.0,0.83984375), + vec3(0.0,0.0,0.99609375), + vec3(0.0,0.37109375,0.0), + vec3(0.0,0.37109375,0.37109375), + vec3(0.0,0.37109375,0.52734375), + vec3(0.0,0.37109375,0.68359375), + vec3(0.0,0.37109375,0.83984375), + vec3(0.0,0.37109375,0.99609375), + vec3(0.0,0.52734375,0.0), + vec3(0.0,0.52734375,0.37109375), + vec3(0.0,0.52734375,0.52734375), + vec3(0.0,0.52734375,0.68359375), + vec3(0.0,0.52734375,0.83984375), + vec3(0.0,0.52734375,0.99609375), + vec3(0.0,0.68359375,0.0), + vec3(0.0,0.68359375,0.37109375), + vec3(0.0,0.68359375,0.52734375), + vec3(0.0,0.68359375,0.68359375), + vec3(0.0,0.68359375,0.83984375), + vec3(0.0,0.68359375,0.99609375), + vec3(0.0,0.83984375,0.0), + vec3(0.0,0.83984375,0.37109375), + vec3(0.0,0.83984375,0.52734375), + vec3(0.0,0.83984375,0.68359375), + vec3(0.0,0.83984375,0.83984375), + vec3(0.0,0.83984375,0.99609375), + vec3(0.0,0.99609375,0.0), + vec3(0.0,0.99609375,0.37109375), + vec3(0.0,0.99609375,0.52734375), + vec3(0.0,0.99609375,0.68359375), + vec3(0.0,0.99609375,0.83984375), + vec3(0.0,0.99609375,0.99609375), + vec3(0.37109375,0.0,0.0), + vec3(0.37109375,0.0,0.37109375), + vec3(0.37109375,0.0,0.52734375), + vec3(0.37109375,0.0,0.68359375), + vec3(0.37109375,0.0,0.83984375), + vec3(0.37109375,0.0,0.99609375), + vec3(0.37109375,0.37109375,0.0), + vec3(0.37109375,0.37109375,0.37109375), + vec3(0.37109375,0.37109375,0.52734375), + vec3(0.37109375,0.37109375,0.68359375), + vec3(0.37109375,0.37109375,0.83984375), + vec3(0.37109375,0.37109375,0.99609375), + vec3(0.37109375,0.52734375,0.0), + vec3(0.37109375,0.52734375,0.37109375), + vec3(0.37109375,0.52734375,0.52734375), + vec3(0.37109375,0.52734375,0.68359375), + vec3(0.37109375,0.52734375,0.83984375), + vec3(0.37109375,0.52734375,0.99609375), + vec3(0.37109375,0.68359375,0.0), + vec3(0.37109375,0.68359375,0.37109375), + vec3(0.37109375,0.68359375,0.52734375), + vec3(0.37109375,0.68359375,0.68359375), + vec3(0.37109375,0.68359375,0.83984375), + vec3(0.37109375,0.68359375,0.99609375), + vec3(0.37109375,0.83984375,0.0), + vec3(0.37109375,0.83984375,0.37109375), + vec3(0.37109375,0.83984375,0.52734375), + vec3(0.37109375,0.83984375,0.68359375), + vec3(0.37109375,0.83984375,0.83984375), + vec3(0.37109375,0.83984375,0.99609375), + vec3(0.37109375,0.99609375,0.0), + vec3(0.37109375,0.99609375,0.37109375), + vec3(0.37109375,0.99609375,0.52734375), + vec3(0.37109375,0.99609375,0.68359375), + vec3(0.37109375,0.99609375,0.83984375), + vec3(0.37109375,0.99609375,0.99609375), + vec3(0.52734375,0.0,0.0), + vec3(0.52734375,0.0,0.37109375), + vec3(0.52734375,0.0,0.52734375), + vec3(0.52734375,0.0,0.68359375), + vec3(0.52734375,0.0,0.83984375), + vec3(0.52734375,0.0,0.99609375), + vec3(0.52734375,0.37109375,0.0), + vec3(0.52734375,0.37109375,0.37109375), + vec3(0.52734375,0.37109375,0.52734375), + vec3(0.52734375,0.37109375,0.68359375), + vec3(0.52734375,0.37109375,0.83984375), + vec3(0.52734375,0.37109375,0.99609375), + vec3(0.52734375,0.52734375,0.0), + vec3(0.52734375,0.52734375,0.37109375), + vec3(0.52734375,0.52734375,0.52734375), + vec3(0.52734375,0.52734375,0.68359375), + vec3(0.52734375,0.52734375,0.83984375), + vec3(0.52734375,0.52734375,0.99609375), + vec3(0.52734375,0.68359375,0.0), + vec3(0.52734375,0.68359375,0.37109375), + vec3(0.52734375,0.68359375,0.52734375), + vec3(0.52734375,0.68359375,0.68359375), + vec3(0.52734375,0.68359375,0.83984375), + vec3(0.52734375,0.68359375,0.99609375), + vec3(0.52734375,0.83984375,0.0), + vec3(0.52734375,0.83984375,0.37109375), + vec3(0.52734375,0.83984375,0.52734375), + vec3(0.52734375,0.83984375,0.68359375), + vec3(0.52734375,0.83984375,0.83984375), + vec3(0.52734375,0.83984375,0.99609375), + vec3(0.52734375,0.99609375,0.0), + vec3(0.52734375,0.99609375,0.37109375), + vec3(0.52734375,0.99609375,0.52734375), + vec3(0.52734375,0.99609375,0.68359375), + vec3(0.52734375,0.99609375,0.83984375), + vec3(0.52734375,0.99609375,0.99609375), + vec3(0.68359375,0.0,0.0), + vec3(0.68359375,0.0,0.37109375), + vec3(0.68359375,0.0,0.52734375), + vec3(0.68359375,0.0,0.68359375), + vec3(0.68359375,0.0,0.83984375), + vec3(0.68359375,0.0,0.99609375), + vec3(0.68359375,0.37109375,0.0), + vec3(0.68359375,0.37109375,0.37109375), + vec3(0.68359375,0.37109375,0.52734375), + vec3(0.68359375,0.37109375,0.68359375), + vec3(0.68359375,0.37109375,0.83984375), + vec3(0.68359375,0.37109375,0.99609375), + vec3(0.68359375,0.52734375,0.0), + vec3(0.68359375,0.52734375,0.37109375), + vec3(0.68359375,0.52734375,0.52734375), + vec3(0.68359375,0.52734375,0.68359375), + vec3(0.68359375,0.52734375,0.83984375), + vec3(0.68359375,0.52734375,0.99609375), + vec3(0.68359375,0.68359375,0.0), + vec3(0.68359375,0.68359375,0.37109375), + vec3(0.68359375,0.68359375,0.52734375), + vec3(0.68359375,0.68359375,0.68359375), + vec3(0.68359375,0.68359375,0.83984375), + vec3(0.68359375,0.68359375,0.99609375), + vec3(0.68359375,0.83984375,0.0), + vec3(0.68359375,0.83984375,0.37109375), + vec3(0.68359375,0.83984375,0.52734375), + vec3(0.68359375,0.83984375,0.68359375), + vec3(0.68359375,0.83984375,0.83984375), + vec3(0.68359375,0.83984375,0.99609375), + vec3(0.68359375,0.99609375,0.0), + vec3(0.68359375,0.99609375,0.37109375), + vec3(0.68359375,0.99609375,0.52734375), + vec3(0.68359375,0.99609375,0.68359375), + vec3(0.68359375,0.99609375,0.83984375), + vec3(0.68359375,0.99609375,0.99609375), + vec3(0.83984375,0.0,0.0), + vec3(0.83984375,0.0,0.37109375), + vec3(0.83984375,0.0,0.52734375), + vec3(0.83984375,0.0,0.68359375), + vec3(0.83984375,0.0,0.83984375), + vec3(0.83984375,0.0,0.99609375), + vec3(0.83984375,0.37109375,0.0), + vec3(0.83984375,0.37109375,0.37109375), + vec3(0.83984375,0.37109375,0.52734375), + vec3(0.83984375,0.37109375,0.68359375), + vec3(0.83984375,0.37109375,0.83984375), + vec3(0.83984375,0.37109375,0.99609375), + vec3(0.83984375,0.52734375,0.0), + vec3(0.83984375,0.52734375,0.37109375), + vec3(0.83984375,0.52734375,0.52734375), + vec3(0.83984375,0.52734375,0.68359375), + vec3(0.83984375,0.52734375,0.83984375), + vec3(0.83984375,0.52734375,0.99609375), + vec3(0.83984375,0.68359375,0.0), + vec3(0.83984375,0.68359375,0.37109375), + vec3(0.83984375,0.68359375,0.52734375), + vec3(0.83984375,0.68359375,0.68359375), + vec3(0.83984375,0.68359375,0.83984375), + vec3(0.83984375,0.68359375,0.99609375), + vec3(0.83984375,0.83984375,0.0), + vec3(0.83984375,0.83984375,0.37109375), + vec3(0.83984375,0.83984375,0.52734375), + vec3(0.83984375,0.83984375,0.68359375), + vec3(0.83984375,0.83984375,0.83984375), + vec3(0.83984375,0.83984375,0.99609375), + vec3(0.83984375,0.99609375,0.0), + vec3(0.83984375,0.99609375,0.37109375), + vec3(0.83984375,0.99609375,0.52734375), + vec3(0.83984375,0.99609375,0.68359375), + vec3(0.83984375,0.99609375,0.83984375), + vec3(0.83984375,0.99609375,0.99609375), + vec3(0.99609375,0.0,0.0), + vec3(0.99609375,0.0,0.37109375), + vec3(0.99609375,0.0,0.52734375), + vec3(0.99609375,0.0,0.68359375), + vec3(0.99609375,0.0,0.83984375), + vec3(0.99609375,0.0,0.99609375), + vec3(0.99609375,0.37109375,0.0), + vec3(0.99609375,0.37109375,0.37109375), + vec3(0.99609375,0.37109375,0.52734375), + vec3(0.99609375,0.37109375,0.68359375), + vec3(0.99609375,0.37109375,0.83984375), + vec3(0.99609375,0.37109375,0.99609375), + vec3(0.99609375,0.52734375,0.0), + vec3(0.99609375,0.52734375,0.37109375), + vec3(0.99609375,0.52734375,0.52734375), + vec3(0.99609375,0.52734375,0.68359375), + vec3(0.99609375,0.52734375,0.83984375), + vec3(0.99609375,0.52734375,0.99609375), + vec3(0.99609375,0.68359375,0.0), + vec3(0.99609375,0.68359375,0.37109375), + vec3(0.99609375,0.68359375,0.52734375), + vec3(0.99609375,0.68359375,0.68359375), + vec3(0.99609375,0.68359375,0.83984375), + vec3(0.99609375,0.68359375,0.99609375), + vec3(0.99609375,0.83984375,0.0), + vec3(0.99609375,0.83984375,0.37109375), + vec3(0.99609375,0.83984375,0.52734375), + vec3(0.99609375,0.83984375,0.68359375), + vec3(0.99609375,0.83984375,0.83984375), + vec3(0.99609375,0.83984375,0.99609375), + vec3(0.99609375,0.99609375,0.0), + vec3(0.99609375,0.99609375,0.37109375), + vec3(0.99609375,0.99609375,0.52734375), + vec3(0.99609375,0.99609375,0.68359375), + vec3(0.99609375,0.99609375,0.83984375), + vec3(0.99609375,0.99609375,0.99609375), + vec3(0.03125,0.03125,0.03125), + vec3(0.0703125,0.0703125,0.0703125), + vec3(0.109375,0.109375,0.109375), + vec3(0.1484375,0.1484375,0.1484375), + vec3(0.1875,0.1875,0.1875), + vec3(0.2265625,0.2265625,0.2265625), + vec3(0.265625,0.265625,0.265625), + vec3(0.3046875,0.3046875,0.3046875), + vec3(0.34375,0.34375,0.34375), + vec3(0.3828125,0.3828125,0.3828125), + vec3(0.421875,0.421875,0.421875), + vec3(0.4609375,0.4609375,0.4609375), + vec3(0.5,0.5,0.5), + vec3(0.5390625,0.5390625,0.5390625), + vec3(0.578125,0.578125,0.578125), + vec3(0.6171875,0.6171875,0.6171875), + vec3(0.65625,0.65625,0.65625), + vec3(0.6953125,0.6953125,0.6953125), + vec3(0.734375,0.734375,0.734375), + vec3(0.7734375,0.7734375,0.7734375), + vec3(0.8125,0.8125,0.8125), + vec3(0.8515625,0.8515625,0.8515625), + vec3(0.890625,0.890625,0.890625), + vec3(0.9296875,0.9296875,0.9296875) ); int get_iterations() { double real = ((gl_FragCoord.x / 1000.0f - 1.2f) * zoom + center_x) * 1.5f; - double imag = ((gl_FragCoord.y / 800.0f - 0.7f) * zoom + center_y) * 1.5f; + double imag = ((gl_FragCoord.y / 800.0f - 0.9f) * zoom + center_y) * 1.5f; int iterations = 0; @@ -306,7 +305,7 @@ vec4 return_color() } int colorIndex = int((float(iter)/float(MAX_ITERATIONS))*256); vec3 color = colors[colorIndex]; - return vec4(color.x/256, color.y/256, color.z/256, 1.0); + return vec4(color.x, color.y, color.z, 1.0); }