M lib/tukan/bitmap.sc +2 -2
@@ 2,8 2,8 @@
using import glm
let
- CDEFS_PATH = (module-dir .. "/../cdefs")
- INCLUDE_PATH = (module-dir .. "/../include/tukan")
+ CDEFS_PATH = (module-dir .. "/../../cdefs")
+ INCLUDE_PATH = (module-dir .. "/../../include/tukan")
spice select-pixeltype (req_comp comptype)
let comptype = (comptype as type)
M lib/tukan/derivative.sc +9 -9
@@ 26,7 26,7 @@ fn safesign (x)
fn safeinv (x)
? (x == 0.0) 0.0 (/ x)
-# da_vec3 <- vec3
+# da_vec3 <- vec3
fn da_domain (p)
da3_vec3
da3_f32 1.0 0.0 0.0 p.x
@@ 64,18 64,18 @@ case (a : f32, b : da3_f32)
da3_f32 (- b.xyz) (a - b.w)
case (a : da3_vec3, b : vec3)
da3_vec3
- da_sub a.x b.x
- da_sub a.y b.y
- da_sub a.z b.z
+ this-function a.x b.x
+ this-function a.y b.y
+ this-function a.z b.z
case (a : da3_vec3, b : f32)
da3_vec3
- da_sub a.x b
- da_sub a.y b
- da_sub a.z b
+ this-function a.x b
+ this-function a.y b
+ this-function a.z b
case (a : da3_vec2, b : da3_vec2)
da3_vec2
- da_sub a.x b.x
- da_sub a.y b.y
+ this-function a.x b.x
+ this-function a.y b.y
# da3_f32 <- da3_f32
fn da_unm (x)
M testing/test_imgui.sc +3 -2
@@ 1,8 1,9 @@
using import glm
using import struct
using import enum
-using import ..tukan.imgui
-using import ..tukan.GUI
+import ..lib.tukan.use
+using import tukan.imgui
+using import tukan.GUI
using import .testfragment
M testing/test_node.sc +2 -2
@@ 15,12 15,12 @@ let NoType = NoId
unlet Builtin
enum Builtin : u32
- ### Inputs
+ ### Sources
# TypeInt 32 false
Samplerate
- ### Outputs
+ ### Sinks
# TypeVector
Audio
M testing/test_ode.sc +1 -1
@@ 4,7 4,7 @@ using import Capture
using import Array
using import enum
-import ..tukan.use
+import ..lib.tukan.use
using import tukan.VertexPainter
using import tukan.GLMain
using import tukan.gl
M testing/test_spritepainter.sc +16 -14
@@ 1,7 1,8 @@
using import glm
+using import itertools
-import ..tukan.use
+import ..lib.tukan.use
using import tukan.SpritePainter
using import tukan.GLMain
using import tukan.gl
@@ 24,12 25,12 @@ global texture_spritesheet = (GL.Texture
'setup texture_spritesheet
bitmap = spritesheet
let sz = spritesheet.size
-va-map
- inline (rc)
- 'register painter rc sz
- ivec4 0 0 5 8
- ivec4 6 0 10 8
- ivec4 10 0 15 8
+for x y in (dim 10 5)
+ x := x * 5
+ y := 4 * 8 - y * 8
+ 'register painter
+ ivec4 x y (x + 5) (y + 8)
+ sz
@@ 'on GLMain.on-draw
fn draw (time size glmain)
@@ 45,13 46,14 @@ fn draw (time size glmain)
t += (/ 60.0)
from (methodsof painter) let sprite screen
- screen size 8
- sprite 0 (vec2 5 40) (vec4 -0.5 -0.5 0.5 0.5)
- angle = t
- sprite 1 (vec2 11 40) (vec4 -0.5 -0.5 0.5 0.5)
- angle = t
- sprite 2 (vec2 17 40) (vec4 -0.5 -0.5 0.5 0.5)
- angle = t
+ screen size 4
+ for i in (range (10:u32 * 5:u32))
+ y := (cos ((i as f32 + t * 4.0) * 0.5)) * 2.0
+ s := (cos ((i as f32 + t * 4.0) * 0.17))
+ s := s * 0.5 + 0.5
+ sprite i (vec2 (i * 5 + 3) (40 + y)) (vec4 -0.5 -0.5 s s)
+ angle =
+ (sin t) * 0.2
GL.BindTextureUnit 0 texture_spritesheet
'draw painter
M testing/test_tmt6.sc +19 -18
@@ 12,7 12,8 @@
one tet is handled per thread
-import ..tukan.voxel
+import ..lib.tukan.use
+import tukan.voxel
let voxel = tukan.voxel
using import glm
@@ 20,23 21,23 @@ 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.mesh
-using import ..tukan.normal
-using import ..tukan.projection
-using import ..tukan.derivative
-using import ..tukan.isosurface
-using import ..tukan.hash
+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.mesh
+using import tukan.normal
+using import tukan.projection
+using import tukan.derivative
+using import tukan.isosurface
+using import tukan.hash
using import .testfragment
let USE_PACKING =
M testing/test_voxelsdf.sc +54 -52
@@ 3,13 3,14 @@
using import Array
using import glm
using import glsl
-using import ..tukan.gl
-using import ..tukan.sdf
-using import ..tukan.rotation
-using import ..tukan.color
-using import ..tukan.packing
-using import ..tukan.sdl
-using import ..tukan.thread
+import ..lib.tukan.use
+using import tukan.gl
+using import tukan.sdf
+using import tukan.rotation
+using import tukan.color
+using import tukan.packing
+using import tukan.sdl
+using import tukan.thread
using import .testfragment
fn map (p)
@@ 25,52 26,53 @@ fn map (p)
vec4 0.0 1.0 0.0 1.0
render-fragment-shader
- fn ()
- fn per-frame-setup ()
+ inline ()
+ inline per-frame-setup (...)
let FAR_LIMIT = 100.0
let MAX_STEPS = 50
let CONTACT_LIMIT = 0.001
- fn raymarch (mapf ro rd)
- loop (i t) = 0 0.0
- let p = (ro + rd * t)
- let d = (mapf p)
- if ((d > CONTACT_LIMIT) & (t < FAR_LIMIT) & (i < MAX_STEPS))
- repeat (i + 1) (t + d)
- return p (not (t >= FAR_LIMIT))
+ inline raymarch (mapf ro rd)
+ loop (i t = 0 0.0)
+ let p = (ro + rd * t)
+ let d = (mapf p)
+ if ((d > CONTACT_LIMIT) & (t < FAR_LIMIT) & (i < MAX_STEPS))
+ repeat (i + 1) (t + d)
+ return p (not (t >= FAR_LIMIT))
- fn raymarch-softshadow (mapf ro rd opts...)
- let getopt = (gen-get-option opts...)
- let mint = (getopt 'min-t 0.05)
- let maxt = (getopt 'max-t FAR_LIMIT)
- let k = (/ (getopt 'aperture 0.03))
- loop (i t res ph) = 0 mint 1.0 1e+20
- let p = (ro + rd * t)
- let h = (mapf p)
- if ((h > CONTACT_LIMIT) & (t < maxt) & (i < MAX_STEPS))
- let y =
- h * h / (2.0 * ph)
- let d =
- sqrt (h * h - y * y)
- repeat (i + 1) (t + h)
- min res (k * d / (max 0.0 (t - y)))
- h
- ? (h <= CONTACT_LIMIT) 0.0 res
+ #inline raymarch-softshadow (mapf ro rd opts...)
+ let mint = (va-option min-t opts... 0.05)
+ let maxt = (va-option max-t opts... FAR_LIMIT)
+ let k = (/ (va-option aperture opts... 0.03))
+ loop (i t res ph = 0 mint 1.0 1e+20)
+ let p = (ro + rd * t)
+ let h = (mapf p)
+ if ((h > CONTACT_LIMIT) & (t < maxt) & (i < MAX_STEPS))
+ let y =
+ h * h / (2.0 * ph)
+ let d =
+ sqrt (h * h - y * y)
+ repeat (i + 1) (t + h)
+ min res (k * d / (max 0.0 (t - y)))
+ h
+ break
+ ? (h <= CONTACT_LIMIT) 0.0 res
- fn raymarch-ambient-occlusion (mapf ro rd)
+ #inline raymarch-ambient-occlusion (mapf ro rd)
let N = 5
- loop (i occ sca) = 0 0.0 1.0
- if (i < N)
- let hr =
- 0.01 + 0.2 * (f32 i) / (f32 (N - 1))
- let aopos = (rd * hr + ro)
- let dd = (mapf aopos)
- repeat (i + 1)
- occ - (dd - hr) * sca
- sca * 0.95
- clamp
- 1.0 - occ
- \ 0.0 1.0
+ loop (i occ sca = 0 0.0 1.0)
+ if (i < N)
+ let hr =
+ 0.01 + 0.2 * (f32 i) / (f32 (N - 1))
+ let aopos = (rd * hr + ro)
+ let dd = (mapf aopos)
+ repeat (i + 1)
+ occ - (dd - hr) * sca
+ sca * 0.95
+ break
+ clamp
+ 1.0 - occ
+ \ 0.0 1.0
fn shader (uv)
let t =
@@ 106,15 108,15 @@ render-fragment-shader
vec3 0.2 0.5 1.0
let rsundir = (- sundir)
let n = (sdNormal map p)
- let shadowing =
- raymarch-softshadow map p rsundir
+ let shadowing = 1.0
+ #raymarch-softshadow map p rsundir
#aperture =
mix 0.03
0.5
(sin (t * 10.0)) * 0.5 + 0.5
- let ao =
- raymarch-ambient-occlusion map p n
+ let ao = 1.0
+ #raymarch-ambient-occlusion map p n
+
*
max 0.0
@@ 126,13 128,13 @@ render-fragment-shader
(dot n rsundir) * 0.5 + 0.5
else
- unconst (vec3 0)
+ vec3 0
vec4
linear->sRGB
tonemap color
1
- return
+ _
per-frame-setup
shader
debug = true