Sky Sphere Sun position ?

I was wondering a while ago about a forcefield material, so when it gets hit at a certain point a material would show this. At the moment I’ve been tweaking the Sky Sphere and have come to the same question as the forcefield.

The Sun’s position doesn’t conform to regular angles, so I’m looking for a way to position the Sun with regular xyz ?

The position of the sun should be defined by the normalized light’s X vector. Then you can make falloff in the sky by doing a dot product with the normalized light vector and normalized world position.

The force field should be the same. To get the localized position, simply subtract the sphere center from the hit position and normalize that. Then get dot product with normalized (worldposition-actorposition) and the normalized local position.

Can you explain it any simpler ?

cbc581f9ef36f657f204248c02e415d8aec63aab.jpeg

In this image, “Light Vector” acts as a position. If you put this on a sphere, it will give a white glow in that position. You can get the vector from an actual directional light using a blueprint by doing “get actor rotation” and getting the X Vector.

This works because directional lights are infinitely far away, so their position itself does not matter, all you need is the rotation or direction.

Same exact thing will work for impacts on your shield, just replace “Light vector” with “impact position - object position” normalized.

It won’t let me just write thanks, but thanks.

I setup the material first applied to a small sphere mesh and another mesh giving it’s location, which has worked fine, also did hit result which also works. However I did as you mentioned getting the x vector from rotation and it hasn’t worked. As far as I can tell the sphere mask is in the center of the world, I tried moving the sphere with the material around and the closer I got to the center it showed up.

This is what worked for mesh given location.

Screen Shot 2016-09-30 at 15.44.21.png

And you are setting “location” on hit using a blueprint by creating a material instance dynamic and then setting vector parameter on that?

… Yes.

If this is for one of the ‘force fields’ and not the sky, then you need to use a local position and not the rotation X vector. The rotation X vector was just for directional lights.

So for the top “world position” you need to subtract “actor position” or “object position”, and then normalize. Then for the “location” value, you need to do the same thing and then you can set “Location” as a world space value. Doing it that way will mean you are sure to get the same ‘object position’ for both calculations.

So far this is fine for a forcefield giving the location as hit or something similar, so I wouldn’t be using rotation x anyway. But I am using a direction light for the sky but I’m obviously doing something wrong. I shall have a practice of what you’ve just mentioned.

Any chance you can do a pretty graph for that one ?

You need to normalize the world position after subtracting actor position. if its the sky you can probably skip the subtract if actor position is at 0, but you still need to normalize. Thats why its making it seem like the spheremask is at the center only.

Get the world position of the directional light, not the rotation ?

No, I was talking about the “world position” node in your image, not the “position” variable.

Thanks, seems to be working ok. :slight_smile:

Just incase anyone else reads this … Also normalize the location input, finding strange results if it’s not.