I need to create material that gets transparent in areas that aren't exposed to light

(MatthieuLeChat) #1

I would like to create something similar to a 3D Earth that gets city lights to shine only in dark areas… But differently. Instead of light, i’ll use shadow. I made this sample here so it’s easy to figure out what i’m heading at. The sphere has a checker texture… IT has voronoi light and shadow casted on it. I want the areas on the ball that are exposed to light to math add on the checker texture that are opaque, and the areas on the ball exposed to no light to diffuse nothing either…
Somehow, i would like the diffuse map on sphere to be more visible in areas exposed to voronoi light… And the transparent shader to be mixed with voronoi darkness… I’m not sure if it makes total sense gramatically but i hope with a picture it’ll be easy to figure out…

Basically… Black points should be transparent on sphere but opaque on white background… And it can’t be done in post-processing because i have to take into account the light bouncing so the object casts light and shadow correctly on the white sheet in the back.

Somehow… The shadow on the white sheet should have its checkboard black to have holes while the white areas should display generously transparent voronoi.

In production, i’ll use what i’ll learn here to make a material opaque on light and transparent on shadow.

Imagine blinds and car’s headlights in the night… The light moves through the blinds and the light moves around just like that voronoi texture… And there’s an apple. The apple gets to shine in its lightened areas… But it’s a ghost apple… So it stays transparent in the dark areas… Yeah. Ghost apple. That’s what i’m up to :slight_smile: Now, car headlights goes through and the ghost apple gets sliced through by the light incoming. And the blinds’s shadow is casted down to up. And the shadow cuts through like razor blade in the wind. And the ghost apple gets visible and invisible at the same time, while blinds’s light and shadow keeps on sliding around the surface…

Shadow Test 1.blend (2.53 MB)

Straight-forward, 3d Earth is a very good example of what i want to achieve but only in a method where the texture naturally change from light to dark… And i’m unsure where to learn that refined need…

Transparent in dark areas… Opaque in light areas… Defined by incoming light… (voronoi)

Here’s another ghost. I like ghosts. They’re so familiar :3

(Martynas Žiemys) #2

The only Cycles output for color intensity is the render itself. If you have an object lit by an HDRI or 20 different lights, what do you consider to be a shadow? Something lit by 3 lights, but not other 17?.. Something below some intensity?.. There is no distinction between a shadow and not a shadow on cycles material level. You would need to achieve this effect using compositing and render layers if it’s an animation you are after. This is probably considered ‘post-processing’, but then I would like to strongly suggest to stop using a fork to eat a soup - choose the right tools for the job. I would create a copy of an object to cast shadows, render background, render the object, render the object using plain white material to get a shadow mask and composite everything together.

(MatthieuLeChat) #3

Somehow my original material already reacts a bit in that way for when there is intense light, the material’s transparency isn’t visible anymore, and when it’s in the shadow, its inner details gets visible. The problem is that the material reacts at whole as soon as there is any bit of light hitting any part of it. While i see very detailed shadow on the background sheet, all i see on the material is glow.
Anyway, in the object, the only source of light that i want to calculate is the one behind blinds. Other sources are redundant.
I tried with intense light but it still doesn’t make the light and shadow well defined on my material…
I’d really like my material to produce a custom shine in lit areas… Post processing won’t do. Post processing is 2d.
I’ll add a picture of my current project’s texture…
So ya, the only way i could slightly get near what i want with post-processing is to make a mask render with only brute BW then use it to mix between 2 images but i can’t afford 3x render time and it’s not the right procedure because it won’t calculate light in 3d but only fake it in 2d…

I’m pretty sure there could be a way to get a texture more opaque on hard light…
Hard light already eats up weaker light so…

About the soup… Better use a fork than a butter knife i would maintain :stuck_out_tongue:

So yeah… On the sphere example, the shadow should produce a tube from front to back then render shadow at the correct position considering the sphere’s glass material and its deform factor…

I’d somehow like *any light to reveal one aspect of the material while no light reveals no aspect and display original material or original particularity of the material…

Using the 3 square picture i added just here, i would say, left is the detail revealed by light, middle is the details when no light is incoming, and 3rd is the mix between both when facing a light blinded by blinds.

But maybe i don’T understand post-processing enough? How much 3d is post processing?

Maybe what i need would imply to have lights with IDs?

(CarlG) #4

Figuring out how much light illuminates a surface happens in shaders, and you can only plug those into “flow shaders” or material output. There is no way to read out and react upon what happens in a shader to influence it further. The best thing you can do is fake a light by pointing to a location (texture coords, using object with an empty for its location) and doing manual light calculations from there using math nodes. And you’d have to repeat this for each light you want to consider.

