9220c246c2da — Leonard Ritter a month ago
* initial work on subjective filtering
4 files changed, 53 insertions(+), 33 deletions(-)

M lib/tukan/VertexPainter.sc
M lib/tukan/sdf.sc
M testing/test_mt.sc
M testing/test_subjective.sc
M lib/tukan/VertexPainter.sc +1 -1
@@ 55,7 55,7 @@ struct VertexPainter
                 active_lightdir = (vec3 0 0 1)
                 active_color = (vec4 1)
 
-    let MaxVertexCount = 16384
+    let MaxVertexCount = 1000000
     let SwapBufferCount = 1
     let PrimArray = (Array vec4)
 

          
M lib/tukan/sdf.sc +4 -0
@@ 294,6 294,9 @@ inline srange (a b r)
         0.0
         r
 
+inline sdDomainRep (p c)
+    p := (mod (p + 0.5 * c) c) - 0.5 * c
+
 fn sdSmoothOr (a b r)
     #float <- (float float float)
     let e = (srange a b r)

          
@@ 493,4 496,5 @@ do
     let sdOr sdAnd sdSub sdBezier
     let sdSmoothOr sdSmoothAnd
     let sdMaterial sdmDist
+    let sdDomainRep
     locals;

          
M testing/test_mt.sc +31 -28
@@ 12,29 12,32 @@ 
 
     one tet is handled per thread
 
-import ..tukan.voxel
-let voxel = tukan.voxel
 
 using import glm
 using import glsl
 using import Array
 using import Box
 using import struct
-using import ..tukan.gl
-using import ..tukan.bitmap
-using import ..tukan.packing
-using import ..tukan.random
-using import ..tukan.color
-using import ..tukan.perfect_hash
-using import ..tukan.raytrace
-using import ..tukan.sdf
-using import ..tukan.sdl
-using import ..tukan.rotation
-using import ..tukan.brdf
-using import ..tukan.normal
-using import ..tukan.projection
-using import ..tukan.derivative
-using import ..tukan.isosurface
+import ..lib.tukan.use
+
+import tukan.voxel
+let voxel = tukan.voxel
+
+using import tukan.gl
+using import tukan.bitmap
+using import tukan.packing
+using import tukan.random
+using import tukan.color
+using import tukan.perfect_hash
+using import tukan.raytrace
+using import tukan.sdf
+using import tukan.sdl
+using import tukan.rotation
+using import tukan.brdf
+using import tukan.normal
+using import tukan.projection
+using import tukan.derivative
+using import tukan.isosurface
 using import .testfragment
 
 # reserve 10MB for each voxel buffer

          
@@ 676,11 679,11 @@ inline main ()
 
     global cell_buffers =
         arrayof GL.uint
-            GL.CreateBuffer;
-            GL.CreateBuffer;
-            GL.CreateBuffer;
-            GL.CreateBuffer;
-            GL.CreateBuffer;
+            GL.Buffer;
+            GL.Buffer;
+            GL.Buffer;
+            GL.Buffer;
+            GL.Buffer;
     let cell_buffer_sz = ((sizeof u32) * (1 + MAX_VOXELS))
     for i in (range (NUM_BUFFERS as u32))
         let buf = (cell_buffers @ i)

          
@@ 697,7 700,7 @@ inline main ()
     #global tx_position_normal = (GL.CreateTexture GL.TEXTURE_BUFFER)
     #GL.TextureBuffer tx_position_normal GL.RGBA32UI position_normal
 
-    global fb-scene-color = (GL.CreateTexture GL.TEXTURE_2D)
+    global fb-scene-color = (GL.Texture GL.TEXTURE_2D)
     'setup fb-scene-color
         size = (ivec2 2048 2048)
         format = GL.RGBA32F

          
@@ 705,24 708,24 @@ inline main ()
         let h = 2048
         GL.ClearTexImage fb-scene-color 0 GL.RGBA GL.FLOAT null
 
-    global rb-scene-depth = (GL.CreateRenderbuffer)
+    global rb-scene-depth = (GL.Renderbuffer)
     setup-renderbuffer rb-scene-depth 2048 2048
         format = GL.DEPTH_COMPONENT
-    global fb-scene = (GL.CreateFramebuffer)
+    global fb-scene = (GL.Framebuffer)
     setup-framebuffer fb-scene
         color = fb-scene-color
         rb-depth = rb-scene-depth
 
-    global vao-empty = (GL.CreateVertexArray)
+    global vao-empty = (GL.VertexArray)
 
-    global pg-rasterize = (GL.CreateProgram)
+    global pg-rasterize = (GL.Program)
     call
         attach-shaders (deref pg-rasterize)
             vertex = rasterize-vert
             fragment = rasterize-frag
             #debug = true
 
-    global pg-supershader = (GL.CreateProgram)
+    global pg-supershader = (GL.Program)
     call
         attach-shaders (deref pg-supershader)
             compute = supershader

          
M testing/test_subjective.sc +17 -4
@@ 74,10 74,13 @@ fn unpack_normal_snorm (encN)
             ? (z >= 0.0) encN.xy (oct_wrap encN.xy)
             z
 
+N := 32
+
 fn persp1 (p)
     static-if true
-        r := (p.z * 0.5 + 0.5)
-        r := (exp2 (8.0 * r))
+        r := (p.z * 0.5 + 0.5) * N
+        r := (1 + 2 * (sqrt pi) / (N * 0.5)) ** r
+        #r := (1 + 2 * (sqrt pi) / 16.0) ** r
         #r := 1.0 / r
         #r := (r / (1.0 - (abs r))) #+ 1.0
         #r := (-(log2 (1.0 - r)))

          
@@ 119,7 122,7 @@ fn draw (size pg-test frame)
             GL.COLOR_BUFFER_BIT
             GL.DEPTH_BUFFER_BIT
             GL.STENCIL_BUFFER_BIT
-    GL.LineWidth 2.0
+    GL.LineWidth 8.0
 
     'setup-depth painter
     'clear painter

          
@@ 131,7 134,6 @@ fn draw (size pg-test frame)
     light 0.25 -0.5 1
     perspective size
     transform cpu_shglobals.view
-    N := 64
     d := (vec3 1) / N
 
     t := cpu_shglobals.time * 0.1

          
@@ 169,6 171,16 @@ fn draw (size pg-test frame)
             hue2rgb
                 (max (unpack (abs pc))) #+ t
         #color c
+        local overts =
+            arrayof vec3
+                vec3 p0.x p0.y p0.z
+                vec3 p0.x p0.y p1.z
+                vec3 p0.x p1.y p0.z
+                vec3 p0.x p1.y p1.z
+                vec3 p1.x p0.y p0.z
+                vec3 p1.x p0.y p1.z
+                vec3 p1.x p1.y p0.z
+                vec3 p1.x p1.y p1.z
         local verts =
             arrayof vec3
                 tf (vec3 p0.x p0.y p0.z)

          
@@ 188,6 200,7 @@ fn draw (size pg-test frame)
                 local p : (array vec3 4)
                 for k in (range 4)
                     q := verts @ (is @ k)
+                    #qv := overts @ (is @ k)
                     p @ k = q
                     d @ k = (map q)
                 let c i = (tetfaces d)