Multiple transmissive objects as just one surface

after the fix (,and thank you Brecht for it!!) we can now retrieve globals from trace function. :smiley:

//BE CAREFULL! for blender versions without this fix, it will crash when render//

So I’ve created this script, which hides the surface whenever the incoming ray is already coming from any object with the same material Id and also shows the surface on the exiting point of the ray.

It can be helpfull with Glass, Translucent and Transparent.

Unfortunatly it doesn’t work for SSS, but it’s a start!

without the script:

with the script:

 * HideInternal.osl by Miguel Porces (2014)
 * (a.k.a. Secrop)
 * Checks if the P is already inside an object with the same material ID,
 * And if so, outputs Transparent()

surface HideInternal
    closure color Closure1 = 0,
    output closure color Closure = 0

    normal n = N;
    float exteriorSurf=0.0;
    float myMaterialIndex=0.0;
    float hitMaterialIndex=0.0;
    float hitFace=0.0;
    vector VectorTrace = vector ( 0.0 , 0.0 , 0.0 );
    int Hit=0;
    getattribute("material:index", myMaterialIndex);
    if (backfacing()) {
    else {
    int DoTrace = trace (P, VectorTrace) ;
    if (DoTrace) {
        int HitTrace = getmessage ("trace", "hit" , Hit ) ;
            HitTrace = getmessage ("trace", "material:index" ,  hitMaterialIndex ) ;
            HitTrace = getmessage ("trace", "backfacing" ,  hitFace ) ;

    if (!exteriorSurf==0){
        Closure = transparent();
    } else {
        Closure = Closure1;


To use it just plug the original closure in.

Attachments (605 Bytes)

It looks as a good idea… can you share a node setup or a simple blender file please?

The setup is very easy…

Then apply the material to the objects you want.

Also the material pass should be different from the other materials in the scene… well, from the other materials that you dont want to include in the effect.

What the script basically does, is to ‘skip’ all the hits with the same material ID, except the ones that come from another material (the entry point) and the ones that continue to another material (the exit point), in between everything becomes transparent.

Thanks… I will try it… :slight_smile:

cool! looks very usefull!