[Fluxus] what about procedural textures on fluxus?
Dave Griffiths
dave at pawfal.org
Tue Nov 6 08:49:34 PST 2007
> Dave Griffiths <dave at pawfal.org> writes:
>
>> On Wed, 2007-10-31 at 22:41 -0300, Glauber Alex Dias Prado wrote:
>>> Hey Dave i was thinking here what about some basic procedural textures
>>> with fluxus? perhaps something like noise, bands this sort of thing
>>> extended trough scheme? would be good not to rely on gimp for all sort
>>> of textures isnt? what do you think about? maybe the glsl shader
>>> already
>>> got everything and my point is missing? I would like to know your ideas
>>> about it as you certainly has thinked about this a lot, you can answer
>>> to me on the list if you feel like it.
>>
>> They are not widely advertised, but you can use pixel-primitives for
>> this. You'll need to get cvs to run this script as I tried it in the new
>> style (tm) and had to add pdata-index-map! (and pdata-index-fold) which
>> supply the pdata element index to the first argument of the procedure:
>>
>> (clear)
>>
>> (with-state
>>
>> ;; simple random noise
>> (with-primitive (build-pixels 100 100)
>> (pdata-map!
>> (lambda (colour)
>> (vector (flxrnd) 0 0 1))
>> "c")
>> (pixels-upload))
> Hey Dave great examples here, perhaps they could find its way on the
> documentation, i found it very hard to play with at first, im not
> familiarized yet with pdata-map! for example and your examples while
> they are very good dont gave me so much clues on how to accomplish
> something from "my mind" for example but this might be a weak point on
> my part, i hope while i study scheme more and fluxus these will become
> more natural.
Yes, we're missing a procedural texturing example, I'll add this one.
A bit more on map etc - scheme has a bunch of functions which are a bit
like for or do-while loops in other languages but are much more useful.
The simplest one is probably for-each:
(for-each
(lambda (element)
(display element)(newline))
'(1 2 3 4 5 6))
Which simply means "run this function on each element of the list", so
this example will print out all the list elements (by using a anonymous
function supplied by the lambda).
map is similar, but can take mulitple lists and returns a list, eg:
(map + '(1 2 3 4) '(1 1 1 1))
will return:
(2 3 4 5)
there is also map! - the exclamation mark means it mutates an existing
list, rather than returning a new one, and pdata-map! is a map! for fluxus
pdata arrays. So - if you wanted to animate a particle system by adding
the velocities on to the positions you could do it in a similar way to the
above one liner:
(pdata-map! vadd "p" "velocity")
For pdata we need to specify the names of the arrays rather than lists as
they are stored inside the primitive object in the fluxus render engine.
(side note: if the procedure passed to pdata-map! is free of side effects,
like the one above - it could eventually be processed in parallel)
foldl and filter are other list related forms to have a play with. I'm
quite new to them, Nik tried to get me to use these ages ago, but I'm a
slow learner.
> Btw i translated teh fluxus building blocks section and
> you have made some good scheme there i shall look it deeper and with
> more attention to each function to realise it better, anyway this is
> just a response i delayed it a bit cause i was going to try to
> understand it better in order to answer you but i couldnt go much
> further.Also something related to the example above, does it can be used
> to generate a random noise on a cube for example?
Thanks for that - pixels->texture will return you a texture id you can use
on another primitive, allowing you to use procedural textures in the same
way as one loaded from disk:
http://www.pawfal.org/Software/fluxus/docs/0.13/en/primitives.html#pixels-_texture
cheers,
dave
More information about the Fluxus
mailing list