The next thing would be post processing, but I have no idea how to set that up.

(Martynas Žiemys) #5

Well, you are welcome to waste your time to find out for yourself if you don’t believe me. It is not currently possible in Cycles. I am not entirely sure about OSL though, but that is not supported by GPU rendering and will require you to learn programming. Your current shaders do not make much sense to me. It’s just diffuse mixed 100% on emission(so only diffuse) mixed by factor of checker texture with transparent that has some pattern generated with ramp over dot product of incoming and normal vectors plugged into color… That will most definitely not produce the desired result. The fact that you are projecting light with a texture does not change anything. Unfortunately you cannot currently get the value of reflected light in a material in Cycles. There was a discussion about it in the https://blenderartists.org/forum/showthread.php?433309-Micro-angle-dependent-Roughness-amp-Iridescence thread somewhere… Unfortunately it really seems to be impossible in Cycles at this time.

(MatthieuLeChat) #6

That’s very interesting nevertheless :o
In the example file, i used voronoi and checker to replace more complicated textures… Instead of voronoi, i use blinds and bw icons mixed to produce swiss cheeze icons in the blinds… and instead of checker texture, it’s a more organic material… Hence the “ghost apple” story.

So if i go post-processing, basically, i know it takes in consideration a lot of different aspects and layer, but does it calculate in 2d or in 3d?

What i should do is make 3 layers that will all render at once? Aspect A, Aspect B, and mask… At this point, can i get 3d coordinates and make the mask split be multidimensional? I worked just a bit, yet, with post-processing but it’s still very alien to me.

I believe that what would be fantastic would be to get some “piercing light” that would pierce through anything but still display the model normally but as if it was transparent… So this way, like a bullet in ballistic gel, the output would be marked as the input of the projectile… LEaving 2 coordinates for the calculation of light “through” channel. Furthermore, with glass deformation, stuff could become very fantastic.

Basically… That’s all said without even being sure if post-processing takes into account 3d or not exactly…

Sure thing is that i want the end result to have light and shadow very contrasted on surface without breaking all transparency…

By the way i’ll have that a try in post processing… Maybe i’ll find my answers there! ^^

And yeah, i really like the lil stickman drawing i did. It so much summarize the whole topic… Hope to find the perfect solution real soon and i’ll follow your advices and ask questions in the sense of your answer if any need comes while putting it all up together.

(MatthieuLeChat) #7

I’m trying to figure that all out.
BTW, final render excludes background which is replaced with full alpha transparency. The object and its volume is what i really concentrate on.

Layer A: Light aspect
Layer B: Shadow aspect
Layer C: Mask produced from light casted on a 255³ white copy of the object.

Objects in Layer A:
°intense sun light
°intense HDRI

Objects in layer B:
°Alt 1 to subject
°no light
°dark HDRI
°volume glow

Objects in layer C:
°Alt 2 to subject
°White texture
°Intense lamp oriented to subject
°Blinds to sift light through holes

________Product C:
________________°Product A
________________°Product B

Now… It’s pretty on a sheet but how do i put it all together?

(Cyaoeu) #8

Maybe you can use https://docs.blender.org/manual/en/dev/render/cycles/nodes/types/input/light_path.html and mix shader nodes.

(Martynas Žiemys) #9

Here, have a look at the file: Shadows.blend
This does not take shadows of the object into account, however if you think about it if what’s in the shadow is transparent, it does not cast a shadow, however it is in a shadow anyway, only lit parts cast shadows, so it should not matter as it should be the same result as taking the shadows of the transparent object into account. Well… Almost the same…

Take a look at the different scene layers, render layers and compositing nodes.

(MatthieuLeChat) #10

That’s pretty amazing for front face! But i see coming the need to produce back face… Maybe using backface culling and inverting topology? could it be done procedurally? Do Cycles backface cull on demand?
I’ll play around with the current file and update this reply once i progressed any significant bit, thanx for accompany.
Edit1: The lamp you made is amazing! Not only does it include the blinds, but it generates them procedraly. That’s great.
Edit2: I’m into it a lot, right now. I’m trying to figure out. If i do backface culling on object, i have to do it on mask too and relate both accordingly, then mix with previous layers… MAking, probably, 5 layers once done… I’ll add the file once i feel it made significant progress…

(Martynas Žiemys) #11

Back face is not lit. It’s therefore transparent. :confused: it would look weird looking from the shadow side. I have no ideas now. :smiley: Maybe if it’s possible to control volumetrics via a texture mapped using UV, the mask could be baked. I don’t know if that is possible.

(MatthieuLeChat) #12

Volumetrics like wood generators and 3d voronoi? (edited previous comment, i’ll quote the change here)

