Cycles, cast but don't receive shadows request

Is there a way in cycles to set up a shader on an object to cast shadows but not receive them? I still want the object to receive lighting cues so I can’t use the emission shader.


Any help appreciated.

Glenn

maybe light path nodes would do it

The most common solution would be to render the objects in different layers, and composite.

For doing it in the render, it’s possible to using OSL…
If you enable OSL, this script solves the problem, by probing the incoming ray to check if it’s a shadow ray, and if the object that throwed the ray has the selected material index, it returns transparent:


shader SelectiveShadows(int materialIndex=1, output float Fact=0.0)
{
    if(raytype("shadow")){
        int Hit;            
        float hitMaterialIndex=0.0;
        int DoTrace = trace (P, I) ;
        if (DoTrace) {
            int HitTrace = getmessage ("trace", "hit" , Hit ) ;
            if(Hit!=0){
                HitTrace = getmessage ("trace", "material:index" ,  hitMaterialIndex ) ;
            }
            Fact=(materialIndex==hitMaterialIndex);
        }
    }   
}

Just create the following Nodegroup, and add the node to all the objects that cast shadows, and change the pass index, in the material properties of the object that you don’t want to recieve shadows.


looks like the win 64 official bl is crashing on OSL !

thanks

looks good but I can’t seem to recreate the steps correctly. Here is my effort trying to recreate the steps…
http://www.glennmelenhorst.com/misc/blender/ballsOSL.blend

Glenn

the shader inside the node group must be a Transparent shader. The material index should be the material index of the objects that you don’t want to recieve shadows.

Also, the OSL must be enabled in the render panel.

This isn’t very intuitive, because the in cycles, the object that produces the shadow is the one that has to check the object that is throwing a shadow ray (which is a ray pointing to the light and not the other way around!), and decide if the ray will continue to the light as Transparent, or to be block as normal.

here’s a corrected blend file:
http://www.pasteall.org/blend/32875

edited: the script is still a bit buggy… I’ll have to check it more carefully. :confused:
@RickyBlender I’m using 2.71 32bit Windows… In my Blender 2.72, the shaders take forever to update.

Thanks. It works.
I was not in CPU mode. I started with transparent and it didn’t work so I began to fiddle and forgot to set it back before uploading :slight_smile:

Will play with this and see where it takes me.

Glenn

ok got latest SVN this morning on win 64
and I tried my own file set up and the one given in link earlier

and as soon as I try F12 for render it crashes

anyone else got same problem ?

Note: Seems that your OSL script makes it crashes
I tested older OSL and seems to work fine

thanks


like this?

@1832vin: No. See example http://www.pasteall.org/blend/32887

Cubes have generic material; only difference is Pass Index.

The odd thing is that if the Material Index is not 1, the script still makes Fact=1 when the hit has the same index, but the MixShader keeps outputing the top shader, as if Fact was 0.

@RickyBlender try to change ‘getmessage (“trace”, “material:index” , hitMaterialIndex)’ with ‘getmessage (“trace”, “hitdist” , hitMaterialIndex)’ and see if it crashes… i’ve seen blender crashing with osl trying to access blender attributes…

tried your new command but on win 64 still crashing!

anyone else has this problem may be ?

thanks

have you tried with 2.71? or even an earlier version? maybe its just broken in the lastest versions… :confused:

in the meanwhile, i’ve found the bug of not working with MaterialIndexes different than 1! :smiley:
(float and integer comparisons!)

working script:

shader SelectiveShadows(int MaterialIndex=1,output float Fact=0.0)
{
    if(raytype("shadow")){
        int Hit;
        float MI=float (MaterialIndex);            
        float hitMaterialIndex=0.0;
        int DoTrace = trace (P, I) ;
        if (DoTrace) {
            int HitTrace = getmessage ("trace", "hit" , Hit ) ;
            if(Hit!=0){
                HitTrace = getmessage ("trace", "material:index" ,  hitMaterialIndex ) ;
            }
        Fact=(MI==hitMaterialIndex);
        }
    }   
}

tried your latest version in 2.72 and 2.71
and still crashing!

may be doing something wrong but what

there must be someone else with win 64 to test this !

note: older ols works fine !
but none with this command trace !

thanks

have you reported as a bug? (I can’t test it here as I still have a 32b computer…)
Maybe someone from the developing team can figure it out. :rolleyes:

Before reporting would like someone else to confirm this on win 64!

thanks

I’m running Secrop’s blend in 2.72b windows64 and it works fine.
G

then must be doing something wrong

can you re upload the file with script and I will try to find what is wrong

thanks for feedback