Digital Art Zone

 
     
shader for glass
Posted: 20 November 2012 02:13 PM   [ Ignore ]
New Member
Total Posts:  12
Joined  2003-10-09

I am trying to build some windows. I have tried to create what I think is good looking glass shader but it does not look OK.  Anyone with some good ideas.

Profile
 
 
Posted: 20 November 2012 03:08 PM   [ Ignore ]   [ # 1 ]
Power Member
Avatar
RankRankRank
Total Posts:  1818
Joined  2004-08-24

Hi Shell1850 smile

If you can post an example of your shader tree, and what you’re aiming for,. people can see it, and advise better.

There should be some basic Glass shaders included with carrara, in the native content,.
In the browser, under Shaders / Glass


you can open any of these in the editor and look at the settings, then compare them to what you’ve made so far,.
Or,. you could use one of those pre-set.

Image Attachments
shaders_glass.jpg
Profile
 
 
Posted: 20 November 2012 04:23 PM   [ Ignore ]   [ # 2 ]
Addict
Avatar
RankRankRankRank
Total Posts:  4545
Joined  2007-09-13
3DAGE - 20 November 2012 03:08 PM

Hi Shell1850 smile

If you can post an example of your shader tree, and what you’re aiming for,. people can see it, and advise better.

There should be some basic Glass shaders included with carrara, in the native content,.
In the browser, under Shaders / Glass


you can open any of these in the editor and look at the settings, then compare them to what you’ve made so far,.
Or,. you could use one of those pre-set.

A couple of things about window glass…it doesn’t seem to be as refractive as other glass, but that’s more because it’s flat.

Also, it is a little reflective, but because it tends to be well lit, the reflections don’t often show up, on ‘viewing’ side…

Other than that, it’s nearly but not quite, completely transparent and has practically no color.

 Signature 

1432 old posts

My ShareCG gallery.

Just because something costs a lot, doesn’t mean it’s the best…

It just means it’s expensive.

Profile
 
 
Posted: 21 November 2012 12:19 PM   [ Ignore ]   [ # 3 ]
New Member
Total Posts:  12
Joined  2003-10-09

I was looking at the icons and expected to see a object that I could see thru. I did find the glass icon (it was brown like muddy water). I am using it.

Thanks

Profile
 
 
Posted: 21 November 2012 04:40 PM   [ Ignore ]   [ # 4 ]
Power Member
Avatar
RankRankRank
Total Posts:  1059
Joined  2007-10-15
mjc1016 - 20 November 2012 04:23 PM

A couple of things about window glass…it doesn’t seem to be as refractive as other glass, but that’s more because it’s flat.

Also, it is a little reflective, but because it tends to be well lit, the reflections don’t often show up, on ‘viewing’ side…

Other than that, it’s nearly but not quite, completely transparent and has practically no color.

Good points.

Seems like the most common thing that people don’t realize is that a pane of glass is reflective, and often it is VERY reflective. And as you say, it depends upon the relative light levels. If you’re in a dark room looking out a window to a bright daylight, then you’re not going to see much, if any, reflection. OTOH, if you’re outside looking in, it’s just the opposite. Which is one reason why just dragging and dropping a glass shader and calling it good might not be the best.

And in fact, technically you might see multiple reflections. If it is dual pane glass, each pane might reflect. And what’s even less obvious is that BOTH SIDES of an individual glass pane might reflect.

Another reason is glass color. Many windows nowadays are tinted, maybe gray or brown. And if you actually raise your head right now and look at the windows in the room you’re sitting in, you’ll probably notice, as I do, that the windows are dirty. That makes a big difference in what you see thru them.

As far as the refractive issue, I think that most window glass has the same refractive index as regular glass, around 1.5. However, the reason you don’t see refractive distortion in flat window glass is not necessarily because it’s flat, it’s because of other reasons. The main one, I think, is the fact that it has thickness. Or actually thin-ness.

Light thru a pane of glass distorts as it enters the glass, and then distorts again when it leaves the glass. The thinner the glass, the less the apparent distortion. And there’s a term for it (which I had to look up…). It’s called Lateral Displacement. It causes the apparent distortion to be less than if it just did a single refraction (like you’re looking into a deep swimming pool), or refracted thru a very thick glass. And I *think*, though I’m not sure, the resulting distortion is different from a purely refractive distortion. With a displacement distortion it just shifts the apparent position of what you see on the other side. Not the bending distortion you might associate with refraction. Though I could be off on that. 

Unfortunately, as I recall Carrara doesn’t allow you to simulate glass thickness as do most other 3D apps.

Ideally what you’d do if you could is simulate a pane of glass as an object with thickness, with air on either side, so that you’d get a realistic, not-very-distorted image when you look thru the thin pane of glass. Instead, I’m guessing that Carrara just takes your flat plane of glass, or even your cube of glass, and applies some fixed factor that ends up giving you an unrealistically distorted image due to refraction.

So bottom line, you’re probably better off with using no refraction at all, just crank up the transparency, give it some reflection depending on lighting levels, and maybe some color (absorption) if you want to tint the glass. And maybe a little highlight if you want.

Profile
 
 
Posted: 21 November 2012 06:09 PM   [ Ignore ]   [ # 5 ]
Addict
Avatar
RankRankRankRank
Total Posts:  4545
Joined  2007-09-13
JoeMamma2000 - 21 November 2012 04:40 PM

As far as the refractive issue, I think that most window glass has the same refractive index as regular glass, around 1.5. However, the reason you don’t see refractive distortion in flat window glass is not necessarily because it’s flat, it’s because of other reasons. The main one, I think, is the fact that it has thickness. Or actually thin-ness.

Yeah, there’s a lot more to it than just, ‘it’s flat’.

Curved surfaces ‘enhance’ the refractiveness…think about old TVs…the picture tube was made, usually of 24% lead crystal…a pretty refractive glass (it’s slightly higher than the 1.5 of ‘normal’ glass…1.56, I think).  But put that old curved tube up against a ‘flat’ CRT and you will immediately notice the difference.

Same thing with plate glass…the refraction isn’t as noticeable,  even if it is 1/2” thick as if it were the same thickness but heavily curved, like a lens…even at the same refractive index.  This is due to the viewing angles and what not…it’s just easier to say ‘because it is flat’, than get into all the differences in the math and perceptions involved.  And even at the same ‘thin-ness’ a curved piece of glass is going to be perceived to be more refractive than a flat one. 

 Signature 

1432 old posts

My ShareCG gallery.

Just because something costs a lot, doesn’t mean it’s the best…

It just means it’s expensive.

Profile
 
 
Posted: 22 November 2012 03:18 PM   [ Ignore ]   [ # 6 ]
Power Member
Avatar
RankRankRank
Total Posts:  1059
Joined  2007-10-15

Yeah, no question curvy-ness enhances the distortion. So I agree. You’re right.

But think of a curved automobile windshield, or a curved F-18 canopy. You can have a curved glass with very little refractive distortion. My point was, maybe a bit overstated, that people tend to forget the fact that modelling the thickness of a refractive object is something you need to consider, and Carrara doesn’t allow it. Yeah, everyone knows that a curved, crystal orb gives a huge amount of refractive distortion, as does a crystal wine glass.

But when you said “it doesn’t seem to be as refractive as other glass, but that’s more because it’s flat” you may have left the impression that the refractive distortion is mainly related to shape. Just look at the typical example of sitting on the side of a swimming pool full of crystal clear water, which is totally calm and flat. You put your feet in the water, and see all kinds of distortion of your feet and legs. But that pool of water is, basically, a flat pane of really, really, really thick glass. No curvature at all.

And then people insert a flat plane into their scenes, apply a standard glass shader, and wonder why they see so much refractive distortion, when the window in their living room doesn’t have that same distortion. I was trying to explain why. Do you disagree with the point I was making? 

But yes, you’re right. Curvy-ness is a big factor in refractive distortion. Okay?

Profile
 
 
Posted: 22 November 2012 04:49 PM   [ Ignore ]   [ # 7 ]
Member
Avatar
Rank
Total Posts:  239
Joined  2006-01-21

Hi,

Just want to correct a misconception here, but Carrara does respect an enclosed volume for refraction.
The surface normals point to the outside of the volume.
In fact two disconnected planes with the back plane flipped works too.

Try it with a vertex cube scaled to match a plane of glass and you will see that there is zero distortion in the glass except when looking along the edges where it should be.
Model a lens out of a solid sphere and you gan make a convincing magnifying glass.

http://www.renderosity.com/mod/gallery/index.php?image_id=2159296&user_id=654859&np;&np;
Basically, as long as opposing surfaces are perfectly parallel, perfectly smooth and have inverse normals there will be no perceptible distortion even though there is refraction (which is why a car windscreen still works despite the curve)
If the opposing surfaces are curved differently then thats when you get the magnifying effect.

And before anyone asks, yes I am an expert in optical physics, or at least I have a bit of paper that says I am.

 Signature 

http://roguepilot.deviantart.com/
http://www.renderosity.com/mod/gallery/browse.php?username=RoguePilot
http://www.ShareCG.com/pf/full_uploads.php?pf_user_name=RoguePilot

Profile
 
 
Posted: 22 November 2012 04:58 PM   [ Ignore ]   [ # 8 ]
Power Member
Avatar
RankRankRank
Total Posts:  1059
Joined  2007-10-15

EXCELLENT !!!! Someone who knows optics !!

Cool. So, RoguePilot, would you say my discussion of why a plane of glass with finite thickness doesn’t show distortion, ie, because it has thin-ness and exhibits lateral displacement, is at least reasonable? Because I’m sure as hell not an expert in any of this, just a guy who looks into the basics…

Now, as far as Carrara’s handling of it….

I could have sworn I tried the trick you mentioned, ie, using two planes with swapped normals, but didn’t see any difference from a single plane….

So how do you tell Carrara that one side is glass and the other is air? And that applies for each plane. Typically, with other apps, you define for each plane that one side is air, the other is glass, and it accurately figures out the refraction. But does Carrara just do it correctly based on normal directions? Hmm…....

Profile
 
 
Posted: 22 November 2012 05:38 PM   [ Ignore ]   [ # 9 ]
Power Member
Avatar
RankRankRank
Total Posts:  1009
Joined  2007-04-08
JoeMamma2000 - 22 November 2012 04:58 PM

EXCELLENT !!!! Someone who knows optics !!

I know optics, I get my whisky out of one at the pub.

 Signature 

You’re never too old for metaballs!  ~Michael Frank

Profile
 
 
Posted: 22 November 2012 05:54 PM   [ Ignore ]   [ # 10 ]
Power Member
Avatar
RankRankRank
Total Posts:  1059
Joined  2007-10-15

Okay, I did a real quick scene with two glass objects. The one on the left is a glass pane with some thickness, the one on the right is an identical sized pane with zero thickness, both have the same shaders and both are located in the same relative positions.

Seems like the one on the left (with thickness) shows minimal distortion, just a lateral shift of the pattern behind the glass compared what you’d see without refraction. While the one on the right also shows some magnification and shifting that the other one doesn’t. Which means RoguePilot was right, Carrara does assume that a primitive cube has thickness when it calculates refraction. Cool…

Though I’m still not sure about two planes (with flipped normals) that are defined as opposing sides of a pane of glass, and how Carrara figures out how to apply refraction….

Image Attachments
Optics.jpg
Profile
 
 
Posted: 22 November 2012 07:06 PM   [ Ignore ]   [ # 11 ]
Member
Avatar
Rank
Total Posts:  239
Joined  2006-01-21

It’s based on the direction of the normals.
The pointing out side (if that makes sense) is seen as the lower RI side. So if you had an RI of 1.3 with normals pointing out you are transitioning from air to glass.
If you flip the normals and have them pointing in you are transitioning from glass to air. You can put air bubbles in liquid by doing this.

The planes simply obey the same rules so you can set up the transitions to counteract or amplify depending on which way the planes are facing each other. Place them at angles to build a prism.

On your other question, it comes down to the lensmakers equation.

As the curve radius increases and the thickness decreases the power of a lens goes down, but also if the curve of the opposing surfaces becomes more similar in radius then they cancel out and the power drops there too. Any difference in curve will produce a positive or negative magnification depending on thickness of a lens.
Hence a volume with perfectly parallel surfaces that is very thin, even if curved, will produce minimal distortion.

Been a long time but I think it goes P = (ri-1)((1/R1-1/R2)+((ri-1)d)/(riR1R2))

R1 radius of first surface, R2 second surface

If R1 = R2 (ie flat) and d (thickness) is small the Power becomes pretty much zero. Thick planar glass will refract, but because it’s all in the same direction you’re pretty much not going to notice anyway.

oh, ri = refractive index, so the closer the ri is to 1 the less the power. (1 is a vacuum so can’t go lower than that)

To finish off, if you have a single curved surface, on its own with no back surface (as modelled in all car models that I’ve seen) you’ve just filled that entire volume with glass. Expect all light coming through that surface to be bent. Like a pool of water.

I guess that means you’re on the right track Joe. Fairly good reasoning. For a layman.

 Signature 

http://roguepilot.deviantart.com/
http://www.renderosity.com/mod/gallery/browse.php?username=RoguePilot
http://www.ShareCG.com/pf/full_uploads.php?pf_user_name=RoguePilot

Profile
 
 
Posted: 22 November 2012 07:24 PM   [ Ignore ]   [ # 12 ]
Member
Avatar
Rank
Total Posts:  239
Joined  2006-01-21

Just to add;

Carrara must assume a refractive index of 1 on the outside of the normal, so technically if you put a regularly oriented object inside another and they both have refractive shaders then the effect amplifies.
If you wanted to put plastic beads in a glass of water say and have it look right you would need to adjust the refractive index of the plastic shader down a bit. Acrylic is about 1.5, water about 1.3 so I think a setting 1.15 should work (1.15*1.3 =  1.495).

If it works that way.

 Signature 

http://roguepilot.deviantart.com/
http://www.renderosity.com/mod/gallery/browse.php?username=RoguePilot
http://www.ShareCG.com/pf/full_uploads.php?pf_user_name=RoguePilot

Profile
 
 
Posted: 22 November 2012 09:01 PM   [ Ignore ]   [ # 13 ]
Member
Avatar
Rank
Total Posts:  239
Joined  2006-01-21

Been looking through my gallery for some examples of solid glass and I think these two fit the bill.
The glass box is constructed of primitive cubes for each pane. Even the base is semi-transparent.

http://fav.me/d4mobtf

http://fav.me/d4o3ut7


For single layer glass any car should do, I simply reduced the RI to 1 and upped the reflection to help show the curve instead.

http://www.renderosity.com/mod/gallery/index.php?image_id=2311743&user_id=654859&np;&np;
Lastly , this was my first real test of what carrara could do with refraction in combination with a simple procedural bump.
Here’s a pool surface for you Joe.

http://www.renderosity.com/mod/gallery/index.php?image_id=2104589&user_id=654859&np;&np;

 Signature 

http://roguepilot.deviantart.com/
http://www.renderosity.com/mod/gallery/browse.php?username=RoguePilot
http://www.ShareCG.com/pf/full_uploads.php?pf_user_name=RoguePilot

Profile
 
 
Posted: 22 November 2012 10:06 PM   [ Ignore ]   [ # 14 ]
Addict
Avatar
RankRankRankRank
Total Posts:  4545
Joined  2007-09-13
RoguePilot - 22 November 2012 07:06 PM

It’s based on the direction of the normals.
The pointing out side (if that makes sense) is seen as the lower RI side. So if you had an RI of 1.3 with normals pointing out you are transitioning from air to glass.
If you flip the normals and have them pointing in you are transitioning from glass to air. You can put air bubbles in liquid by doing this.

The planes simply obey the same rules so you can set up the transitions to counteract or amplify depending on which way the planes are facing each other. Place them at angles to build a prism.

On your other question, it comes down to the lensmakers equation.

As the curve radius increases and the thickness decreases the power of a lens goes down, but also if the curve of the opposing surfaces becomes more similar in radius then they cancel out and the power drops there too. Any difference in curve will produce a positive or negative magnification depending on thickness of a lens.
Hence a volume with perfectly parallel surfaces that is very thin, even if curved, will produce minimal distortion.

Been a long time but I think it goes P = (ri-1)((1/R1-1/R2)+((ri-1)d)/(riR1R2))

R1 radius of first surface, R2 second surface

If R1 = R2 (ie flat) and d (thickness) is small the Power becomes pretty much zero. Thick planar glass will refract, but because it’s all in the same direction you’re pretty much not going to notice anyway.

oh, ri = refractive index, so the closer the ri is to 1 the less the power. (1 is a vacuum so can’t go lower than that)

To finish off, if you have a single curved surface, on its own with no back surface (as modelled in all car models that I’ve seen) you’ve just filled that entire volume with glass. Expect all light coming through that surface to be bent. Like a pool of water.

I guess that means you’re on the right track Joe. Fairly good reasoning. For a layman.

OK…‘it’s flat’ = ‘parallel surfaces and thin’...

 

 Signature 

1432 old posts

My ShareCG gallery.

Just because something costs a lot, doesn’t mean it’s the best…

It just means it’s expensive.

Profile
 
 
Posted: 23 November 2012 01:19 AM   [ Ignore ]   [ # 15 ]
Power Member
Avatar
RankRankRank
Total Posts:  1059
Joined  2007-10-15

Awesome, RoguePilot !!! I really appreciate the info.

I guess I’ve always gotten some rather un-remarkable results when modelling crystal/glass in Carrara, and could never get the realistic refractive distortion that seems so much easier to obtain in other apps. I’m guess I’m still not real clear why that is…perhaps just operator stupidity, but maybe there’s something about Carrara’s handling of curved surfaces and refraction or something? Maybe modelling the wine glass as two perfectly parallel inside and outside surfaces ruins the real-world distortion in a wine glass with imperfections.

Anyway, thanks for confirming some stuff that I’ve thought was right but have always felt a little shaky about. And for teaching me some new stuff.

Never occurred to me that a flat pane of glass is really just one type of lens. Cool. And it’s good to know that Carrara actually can figure out refraction correctly on a ‘solid’ object. Sounds like I’ve got some head-scratching and testing to do to get a handle on all of this.

Thanks again. Dude, you rock….

Profile