Jump to content

reflections


MENOZ

Recommended Posts

hello, i'm trying to make some reflections in vex.

looking in the presets materials i found that i should use a trace vop.

so.. i add a trace sop and it works. but it has no inputs.

i was thinking that trace vop needs dir (trace vector) input and position from global variables.

so i normalized the I and N globals, put in a reflect vop, and put the rdir output into the dir(trace vector) of my trace sop.

but i have the same result.

so why trace sop works anyway without any input?

it's correct to use a reflect vop to feed the dir input of my trace vop?

Link to comment
Share on other sites

instead of what?

i assume that if i don't plug anything, the trace vop will use the global variables with the same name, as i see in the help of others vop nodes....

i tried o use the raytrace, trace, reflective, and reflectlight with a reflect vop plugged in. they give all the same result, except for the raytracing, that give me some artifacts on the borders.. ror strange reflections..

is my approach to use the reflect vop correct?

i'd like to understand better how this reflections stuff works under the hood

Link to comment
Share on other sites

i'm trying to figure out what these nodes do..

from what i can understand the reflectLight vex takes the incident vector (from the camera) and the normal vector, make the dot product to find the reflected vector, basically what the reflect vex does, and computes the color of what the reflected vector hits. this second part is done by the raytrace vex.

so the reflectlight vex is the combination of reflect and raytrace vex nodes.

and trace vex is an extension, with more parameters, of reflectlight, or others nodes..

it's right?

i'm wrong? :wacko:

Link to comment
Share on other sites

i'm trying to figure out what these nodes do..

from what i can understand the reflectLight vex takes the incident vector (from the camera) and the normal vector, make the dot product to find the reflected vector, basically what the reflect vex does, and computes the color of what the reflected vector hits. this second part is done by the raytrace vex.

so the reflectlight vex is the combination of reflect and raytrace vex nodes.

and trace vex is an extension, with more parameters, of reflectlight, or others nodes..

it's right?

i'm wrong? :wacko:

1. The best what you can do (aside of reading docs) is to examine shaders that come with Houdini. There are number of usage of ray trace related VOPs inside them.

From those you will investigate for example, that ReflectlightVOP, doesn't return a reflectance vector but a color of reflected light, meaning - the amount of color that was send back from a surfaced hit by the ray shot from a P along reflection vector... (...my God, is it correct?). In fact this is a VOP implementation of the main form of reflectlight() function. There are two others forms of it though. Again, please refer to VEX docs.

The nodes which compute actual reflection vector against N and incident vector are ReflectVOP and FresnelVOP (and reflect() and fresnel() in VEX respectively ).

2. All ray trace related functions in VEX are grouped in terms of its generality:

2.1 There are very specific routines, like reflectlight() from which building mirror-like surface is just a matter of single call (from Docs!):

surface mirror(vector refl_color=1; float bias=.005)
{	 Cf = refl_color * reflectlight(bias, max(refl_color));
}

2.2 Some other similarly specific functions are fastshadow() and filtershadow() that return amount of occlusion in P along the vector (how much light could possible reach a surface from that specific direction). The first one simply checks if surface is or isn't occluded (0 or 1), the second one examines opacity values of all surfaces hit while ray traverses a scene along a vector D and returns vector representing occlusion (thus allowing us to make transparent/colored shadows, stained glass effect and such).