Edit1: The lamp you made is amazing! Not only does it include the blinds, but it generates them procedraly. That’s great.
Edit2: I’m into it a lot, right now. I’m trying to figure out. If i do backface culling on object, i have to do it on mask too and relate both accordingly, then mix with previous layers… MAking, probably, 5 layers once done… I’ll add the file once i feel it made significant progress…

I’m literally learning layers right now, it’s lots of fun, once i figure out the features :stuck_out_tongue:
Current project has 4 layers but i’m setting up 4th right now, i called it backface, but i wonder if a pass and a second pass could be done on a same object, having texture with backface, and inverted backface on a render and the other… “or something”

Final produce should react under any source of light and be used in different scenes and somehow naturally adapt to lighting. Produce light when dark, be opaque when in well lit areas. lol… Reminds me of Pirate of the Caribbeans 1 and the ghost pirates… Or pirate ghosts. Whatever their personal preferences.

Ghost apples. Summarize it all. :stuck_out_tongue: haha

BTW. I’m working on 5 layers now, as i edit once more.
Backface layers has inverted faces. Outside-in. So they react to backface culling…
Layers are like:

But i’m not entirely sure if i’m doing it the right way… I’ll check that just right now.

I’m not sure, render layers has their own materials? Mustn’t be it… I’ll pay closer attention… I seen that first suzan has 1 material and second has 2… Shadow and mask…

And render layer called MAsk has “mask” as material… And it’s the only layer that has material. That’s all new to me but that seems to sink in X)

On post-process, i would produce background > backface and its mask > inner details > frontface and its mask…

It’ll actually also need a 6th layer, i guess. Or maybe background layer is superfluous so it’ll become “inner details” layer. Makinf 5 once more.

(CarlG) #13

Backface can be diffusely lit using translucency shader. Not sure if it’s relevant to the approach, haven’t gotten my mind around it.

(MatthieuLeChat) #14

I guess i’m really messing up. I’m putting in as much efforts as i can but it’s all still very alien to me and my learning curve :stuck_out_tongue: Here’s what i’m at, at 11:48AM… It’s not yet working… And i’m unsure if i take the right direction but backface culling seems to work different on cycles than on viewport. But it sure has a bit to do with me trying to figure out everything-layer, which is the part i’m really new at…
I haven’t yet touched the post-processing branch yet…
Would there be a way to have this all on one single object that would render different materials and face inside and outside orientation for backface and frontface?

CArl, Hello! :stuck_out_tongue: I really wonder. By “diffusely” you mean, with it having a diffuse shader?

Shadows1.blend (225 KB)


Shadows1.blend (223 KB)

(MatthieuLeChat) #15

I’ve got the 2nd mask wrong (should be white, not orange) (got to exclude the right views from the layer) but i think i’ve got the compositing right, in this latest.Shadows2.blend (231 KB)
ABout backface, it’s wrong on both backface renders… But i’ve set the bases to develop more :3
Fixed backface mask’s color by adding “mask.backface” to layer’s material. But still doesn’t seem to display backface culling the way i would want it to… :3

(Martynas Žiemys) #16

Are you sure the desired result is with a backface visible? Is it really worth the effort? Our eys are definitely not used to seenig backs of surfaces of objects around us. That will look weird. It will form an impression the object is hollow. If it’s a ghost, I think a better look would be without the backface or with volumetrics. I think it might be possible to project the same texture for volumetrics and the light so it matches. There could also be a way to use UV mapped texture to control density of some volume in the oposite direction of the surface normals so it would be possible to use a baked ‘shadow mask’. But it’s a bit too complicated for me…

(MatthieuLeChat) #17

I tried around this yesterday but couldn’t figure out where to put that in the chain. I made some attempts but didn’t get the expected results, somehow. But i feel like if it worked the way i expected, it could produce the wanted effect but i can’T figure out what to put between here and then :3

(MatthieuLeChat) #18

Whatever works the best, i would say…

A good example of transparent objects on which the backface is visible and important is those green beer bottles with stuff written on the back of the opposite side’s sticker.

Shadows4.blend (231 KB)

I would really admit that everything you’ve created yet is already really nice and applies really well already to my needs. It just feels a bit like there’s a bit missing behind the front face but it’s already real nice.

Volumetric stuff seems amazing… I’ll check onto that on youtube.

(Martynas Žiemys) #19

Light Paths node does not have functionality to output brightness of the material or the intensity of the shadow inside the material. You can rest assured, there is currently no way for you to achieve your desired result with it.

(Martynas Žiemys) #20

I have the same feeling. I think it’s interesting to explore the volumetric way.