Another thread to discuss about the 4th parameter in the (build-pixels)
function.
I do realize the point for a ffgl chaining but I can't figure out the
feedback goal.
Taking the supplied fluxus example : pixels-feedback.scm
(clear)
(scale (vector 20 15 1))
(define p (build-pixels 512 512 #t 2))
(define frame 0)
(every-frame
(let ([tex (pixels->texture p frame)]
[ptex (pixels->texture p (bitwise-xor frame 1))])
(with-primitive p
(pixels-render-to tex)
(pixels-display tex))
(with-pixels-renderer p
(clear-colour 1)
(with-state
(texture ptex)
(rotate (vector (* 60 (time)) 45 0))
(scale 6)
(draw-cube)))
(set! frame (bitwise-xor frame 1))))
I don't see the goal of the alternating frame variable value
and why don't shorten this in this, using only one texture:
(clear)
(scale (vector 20 15 1))
(define p (build-pixels 512 512 #t 1))
(define frame 0)
(every-frame
(let ([tex (pixels->texture p frame)])
(with-primitive p
(pixels-render-to tex)
(pixels-display tex))
(with-pixels-renderer p
(clear-colour 1)
(with-state
(texture tex)
(rotate (vector (* 60 (time)) 45 0))
(scale 6)
(draw-cube)))))
The other Gabor example "pixels.scm" seems to me quite confusing too
with this balanced frame variable.
That was my first questioning
I read in the mailing list, the main goal was to avoid multiple pixels
primitives.
My goal is to build a pixels renderer with a pixels or texture mask what
I did with to pixels renderer and a multitextured plane playing with
blending parameters.
You'll find it in attachement in "multitexture-pixels.scm".
But can I use the different pixels primitives textures to do sort of
multitexturing, or I'm misunderstanding this.
Thanks for any explanations.
On an other note, there is no documentation in the helpmap on the
(pixels-render-to ) and (pixels-display ) functions, and the 4th
(build-pixels) parameter.
I'll be happy to translate but I prefer to let you explain these
things. ;-)
best,
Ted
(clear)
(clear-colour 0.1)
(reset-camera)
(define s 5)
(define mask (with-state (scale s) (translate (vector 1 0 0)) (build-pixels 500 500 #t)))
(define renderer
(with-state
(scale s)
(translate (vector -1 0 0))
(build-pixels 500 500 #t)
)
)
(define mapping
(with-state
(translate (vector 0 0 .1))
(scale s)
(multitexture 0 (pixels->texture renderer))
(texture-params 0
(list
'min 'nearest
'mag 'nearest
'wrap-t 'clamp
'wrap-s 'clamp
'tex-env 'replace
)
)
(multitexture 1 (pixels->texture mask))
(texture-params 1
(list
'min 'nearest
'mag 'nearest
'wrap-s 'clamp
'wrap-t 'clamp
'tex-env 'blend
)
)
(build-plane)
)
)
#(with-primitive p
(show (pdata-exists? "t"))
(pdata-map!
(lambda (t)
(vmul t 1)
)
"t"
)
)
#(with-pixels-renderer mask
(build-cube)
)
(define (map-mask)
(with-pixels-renderer mask
(with-state
(clear-colour #(1 1 1))
(colour (vector 0 0 0))
(rotate (vmul (vector 0 (time) (time)) 20))
(scale 5)
(draw-cube)
)
)
(with-pixels-renderer renderer
(with-state
(clear-colour #(0.2 0.2 0.2))
(rotate (vmul (vector (time) (time) 0) 20))
(scale 5)
(draw-cube)
)
)
)
(every-frame (map-mask))
(clear)
; pixels primitive with 2 textures and active renderer
(define p (build-pixels 1024 1024 #t 2))
(with-primitive p ; hide it
(scale 0))
; extra camera
(define cam1 (with-pixels-renderer p
(build-camera)))
(with-pixels-renderer p
(current-camera cam1)
(viewport 0.5 0 0.5 1) ; use the right handside for the extra camera
(set-camera (mmul (mtranslate (vector 0 0 -2))
(mrotate (vector 0 -145 0))))
(current-camera 0) ; left handside for the default camera
(viewport 0 0 0.5 1))
; fullscreen quad for displaying the scene
(define fs-quad (with-state
(hint-unlit)
(scale #(20 15 1))
(build-plane)))
; set its texture coordinates to the default camera viewport
; in the pixel primitive
(with-primitive fs-quad
(pdata-set! "t" 0 #(0 1 0))
(pdata-set! "t" 1 #(.5 1 0))
(pdata-set! "t" 2 #(.5 0 0))
(pdata-set! "t" 3 #(0 0 0)))
; scene object
(define c (with-pixels-renderer p
(build-cube)))
(with-pixels-renderer p
(with-primitive c
(hint-vertcols)
(pdata-map! (lambda (c) (rndvec)) "c")))
; camera display
(define tv (with-pixels-renderer p
(hint-unlit)
(build-plane)))
(with-pixels-renderer p
(with-primitive tv
(hint-wire)
(hide 1)
(camera-hide 0) ; show only in the default camera
(rotate #(0 35 0))
(translate #(0 0 -5))
(scale #(6 8 1))
; set texture coords to the extra camera viewport
(pdata-set! "t" 0 #(.5 1 0))
(pdata-set! "t" 1 #(1 1 0))
(pdata-set! "t" 2 #(1 0 0))
(pdata-set! "t" 3 #(.5 0 0))))
; frame count to ping-pong render target
(define frame-count 0)
(every-frame
(let ([tex (pixels->texture p (remainder frame-count 2))]
[ptex (pixels->texture p (remainder (+ frame-count 1) 2))])
; set render targets and display texture for the pixel primitive
(with-primitive p
(pixels-render-to tex)
(pixels-display tex))
; fullscreen quad texture
(with-primitive fs-quad
(texture tex))
(with-pixels-renderer p
; rotate the cube
(with-primitive c
(identity)
(rotate (vector (* 40 (time)) 35 0)))
; camera display texture
(with-primitive tv
(texture ptex)))
(set! frame-count (+ frame-count 1))))