2.3 occlusion() and irradiance() are another two shading specific routines (and the last, if I'm not wrong here). Note, that occlusion() has also two forms from which the second one (not implemented in VOPs) seems to be more useful.

3. There are more general functions like trace(), that expects P and D (computed previously by reflect(), fresnel() or any other way), and returns some specific information about surface which was hit by a ray (namely Cf, Of, Af).

4. Similar (but simpler and thus more general) is rayhittest(), returning the distance to a first met surface (+ it can return P and N of that surface).

5. At the end of a generality is a gather() statement which is like a magic bullet of ray tracing in Mantra. It can sand any number of rays in any direction gathering any possible informations from a shaders assign to all surfaces met by a rays traversing your scene.

6. Extremely important are "optional raytracing parameters": http://www.sidefx.com/docs/houdini9.1/vex/...ontexts#rayopts

which allows you fine tune your shaders and can speed up ray tracing quite dramatically. Most of them can be applied to any of ray tracing calls mentioned above.

I hope I didn't omit too much ;)

Does it help?

cheers,

sy.

Edited by SYmek
Link to comment
Share on other sites

mmm, wait a minute.. VOP and VEX... you refer to nodes as VOP nodes, but the help i see for example reflectedLigh VEX node :blink:

anyway the reflectlight and others nodes works the way i wrote?

Sorry, I'm not compatible with the way how Houdini9 defines these things. Whenever I wrote above "VOP" I meant a node (VEX node in Houdini's interface) because this is what they were called previously if I'm nor wrong.

Whenever I wrote VEX I meant the VEX code (a function in programming language VEX).

The problem is that in H9 VOPs operators turned to be VEX operators. VOP context turned to be VEX context or something... I lost my self.

Edited by SYmek
Link to comment
Share on other sites

Sorry, I'm not compatible with the way how Houdini9 defines these things. Whenever I wrote above "VOP" I meant a node (VEX node in Houdini's interface) because this is what they were called previously if I'm nor wrong.

Whenever I wrote VEX I meant the VEX code (a function in programming language VEX).

The problem is that in H9 VOPs operators turned to be VEX operators. VOP context turned to be VEX context or something... I lost my self.

yes, i agree. i remember in h8 the names across the scene are alwais the same. now if i create a vop network, and enter inside... i'm in a VEX network... it' a little bit confusing.

the motion view also, why don't leave it chop view?

ok, nodes = VOP

code = VEX

ok, so what about my questions? :D

Link to comment
Share on other sites

ok, i think i understood how reflections stuff works in houdini.

now, i'm trying to make a custom reflection, i want to change the reflection vector based on a falloff, or facing fatio.

i'd like to recreate the reflectVOP with others vop nodes.

this should be the formula for reflection

R = 2N(N . L) - L

and i tried to replicate in houdini, but it doesn't work.

i attach a hip file.

the next problem will be how to bend my vector. i could bend the normal, or the reflection vecor itself, but i have no idea on how to do this. i'm not smart in math <_<

thanks

reflect.hipnc

Edited by MENOZ
Link to comment
Share on other sites

Nice overview SYmek!

this should be the formula for reflection

R = 2N(N . L) - L

Well... yes, that formula will set R to the direction of L reflected about N. In other words: the mirror reflection direction of L relative to N. It also assumes that both N and L are in the same hemisphere. Also, in practice, that 'L' in your formula would be normalize(-I), not the global 'L' of an illuminance loop.

But why bother? There is a vex/vop function/operator that will do the exact same thing for you: the ReflectVOP and reflect() function. For example: reflect(I,N) will mirror the viewing direction I about N (note that, internally, this is not exactly the same as your formula -- this one expects the two vectors to be in opposite hemispheres, but the results are the same).

Please note that all of the above results in a direction vector, not the amount of light coming from that direction -- just the direction of reflection, nothing more. To actually get the amount of light coming from that direction you need to feed that vector you just computed to one of those functions SYmek mentioned: reflectlight(), gather(), environment(), etc.

Last but not least, you need to realize that your newly minted reflection direction is in camera space. This is fine if you're only going to be sampling your scene (using reflectlight(), gather(), etc.). But not if you intend to sample an environment map. In that case I'd suggest you transform it to world space before using it. So for example:

vector envcolor = environment("envmap.rat", vtransform("space:world",reflect(I,N)) );

or

vector envcolor = environment("envmap.rat", reflect(I,N), "envobject", "space:world");

For the rest... what SYmek said :)

Cheers.

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...