Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] General Discussion => Topic started by: Njen on 2018-06-21, 07:54:07

Title: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-21, 07:54:07
What was the reason to use a point3 controller for the U and V offset in CoronaBitmap?

I want to wire two seperate values to the U and V offset, but both of them use a single controller. So I can't connect up what I want, or is there another method?

For example, the following allows me to wire the Z rotation value of my sun to my HDRI:
Code: [Select]
paramWire.connect $'lgt_sun.Target'.rotation.controller[#Z_Rotation] meditMaterials[24][#uvwOffset] "[-(radToDeg Z_Rotation / 360), 0, 0]"
But I also want to tilt the map in Y as well, and I can't figure out how to do it. If the U and V values were separate single float controllers, this would be easy to do.
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-21, 08:34:25
I figured it out using a script controller instead of a wire controller:
Code: [Select]
map.uvwOffset.controller = point3_script()
map.uvwOffset.controller.script = "[$'lgt_sun.Target'.rotation.z, $'lgt_sun.Target'.rotation.y, $'lgt_sun.Target'.rotation.x]"
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-21, 08:52:26
Not so fast though, obviously this doesn't create a dynamic link between the two controllers, and I need to rerun the script every time the light changes, which is an issue for me, as I am simulating the rocking motion of a moving object by having the scene stationary and having the env map and sun move instead. I realise I could run a prerender script on every frame, but I was hoping there was a more elegant solution?
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-21, 09:23:30
Ok, I figured out the syntax how to wire multiple values to control a single point3 controller:
Code: [Select]
paramWire.connect $'lgt_sun.Target'.rotation.controller[#Z_Rotation] meditMaterials[24][#uvwOffset] "[$'lgt_sun.Target'.rotation.x, $'lgt_sun.Target'.rotation.y, $'lgt_sun.Target'.rotation.z]"
Finally I hook up the 'wAngle' in the CoronaBitmap to the appropriate axis.
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: karnak on 2018-06-21, 12:30:33
What was the reason to use a point3 controller for the U and V offset in CoronaBitmap?

I was wondering the same.

I want to wire two seperate values to the U and V offset, but both of them use a single controller. So I can't connect up what I want, or is there another method?

You can still use a controller to manage your values separately (see attached image).

Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-22, 05:38:11
Ah, yeah, that also seems like a good idea.

Now I am having another issue with the 'wAngle' parameter. It looks like it displays a number in degrees, but when I give it a value in degrees, it returns some weird number and I can't figure out why.

For example, I wire the 'wAngle' to my sun target like this:
Code: [Select]
paramWire.connect $'lgt_sun.Target'.rotation.controller[#X_Rotation] meditMaterials[24][#wAngle] "(quatToEuler $'lgt_sun.Target'.rotation).x"
Then when I rotate my sun target 10 degrees in the x axis, the number that appears in 'wAngle' ends up being '572.958'. If I run the following, I get an output of '10.0' in the Listener:
Code: [Select]
(quatToEuler2 $'lgt_sun.Target'.rotation).xObviously there is some sort of a conversion going on, because the number I'm supplying is not the number that is output, so what type of number does 'wAngle' actually need?
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-22, 05:50:55
Argh, I just found the answer. I need to go from quat to euler to rad...sheesh!

Code: [Select]
paramWire.connect $'lgt_sun.Target'.rotation.controller[#X_Rotation] meditMaterials[24][#wAngle] "(degtorad (quatToEuler $'lgt_sun.Target'.rotation).x)"
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: mferster on 2018-06-22, 19:14:49
Hmmmmm!

IF your environment and sun are going to be constantly and consistently shifting back and forth (ala a boat on the ocean)... it might be easier to hook up your sun's rotation to a waveform float controller and then hook up your hdri's angle to a float expression controller that reads the sun's waveform controller, that way you don't really have to animate it by hand, and you can easily edit the waveform to meet your needs.

This might not be appropriate for what you are trying to do, but it is just a thought I had.
Title: Re: How to wire seperate values to the U and V offset in CoronaBitmap?
Post by: Njen on 2018-06-22, 19:46:53
It is a good thought.

The orientation of the 'world' (sun and HDRI) is animated using a combination of noise and hand animation through a list controller on the sun target, because I have specific needs in getting the look I want for each shot. I then get the final world rotation from the target using an exposeTm object, which then drives the orientation of the HDRI.