Planetside Software Forums

General => File Sharing => Planets => Topic started by: bigben on July 10, 2017, 10:46:58 PM

Title: Angle from a reference vector
Post by: bigben on July 10, 2017, 10:46:58 PM
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.
Title: Re: Angle from a reference vector
Post by: Dune on July 11, 2017, 03:34:51 AM
Higher level TG calculative work. Thanks a lot, Ben, this might come in handy one day.
Title: Re: Angle from a reference vector
Post by: bigben on July 11, 2017, 04:34:09 AM
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 ;)

Title: Re: Angle from a reference vector
Post by: cyphyr on July 11, 2017, 05:15:51 AM
Very useful indeed. I shall investigate later
Title: Re: Angle from a reference vector
Post by: bigben on July 11, 2017, 09:20:28 AM
Eye ball with displaced lens using 2 spheres  ;)
Title: Re: Angle from a reference vector
Post by: Dune on July 11, 2017, 09:30:18 AM
Cool!
Title: Re: Angle from a reference vector
Post by: Kadri on July 11, 2017, 09:40:38 AM

Nice and thanks for sharing.
Title: Re: Angle from a reference vector
Post by: bobbystahr on July 12, 2017, 07:38:17 PM
thanks for the shares and cool technique on the eyeball. nice t have you posting again. I sense a learning curve in BobbyWorld.
Title: Re: Angle from a reference vector
Post by: 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 ;)
Title: Re: Angle from a reference vector
Post by: bobbystahr on July 13, 2017, 01:22:09 AM
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.
Title: Re: Angle from a reference vector
Post by: luvsmuzik on July 13, 2017, 09:37:42 AM
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
Title: Re: Angle from a reference vector
Post by: 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 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) 
Title: Re: Angle from a reference vector
Post by: luvsmuzik on July 13, 2017, 12:38:35 PM
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...
Title: Re: Angle from a reference vector
Post by: 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
Title: Re: Angle from a reference vector
Post by: bobbystahr on July 15, 2017, 01:24:11 PM
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
Title: Re: Angle from a reference vector
Post by: Oshyan on July 15, 2017, 08:06:12 PM
Excellent! Some interesting dithering artifacts at the top of the image though. Was that in the render, or due to post processing?

- Oshyan
Title: Re: Angle from a reference vector
Post by: bigben on July 15, 2017, 09:23:59 PM
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

... and this is exactly why I share my clips... seeing someone else find a good use for them :)

Change the vector to the poles and add auroras or other latitude-based masking.  All you need for each different latitude restriction is a new colour adjust node from the output to set the limits.
Title: Re: Angle from a reference vector
Post by: bobbystahr on July 15, 2017, 10:04:43 PM
...once again, I love this forum....
Title: Re: Angle from a reference vector
Post by: Ariel DK on July 16, 2017, 02:15:19 PM
I formatted my PC a few days ago, saying this

@ Oshyan: yes, is PW. I finally buy PS cc v.18 yesterday, but the jpeg module was bad configurated, the original tiff is much more detailed

@ bigben: this scene already contains auroras  ;) i will make a render test now, but gonna be slow, because for now im only dedicating 512 mb for VRAM
Title: Re: Angle from a reference vector
Post by: hydrodigger on January 05, 2020, 03:20:36 PM
This works very well. Awesome work! Thank you so much!  :D
Title: Re: Angle from a reference vector
Post by: Valri on October 19, 2020, 01:11:09 AM
I wonder if this can be used to mask GI and AO on the side of a planet where the direct light is on, I've often wanted GI and AO only on the dayside of my planets but never could figure out how to do this.
Title: Re: Angle from a reference vector
Post by: Dune on October 19, 2020, 02:20:37 AM
You could try plugging that mask into the shadow function of the atmo (theoretically).
Title: Re: Angle from a reference vector
Post by: Valri on January 27, 2021, 10:06:06 PM
Quote from: Dune on October 19, 2020, 02:20:37 AMYou could try plugging that mask into the shadow function of the atmo (theoretically).
Was this in response to what I asked?
Title: Re: Angle from a reference vector
Post by: Dune on January 28, 2021, 02:52:40 AM
I guess so, but just a hunch.
Title: Re: Angle from a reference vector
Post by: WAS on January 28, 2021, 03:00:39 AM
I thiiink if you use a sphere with same final position terrain and have cast shadows off it will look far more flat in light/shadow. You could have it a sphere of the same size as planet and offset it by just enough to mask that side of the planet maybe. Using same disp and colour it should bend fairly well. Better if GISD is off. Would be cool if the image effect was able to read intersected terrain as one thing to prevent shaded lines at intersections.
Title: Re: Angle from a reference vector
Post by: Dune on January 28, 2021, 04:41:43 AM
Perhaps an invisible huge plane transecting the planet, giving of just a shadow...
Title: Re: Angle from a reference vector
Post by: WAS on January 28, 2021, 06:14:17 PM
Quote from: Valri on October 19, 2020, 01:11:09 AMI wonder if this can be used to mask GI and AO on the side of a planet where the direct light is on, I've often wanted GI and AO only on the dayside of my planets but never could figure out how to do this.

Posted an example of what I envisioned here: https://planetside.co.uk/forums/index.php/topic,28834.new.html
Title: Re: Angle from a reference vector
Post by: Victorpks on May 25, 2023, 03:25:52 PM
Quote from: Ariel DK on July 15, 2017, 12:42:00 PMI almost missed this topic. as an idea, it's also useful for recreate the Ionosphere
Hello,
I saw your post creating the Ionosphere of the earth on the darkside ? How can i do it please ?
I tried with 2 differents atmosphere but i dont know how to mix them.
Do you have a technique to mix them or maybe i'm wrong  please ?

Thank you in advance.
Title: Re: Angle from a reference vector
Post by: Ariel DK on August 04, 2023, 07:31:05 PM
Quote from: Victorpks on May 25, 2023, 03:25:52 PM
Quote from: Ariel DK on July 15, 2017, 12:42:00 PMI almost missed this topic. as an idea, it's also useful for recreate the Ionosphere
Hello,
I saw your post creating the Ionosphere of the earth on the darkside ? How can i do it please ?
I tried with 2 differents atmosphere but i dont know how to mix them.
Do you have a technique to mix them or maybe i'm wrong  please ?
Thank you in advance.
Hi Victorpks! Sorry the late response. the ionosphere is quite simple: it was just a very thiny high altitude cloud layer. i plugged the setup into a colo adjust node, then, into a final density modulator in the cloud node, and played with the values. Make sure your angle vector is the same your sun "elevation" angle. Unfortunatelly i couldnt find the tgc files in my PC