[Fluxus] lighting the inside of a sphere

Dave Griffiths dave at pawfal.org
Mon Nov 12 11:14:17 PST 2007


On Mon, 2007-11-12 at 14:00 +0100, gabor papp wrote:
> > two identical spheres except one with normals pointing inside and one
> > outside
> thanks artem.
> 
> > the camera light is 0, so you can do something like: (light-diffuse 0
> >  (vector 0 0 0))
> works very well. thank you. i also tried (destroy 0), but it didn't seem
> to do anything.
> 
> > I've done this in the past by negative scaling a sphere inside a 
> > normal one and grouping them under a locator - should work for most 
> > things.
> i could not make this work. am i doing something wrong?
> 
> (clear)
> 
> (define p (build-locator))
> 
> (parent p)
> (define s (build-sphere 10 10))
> (define si (build-sphere 10 10))
> 
> (with-primitive si
>     (scale (vector -.9 -.9 -.9)))
> 
> i tried (recalc-normals), but it didn't help.

Something which makes this confusing is that there are two factors. One
is the normals - if you only use the default camera light, back facing
polygons will always be black. 

The other thing is that the winding order of the polygons causes them to
be culled if they are facing away, and (backfacecull) is set to 1.

Scaling negatively reverses the winding order, reverses the culling,
effectively making an inside out sphere. The normals don't get scaled
though, so they still point outwards.

Here is an example with lighting turned off, making a sphere where the
outside is red and the inside is green:

(clear)

(hint-unlit)
(scale (vector 2 2 2))
(colour (vector 1 0 0))
(define s (build-sphere 10 10))
(colour (vector 0 1 0))
> 
> (with-primitive si
>     (scale (vector -.9 -.9 -.9))
>     (parent p))
> 
> thanks,
> gabor
> 
(define si (build-sphere 10 10))

(with-primitive si
    (scale (vector -1 -1 -1)))

To get it to light correctly, you need to reverse the normals of the
inside sphere as you are doing - making a new light, and/or setting the
background to non black also helps see what's going on.

Another way to do this is just (backfacecull 0) which will make
everything double sided, but it won't light correctly, as there will
only be one set of normals. 

Add alpha cutout textures and it gets more confusing - but there is
usually a way to wrangle what you want out of it.

> i also realised that (parent) does not work with (with-primitive) is it
> on purpose? i tried something like this:

Its possible that parent only works at creation time - eg. inside
(with-state) but it should be possible to use it to reconfigure the
scenegraph later, not sure why not - I'll look into it and report back.

cheers,

dave




More information about the Fluxus mailing list