Angle from a reference vector

Started by bigben, July 10, 2017, 10:46:58 PM

Previous topic - Next topic

bigben

Here's a function I use for creating masks at specific angles around a reference vector by comparing it with a vector from a reference point to get(position).  The output is in degrees to make it easier to work with.

Reference point: e.g. the location of the render camera or the center of an object/planet
Reference vector: Line between 2 points or derived from the heading/altitude of an object/light e.g. the position of the sun.

To create a mask, just feed it into a colour adjust node and set the black and white levels to the required angles.
For example I'm currently using it to mask a spherical image map used for simulating city lights on the Earth. Reference point is the centre of the planet, reference vector is derived from the position of the sun (I negate it for simplicity).  This allows the lights to be hidden on the daylight side as a mask and fading in the lights towards the night side of the planet by multiplying the mask with the luminance of the lights so that the lights start of dim and fade up to full intensity after 2-3 degrees.

Animation: The mask can be animated easily by duplicating the animation of the reference point/reference vector where applicable.  This is easy when the camera is the reference point as you just need a get(camera position) node

I've also included a clip to convert Heading/Altitude to a vector... e.g. to convert the sun's position to a vector for use in the above clip. They're both the same functionally. The TGD shows the basic usage of both combined.

Dune

Higher level TG calculative work. Thanks a lot, Ben, this might come in handy one day.

bigben

#2
It's the basis for my procedural rainbow test.
Import a rocket with Z-up and you can use X rotation for altitude, y-rotation for heading and have a conical mask extend out the back of the rocket... or constrain a dust cloud behind a moving object... fake spotlight beam using a cloud...  you never know when it'll come in handy ;)


cyphyr

Very useful indeed. I shall investigate later
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

bigben

Eye ball with displaced lens using 2 spheres  ;)

Dune



bobbystahr

thanks for the shares and cool technique on the eyeball. nice t have you posting again. I sense a learning curve in BobbyWorld.
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist

bigben

Quite possibly Bobby...  refreshing my memory from my old notes, but my best notes are here in the forum.  Reading an old post and wishing I'd included an screengrab of this or that, or a clip... so I'll be posting a bit more detail for my own reference in future ;)

bobbystahr

Quote from: bigben on July 12, 2017, 10:19:06 PM
Quite possibly Bobby...  refreshing my memory from my old notes, but my best notes are here in the forum.  Reading an old post and wishing I'd included an screengrab of this or that, or a clip... so I'll be posting a bit more detail for my own reference in future ;)

Forums are often the best archve.
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist

luvsmuzik

Hi. Thanks for this share! I have read many of your posts in the archives through the years. Joined the forum last year.

I tried this tgd hoping to get similar results but perhaps I did something wrong. Does this lighting effect work using the nebula and stars tgc? I did not change any values in the sun position or other nodes.
I added a higher atmo to the planet and masked that with a PF. I seem to be getting the reverse shading effect that you show here.
I tried changing the color adjust settings...many ways, and no luck there either.
I also tried the altitude node....getting a bright pink stripe on the planet...

I posted my results in image sharing:
http://www.planetside.co.uk/forums/index.php/topic,23363.msg236432.html#msg236432

bigben

Answered in your image post but I'll add a little here as well. Assuming the sun is in the same position as the clip and those settings don't need adjusting...

There are a few ways to reverse the mask if the mask seems to be affecting the wrong side. 
1. In the node you are masking, check Invert Mask
2. Insert a Negate vector before the INPUT Reference vector
3. multiply the Heading and Altitude numbers by -1
4. Subtract the Black level and White level values from 180 in the final Colour Adjust node

Values for the colour adjust node range from 0 (pointing along the reference vector) to 180 (pointing in the opposite direction to the reference vector) 

luvsmuzik

Quote from: bigben on July 13, 2017, 12:01:10 PM
Answered in your image post but I'll add a little here as well. Assuming the sun is in the same position as the clip and those settings don't need adjusted.

Thanks! Trying any and all...

Ariel DK

I almost missed this topic. as an idea, it's also useful for recreate the Ionosphere
Hmmm, what version of Terragen does God use?

bobbystahr

Quote from: Ariel DK on July 15, 2017, 12:42:00 PM
I almost missed this topic. as an idea, it's also useful for recreate the Ionosphere

Good find
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist