Rainbow

Started by bigben, February 26, 2008, 06:50:49 PM

Previous topic - Next topic

rcallicotte

Once again, the Lone Ben rides again!   ;D  Way to go!
So this is Disney World.  Can we live here?

bigben

Quote from: Matt on February 27, 2008, 09:01:35 PM
Quote from: ghotir on February 27, 2008, 10:37:51 AM
Then wouldn't he have dark clouds instead of colored clouds.  It needs to go transparent when it is shadow.  That is what rainbows do. 

Ah... true. The cloud would need to be rendered additively for that to work. But an interesting trick you might try is to make the RGB colours much brighter and reduce the density. For example use a colour intensity of 100, and then divide your current density value by 100. That will make it almost entirely additive 8)  If that's not enough to make the shadowed regions invisible, use a larger factor.

Thanks Matt

That sounds like a promising approach. A very quick test on the original render seems to produce a similar looking rainbow in sunlight.  From a previous test with the second model it looks like I'll have to find a balance between (horizontal) cloud thickness and density to maintain a certain level of transparency. I'll throw a shadow into the mix when I'm testing these combinations.

Quote from: Oshyan on February 27, 2008, 09:11:15 PM
I just want to say this is really cool and the results are surprisingly good. Go Ben! :)

- Oshyan

I'm starting to find the limitations of this hack but it's working much better than I first thought it would. I think adding the lightening inside the arc of the primary rainbow will be one of the biggest improvements towards a more realistic rainbow.

bigben

Another step forward. Replaced the conditional shaders with Boolean scalars for creating the edges of each region and removed all redundant clamping. This has been quite helpful, providing access to the original gradient to extend it either direction. This simpified the process of adding additional gradients to simulate lightening of the sky past the blue edge of the rainbow.

Each of the boolean scalars is also inverted by a boolean NOT to provide a complete set of edge masks. These are combined using a multiply or add nodes to mask different areas as required. I'll set something up on a cloud layer today to let it render over the weekend at work. The image below is still a surface preview.

PS my copy of XFrog arrived yesterday  :)

bigben

#18
Matt is a genius  ;D

Here's a cropped render of a 300m thick double rainbow in shadow  8) 8) 8)
(well the effective thickness is only 200m, with fuzzy edges toward and away from the camera)

Cloud density 5e-4
RGB colour 100

It's going to be a balancing act between the total thickness of rain/distance shader high colour AND cloud colour/cloud density but I'm thinking that once I have the cloud/desnity colour sorted the placement of the rainbow will require keeping the cloud thickness (laterally from the camera) X distance mask colour constant to provide a constant density.

I have other nodes that could be used for adjusting the brightness of the rainbow in an animation.

Rendering a comparison image without the background clouds now so that you can see where the rainbow is. (You can partly work out it's location from the image above)

bigben

OK, apart from the levels/density etc needing a bucket load of fine tuning the general principle of the model is working. This is the same TGD as the previous post with the only change being the disabling of the clouds that were casting shadows on the terrain. It's going to take a little while to get familiar with the relationship between the different numbers and the way they render in the atmosphere.

Outer edges of rainbow may have to be softened (easy)
RGB gradients may be better as non linear to show secondary colours better (adjustment nodes already in place)
Not sure what happened with the inner and outer lightening, but they look like they got swapped around...  ??? Possibly from variation in the cloud's density shader which you can make out.

I sped up render times by simplifying the density shader for the cloud. 8 cloud samples for a quality of 1. There is some noise so I may need to adjust the cache/qualtiy settings some more.
Detail 0.5, aa 3, GI 2,2

bigben

The last image needed a lot of fixing...

Another little step closer... tweaking the primary rainbow for now. I probably should add the rest of the rain that's supposed to be producing the rain as well.  The sharp edges will definitely have to be softened, and maybe changing to slightly less saturated shades of the primary colours.

This image better illustrates the lighter region beyond the blue edge of the rainbow.


rcallicotte

Oh my God!  You are a busy man, you are.   :o
So this is Disney World.  Can we live here?

bigben

nah... just a nerd with a bone ;)  I tend to post a lot while doing stuff like this on the off chance that someone has an idea that will help (like Matt's wonderful suggestion) If I had waited until the end to post I would have had a lot of reworking to do.

Selecting less saturated colours is a) not possible with values >1  and b) not required as adding the surrounding rain tones things back a bit to a more realistic level. Replacing the Boolean masks with fuzzy-edged masks should just about finish the primary rainbow. The secondary rainbow should just be a case of transferring the new levels for the rainbow gradients and then finding a suitable intensity.

