illuminate loop bug

Atom
2012-06-23
2013-04-25
  • Atom
    Atom
    2012-06-23

    Hi All,

    I just ran across this and thought I would report this bug in the shader language itself.

    Consider this code.

        // Default to HEMI/Ambient lighting.
        if (type == 3.0) {
            L = vector( 0,0,0 );
            Cl = energy * light_color;
        }
    

    When I pass in a type of 3.0 the light energy gets calculated for ambient lighting.
    I compiled this and it works.

    So let's extend this.

        // Default to HEMI/Ambient lighting.
        if (type == 3.0) {
            L = vector( 0,0,0 );
            Cl = energy * light_color;
        }
        // Point light with shadow.
        if (type == 0.0) {
            illuminate (from) {
                color vis;
                vis =  (1 - shadow("raytrace",Ps,"blur",shadow_blur_size,"samples",shadow_ray_sample));
                Cl = vis * energy * light_color;
            }
        }
    

    When I pass a_ type_ of 3.0 I get a different light calculation in the form of a point light casting raytraced shadows.
    I compiled this and it worked!

    So I decided to pass 0.0 to the second example and it failed. I get a completely black scene. The shader does compile and still works when I pass a 3.0.

    I came to the conclusion that_ illuminate_ must be "Taking Over" the shader in some global way, locking other portions of the shader from changing Cl. I know that sounds weird, but I tried commenting out the illuminate loop and the shader began to work as expected again.

        // Default to HEMI/Ambient lighting.
        if (type == 3.0) {
            L = vector( 0,0,0 );
            Cl = energy * light_color;
        }
        // Point light with shadow.
        if (type == 0.0) {
            //illuminate (from) {
                color vis;
                vis =  (1 - shadow("raytrace",Ps,"blur",shadow_blur_size,"samples",shadow_ray_sample));
                Cl = vis * energy * light_color;
            //}
        }
    

    Just reporting this. I don't know if it will ever get fixed but it does prevent us shader writers from creating complex shading scenarios.

     
  • Cedric PAILLE
    Cedric PAILLE
    2012-07-03

    Hi,

    As far as I remember, there's a cache system for lights, could you try to add :

    clearlighting();
    

    at the beginning/end of the surface shader code ?

    Cheers.