Jump to content

Rotate enviroment map?


brooklynz

Recommended Posts

I really used the old "reflection map" on a light a lot in previous versions of houdini. One of the handy thing about lights with reflection maps was that you could rotate them with the light's transform. Now I'd like to do the same thing with the environment map vop - in a shader. How can I do that? The "direction" vector in the env map vop doesn't seem to be what I want - doesn't seem to change anything. I guess I need to do something with the shader "space" but I am a bit mystified by it.... :blink:

Link to comment
Share on other sites

I really used the old "reflection map" on a light a lot in previous versions of houdini. One of the handy thing about lights with reflection maps was that you could rotate them with the light's transform. Now I'd like to do the same thing with the environment map vop - in a shader. How can I do that? The "direction" vector in the env map vop doesn't seem to be what I want - doesn't seem to change anything. I guess I need to do something with the shader "space" but I am a bit mystified by it.... :blink:

Probably the easiest way to do this would be to feed your reflection vector into the vector input of a TransformVOP and make its "tospace" string input into a parameter (and make its default "space:world"). Then, once you've created a shader instance, you'd set this shader parameter to the path of some object that acts as your transformation object (typically a null object with the toggle "Output transform as render space" set to "on" -- found in the Render tab of the null object). This null object will need to be displayed when rendering. The idea is that whatever transformations you give the null, will be applied to your environment map.

Another way to do this would be to add the actual transform controls to the shader itself (avoiding the need for a "parent" or "reference" object as in the method above), but that would take a little longer to explain :)

Try the TransformVOP method first and see if it does it for you.

Cheers.

Link to comment
Share on other sites

Thanks Mario - but I still am confused:

What is the reflection vector in this context? Is it "I" in globals?

And can you tell me what the "Direction" vector in the Environment Map VOP does anyway? As I said, I thought originally all I would have to do is change that to do what I wanted, but it doesn't seem to make any difference to my reflection..

thanks again

Probably the easiest way to do this would be to feed your reflection vector into the vector input of a TransformVOP and make its "tospace" string input into a parameter (and make its default "space:world"). Then, once you've created a shader instance, you'd set this shader parameter to the path of some object that acts as your transformation object (typically a null object with the toggle "Output transform as render space" set to "on" -- found in the Render tab of the null object). This null object will need to be displayed when rendering. The idea is that whatever transformations you give the null, will be applied to your environment map.

Another way to do this would be to add the actual transform controls to the shader itself (avoiding the need for a "parent" or "reference" object as in the method above), but that would take a little longer to explain :)

Try the TransformVOP method first and see if it does it for you.

Cheers.

Link to comment
Share on other sites

What is the reflection vector in this context? Is it "I" in globals?

The global vector "I" is not the reflection vector; it is "the thing you want to reflect", and you get this reflection of I (about N) by using the ReflectVOP.

And can you tell me what the "Direction" vector in the Environment Map VOP does anyway? As I said, I thought originally all I would have to do is change that to do what I wanted, but it doesn't seem to make any difference to my reflection..

You're correct in that changing the "Direction" vector that you feed the Environment Map VOP will change the orientation of the environment -- that is exactly what piping it through a transform vop, which is what I'm suggesting, will do. I have no way of knowing (without looking at your vops) why it is that you're seeing no change when you try to do this, but I suspect it might be related to how you're going about changing this vector.

In any case, I'm attaching a very simple scene with a vop network that does what I suggest. Hopefully it'll clear some stuff up.

Scrub the time line to see the env map rotating. Alternatively, input your own rotations into the object "Space_Env" and see how they affect the orientation of the environment. (by "see" I mean "fire off a render", not "look at the shader ball" -- you'll only be able to see the effect in an actual render).

testrefl.hip

HTH.

P.S: You'll notice that the Environment VOP also has an input for a transform object. This means that, you could just pipe the "tospace" parameter directly there (avoiding the need for a transform vop), but this way you see how to do it independently and can apply it to more unusual situations.

Link to comment
Share on other sites

This method of rotating the environment map with a null is handy but I have noticed one thing. When a polygonal sphere has this material with the environment map and it gets very small, the reflection behaves differently from a larger sphere would ( attached pic). The odd thing is that if I turn off the null, the shader doesn't get the transform and complains about it, but I see the reflection correctly ( as it would be without any rotation of course).

I have some idea that it may have to do with scaling geometry in the object space, with transform sops. Could it be a normal issue?

Anyway, I am also including a .hip to show what I'm talking about...

post-3165-1221508984_thumb.jpg

show_emap_prob_2.hip

Link to comment
Share on other sites

This method of rotating the environment map with a null is handy but I have noticed one thing. When a polygonal sphere has this material with the environment map and it gets very small, the reflection behaves differently from a larger sphere would ( attached pic). The odd thing is that if I turn off the null, the shader doesn't get the transform and complains about it, but I see the reflection correctly ( as it would be without any rotation of course).

I have some idea that it may have to do with scaling geometry in the object space, with transform sops. Could it be a normal issue?

Anyway, I am also including a .hip to show what I'm talking about...

Hard to duplicate your renders without the environment map, but I did notice a couple of problems: 1) you're setting Of to the envmap value, which will give you a semi-transparent object with likely unexpected coloring of the reflections, and 2) the "Interpretation" parameter to the TransformVOP should be set to "Direction Vector" (It's possible I might have missed this in my example. Sorry if I did.).

Other than that, I get the same reflections at all scales.

Regarding the different results with the null on and off... when it's undisplayed (off), the shader is still passing it to Mantra, but Mantra can't find it in the IFD. In this error case, the space will fall back to "space:current", giving you something that is different from either "space:world" or /obj/REFLnull. Note that this behaviour is different from a shader default -- it is the response to an error state (i.e: you're asking it to use something that doesn't exist, so it arbitrarily picks "space:current", prints out a warning, and gets on with things).

Here's your file with those changes:

show_emap_prob_3.hip

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