I'm tempted to add a single supernumerary rainbow just to show off what TG2 can do. I'll fade it with a horizontal gradient so it willl be stronger at the top of the rainbow and then fade as it goes left and right.

The whole process is basically an extension of my multiple masks method with the only difference being the the edge effects are required this time. After calculating the angle from the anti-sun vector the math is no more complicated than Y=mX+c to position gradients for the RGB values and additional masks

bigben

Finally made the obvious connections required to simplify the whole setup. I had a mixture of colour adjust nodes and manually generated gradients because I was only thinking of the colour adjust node within the normal context of adjusting colours rather than the way it actually functions. This approach also required additional clamp scalars and extra masks.

Adding soft edges to the rainbow made some of the masks redundant as all RGB values would drop to 0, but the process of creating the extra gradients seemed unnecessarily complicated. Eventually the obvious answer clicked.... I was doing things in two stages, while the colour adjust node could do the exact same thing in one easy step. All I had to do was calculate the actual angles for the colour changes and use these for the black and while levels in the colour adjust shaders, clamping to 0 and 1.  The node network pic shows the new node structure for te primary rainbow and the old structure of the secondary rainbow.

Added some "rain". The rainbow is still a bit too distinct, so an additional broader softening of the edges may be necessary.

Cyber-Angel

If it helps refine your colors any, I found this gallery of rainbow images that maybe of assistance http://www.capetownskies.com/rainbows.htm. If you can find away to soften your colors and the transition between bands that I this would make yours more realistic from a visual perspective (IMHO), but this is a WIP so I understand that there is still much work left to do and maybe you have already considered these factors.  ;D

It is a shame that Terragen doesn't support Refraction and Dispersion in its lighting model, but maybe it will at some point in future which would make life easier for trying to do these types of natural phenomena.

Regards to you.

Cyber-Angel   

bigben

#25
There's lots of reference images around  ;)  tweaking is proving a little tricky, although I've pretty much stabilised the design of the model now so this should help.  As the construction is pretty much made up of distinct components, there are usually only one or two nodes that need to be adjusted at any one time.  I've added a fade shader to allow for fading of the rainbow from the center to the edges.

I also haven't tried a render with GI yet, and it will be interesting to see what effect the rainbow has on the surrounding rain (possibly not much for thick rainbows). This may help soften things up a little.

My trig was not as rusty as I had thought, once I got the angle calculation correct the automatic calculation of the anti-sun vector worked (I had dropped it earlier it for a manual vector just to be sure). I've left the manual node in as a fallback in case it provides a minor efficiency boost for a stationary sun). The coordinates are calculated based on a 1 meter vector in the XY plane pointing towards the sun. At least now the rainbow is effectively attached to the camera so you can go chasing rainbows around your scene.

Below is the current node structure, which is  simplified a fair bit from earlier versions despite doing a lot more. It's also easier to locate specific controlling nodes. The bulk of it consists of just colour adjust nodes that are added or multiplied together.

I'm running another test render at the moment of a complete double rainbow with "rain" and background clouds but it's going to take a little while. I can already see things that need tweaking but it will be good to see what else is working...

Cyber-Angel

As to reference images yes there is a large amount, I found that gallery just from a cursory search of Google Images which I posted only to be of help. Other than that I really like the work your doing here which shows just how powerful the node network can be.

Regards to you.

Cyber-Angel  ;D

bigben

A little more progress although unfortunately no images to show at this time. I have a completed render but I can't get it off the laptop as Explorer has spat the dummy and locked up on an error message (not related to TG).  The 2 TG renders are still running fine though, so I'm waiting for them to finish before I give it a "kick".

The one thing that bugged me with some of the tests was that the faded rainbows seemed to lose the secondary colours. On reflection this is probably related to the hack of using a low cloud density with high colour values. Simply multiplying a linear mask by a fixed factor to reduce its density will drop some of the lower densities to a point where they disappear.... so that the more a rainbow is "faded" the more the colours will be reduced to just red, green and blue. To get around this I thnk I'll have to set a minimum density for the rainbow masks and then multiply the remainder by the mask value.

Normal rainbow = min value + mask value x (1 - min value)
Faded rainbow = min value + fade factor x mask value x (1 - min value)

The value for 'min value' will depend on the cloud density/colour values and will require some testing to find out. All of the other tweaks I tried had problems that were related to this, so hopefully this should just about complete the model.

moodflow

Woah, those are some serious connections!  Any more and we'll need a machete to get through those nodes. 

Nice work BTW!   8)
http://www.moodflow.com
mood-inspiring images and music

FrankB

I'm just amazed about the level of creativity you are demonstating, Ben! Respect!

Cheers,
Frank