[fluxus] pixel primitive
Dave Griffiths
dave at pawfal.org
Fri Apr 14 08:35:54 PDT 2006
some additions for procedural texturing
(build-pixels width height) makes a new pixel primitive
(upload-pixels) uploads texture data, you need to call this when you've
finished writing to the pixelprim, and while it's grabbed
(pixels->texture pixelprim) returns a texture you can use exactly like a
normal loaded one
pixel primitives render as rectangular planes, textured with the pixel
data, this is useful, but in most cases I think it would be hidden and
applied to another primitive as a texture with (pixels->texture)
you can get/set the pixel data as colour pdata (called "c") and pdata-ops
should work with it ok (but I don't think many of them support colour yet)
and you should be able to create multiple channels etc with
pdata-add/pdata-copy. alpha works too, just use pdata-set with a vector of
size 4.
fixes:
* textures can now be set for a primitive after it's been created, with grab
todo:
* it uses a float texture type for speed, as it doesn't need conversion,
might cause problems on older cards?
* load image to pixel primitive
* save image from pixel primitive
http://www.pawfal.org/dave/images/proctex.png
; animated procedural texture
(clear)
(define a (build-pixels 50 50))
(define (rnd-tex n)
(pdata-set "c" n (vector (sin (* n 0.1)) (cos (* n 0.01)) (sin (+
(time) n))))
(if (zero? n)
0
(rnd-tex (- n 1))))
(define (render)
(grab a)
(rnd-tex (pdata-size))
(upload-pixels)
(ungrab))
(translate (vector 2 0 0))
(define b (build-sphere 10 10))
(grab b)
(texture (pixels->texture a)) ; apply the texture to the sphere
(ungrab)
(every-frame (render))
More information about the Fluxus
mailing list