Jump to content

VEX Glass


AndrewVK

Recommended Posts

From VEX Glass, translucent VOP:

fresnel(-V, nn, dot(nn, N) < 0 ? 1/eta : eta, kr, kt, R, T);

But dot(nn,N) < 0 means that we are inside...

so eta should be "ior glass"/"ior air = 1"

I think this string should look like

fresnel(-V, nn, dot(nn, N) < 0 ? eta : 1/eta, kr, kt, R, T);

Am i wrong? :unsure:

Link to comment
Share on other sites

Hey Andrew,

The quick answer is "No; it's correct as written." :o

But I'm waiting for renders, so here's a long-winded explanation...

I also had to do a fair bit of head-scratching with VEX's fresnel() function.

The confusion comes from two places: first the docs, which simply state that the parameter eta is the index of refraction... period... that's it -- they don't say whether it's meant to be an absolute index (i.e: expressed relative to vacuum/air, like 1.33 for water), or a relative index (i.e: the ratio of the "from" medium to the "to" medium, like 1.0/1.33 if going from air to water, say)... which leaves you looking for answers in the examples... which in turn leads you directly to the second source of confusion, which is that all the defaults for eta in all the VOPs/SHOPs that ship with Houdini are something like 1.2 (or something larger than 1.0 anyway); suggesting that the function wants an absolute index; when in reality, if you want an "intuitive" result, you need a *relative* index.

To me, "intuitive" means that if we go into a denser medium, then light bends *toward* the axis of the surface normal (+-N) as the speed of propagation slows down. It also means that the two vectors that I feed it should be the incident vector I and the surface normal N (both normalized). And if you set things up this way (which is the way it's done internally in the SESI OPs), and you're looking for an "intuitive" effect, then the fresnel() function expects a relative index -> the "from" medium over the "to" medium. So all those defaults should really be 1.0/1.2 instead of 1.2 (assuming we're usually coming from "air", that is).

Of course, you may like to set up the geometry in a different way, in which case you would need to reinterpret eta... everything is relative ;)

But hopefully this now answers your question. Given that the parameter eta describes the *relative* refractive properties of the surrounding medium to those of the object's material, and assuming that the surrounding medium exists in the direction N (and the object's interior in the direction -N), then the following statement is true:

"If I had to flip N in order for it to face in my direction, then we're on the other side of the interface, and the *relationship* between the two mediums (expressed by the single number eta) is inverted. I should therefore use 1/eta."

Which is the way in which it was written....

HOWEVER:

If, like myself and probably most users, you put a number like 1.2 for eta, not knowing that what it really wanted was 1/1.2, then *your* version is true, because everything is inverted to begin with.

Make sense?

ooops... back to my comp....

Link to comment
Share on other sites

Thanks Mario, You are right!

...and "big brother" assumes eta as relative parameter.

From RiSpec:

void fresnel( vector I, N; float eta, Kr, Kt; [output vector R, T] )

Return the reflection coefficient Kr and refraction (or transmission)

coefficient Kt given an incident direction I, the surface normal N,

and the RELATIVE index of refraction eta.

eta is the ratio of the index of refraction in the volume containing

the incident vector to that of the volume being entered.

Anyway...changes should be made (docs & shaders)

to prevent questions like

"Why my glass looks like glAss?"

surface glass (.....; float ior = 1.2; .....)

{

.....

.....

float eta = 1/ior;

.....

}

Link to comment
Share on other sites

Anyway...changes should be made (docs & shaders)

to prevent questions like

"Why my glass looks like glAss?"

Haha... yes, but that's the old version, now we use oglAss() ;)

surface glass (.....; float ior = 1.2; .....)

{

float eta = 1/ior;

}

That's exactly what I do in all my OPs: ask for the absolute index, and then invert it internally. The thing is that all references for material properties out there are given as absolute indices, and so it's much more likely that the user will enter a number like 1.33 than 0.75187969924812030075187969924812 :P

Having said that, I think it makes perfect sense that the *function* fresnel() should expect a relative index, so I wouldn't want that changed -- just explained better 'sall (maybe just copy/paste form "big brother's" docs?).

Cheers!

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

Hi Pete,

OK, so, relative or absolute, "eta" of 1 should give me a passthrough, no?

Yes.

However,  the VEX Glass does not! So something is still busted...

hmmm... I'm testing this on 6.5.95 (and I've been using it on 6.1 until a couple of days ago), and it seems fine over here (I'm talking about the vex functions related to refraction, not the vex glass shader).

But I just tested the following (in 6.5.95):

All tests done with various objects in front of a constant, textured backdrop

VEX Glass shader:

* all colors slammed to zero, except "Transmit"

* eta = 1 As expected, a straight passthrough --> worked OK

* eta = .9 (anything < 1) As expected, object as "denser" medium --> worked OK

Translucent VOP:

* all colors slammed to zero, except "Refraction Color"

* eta = 1 As expected, a straight passthrough --> worked OK

* eta = .9 (anything < 1) As expected, object as "denser" medium --> worked OK

So, I can't reproduce your problem here :( (which, in this case, I'm really happy to report! ;) )

The only strangeness I've noticed, is that in the "shaderball preview" viewport, you have to set the "Scale" of the "world" (bottom toolbar) to ~1.7 in order to get a 1-to-1 refracted background.

Maybe post a busted hip?

Cheers!

Link to comment
Share on other sites

Ah, heh, yeah, sorry, actually it doesn't work in the SHOP/VOP Shaderball (in Houdini) but works fine in Mantra. Sorry about that.

Thanks for your concise explanation of "eta" in Houdini world, for 5 years it has troubled me that things didn't render right with Refractions until I discovered doing below 1 gives me a nice look :) Now I know why!

Link to comment
Share on other sites

Yeah, as usual, Houdini's is the other way round. Mental Ray and other raytracers out there using numbers greater than one to represent a ray passing from a less-dense medium to a more-dense medium. So you can use numbers straight from textbooks with mental ray, like 1.33 for water, not 1/1.33 like you have to in mantra.

Also, in the shaderball, make sure transparency is turned on (at the bottom of the shaderball view pane) in order to see the pass-through,, but keep in mind that a refracted ray has a resultant opacity of 1 because all the light is being redirected by refraction. If you set eta to 1, however, the rays are not bent and it uses regular transparency instead of raytracing it.

Take care,

Jason

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...