Dear list, I'm still having a few problems with particles, transparency and depth. The code below represents a field with a cube (for scale) and a random amount of clouds. This is supposed to be joined with my "teach myself Fluxus by building a village" project, to explain the colours and theme. Some of the previous steps are in this album; http://www.facebook.com/album.php?aid=2001396&id=1391163181&l=f8f7ecc07a (I think that should be visible to non-FB-users)
So far I set the clouds, which are particle primitives, to depth-sort which
avoided glitches. When I made a "place clouds" function with random
placements it turned out that there were still glitches when one cloud was
place more or less on top of another. I fixed that with a hint-ignore-depth
inside of the place-clouds function... this made the glitches there go away
but created a new issue of all of the clouds being visible from through the
plane/field and the house/cube. By now I was getting the hang of it so I
placed some depth-sort hints outside of the build-clouds scope again. This
brings us to the current situation. As it is it mostly works in a mostly
correct way and often even looks good; I've seen worse in some games, I
think. However now the clouds don't always disappear when the plane should
obscure them, they are seen through the plane until some point where they
suddenly blink out of sight.
What would be the proper way to address this? Is this some fundamental
limitation to particles or am I doing something wrong? I think I could live
with the current situation but I'd rather see it behave 100% correctly.
Yours,
Kas.
(clear-colour (vector 0 0 .9))
(clear-texture-cache)
(hint-depth-sort)
(clear)
(with-primitive (build-plane)
(scale 30)
(hint-depth-sort)
(colour (vector 0 .9 0)))
(with-primitive (build-cube)
(translate (vector 0 0 .5)))
(define (build-cloud)
( let ((x 0))
(with-state
(hint-depth-sort)
;================
;see attachment for this file
(texture (load-texture "/home/ghost/Fluxus/experiment1/cloud.png"))
(with-primitive
(build-particles (floor (+ 6 (* (rndf) 8))))
(pdata-index-map! (lambda (index c) 1) "c")
(pdata-index-map! (lambda (index s) (+ (* (rndf) .2 )(- (/
(pdata-size) 2 ) (abs (- (/ (pdata-size) 2) index ))) .7) ) "s")
(pdata-index-map! (lambda (index p) (set! x (+ x (* .25 (- (/
(pdata-size) 2 ) (abs (- (/ (pdata-size) 2) index )))))) (vector
(+ x (* (grndf) .3))
(* .4 (rndf) (- (/ (pdata-size) 2 )
(abs (- (/ (pdata-size) 2) index ))))
(* .15 (rndf))
) ) "p")
(translate (vector (- 0 (* .5 x)) 0 0))
))))
(define (place-clouds n)
(cond
((not (zero? n))
(with-state
(hint-ignore-depth)
(identity)
(translate (vector ( * 15 (crndf)) ( * 15 (crndf)) (+ 8 (* 4
(rndf)))))
(build-cloud)
(place-clouds (- n 1))))))
(place-clouds (floor (* 8 (rndf) ) ))
<<attachment: cloud.png>>
