Every cloud needs a silver lining: edge glow mask

I am trying to create a sky system using polygonal clouds rather than volumetrics. It looks fairly good throughout the daytime.

But come 6PM clouds look opaque when we look at them through the sun:

So I hooked up a camera vector and vertex normal dot product, and got silver linings-- but of course, clouds had silver linings everywhere, even when you’re looking away from the sun.

This is the desired effect (a composite in photoshop)

How do I make it so that we get this silver lining only over the sun, fading out as the clouds recede away? Maybe a mask?

Thanks in advance for any help on this!

yeah you could scale the intensity with a sphere mask.
the ‘a’ input would be world position and ‘b’ would be the position of the sun. hardness would be 0 and radius some fairly high value in the thousands i’d imagine.

you could also try running the dot product with the normal and atmospheric light vector for a of bit different effect.

How would you go about getting the position of the sun’s light vector into the material graph? That’s what I’d have the most trouble with.

I’ve got an orrery going atm-- the sun’s on a card that rotates around in front of the sky sphere. The directional light is parented to the sun card. It all does a day/night cycle that works pretty well.

So all I have to do is use the atmospheric light vector node, which will return any directional light vector? What if there are two directional lights in the level, one for the moon if it’s up while the sun is (though at a very low intensity)?

if you have a directional light in the level then the “atmospheric light vector” node will return the direction it’s pointing provided the directional lights intensity is over 0.

Alternatively, you could make a fake sun blueprint. Generally I would add a billboard and arrow components. Then make a material parameter collection and set a vector parameter to the arrow’s forward vector in the construction script. Bring the fake sun into the level and add the parameter collection to the material. when you rotate the sun the light direction in the material changes.

I don’t think “atmospheric light vector” node will work right with two directional lights. it will try to just swap back an forth as they run their construction scripts.

you could feed a parameter off of the directional light in your card, and swap the vector for the moon when one becomes more intense then the other. or you could use two dot products in the material if you would rather not swap.

Swap would be complicated, so two dot products it is. Or could you add the two sphere masks together, then multiply over the dot product?

Thank you for your continued attention to this, I may need to consult your help in the future when implementing this in the blueprint stage. Think you’d be game to help me out again in the future?

What are the dot products for in this case?

I’m not sure what you’re saying, I think you’ll need two dots but it won’t hurt try whatever it is you’re thinking.
I’ll be around if you have more questions.

dot(light vector a, pixel normal) * spheremask

dot(light vector b, pixel normal) * spheremask

then add together.

sometimes the light vector needs to be inverted, it will be obvious if it’s an issue.
vertex normal will work too its nearly the same as pixel normal.

I’ve given it some more thought and since a directional light with a mask is basically just a point light, so you could use point light math. either way will work though.

Your extra thought and continued attention to this is greatly appreciated! I’ll get onto scripting this quickly so we can work on it simultaneously.

To make things faster, how would you set up the normal dot product(a,b) -->sphere mask on graph?

it would look like this