How do i make a light get increasingly brighter when you look at it? (anamorphic lens flare, billboardgui)

Put a minus in front of the Dot() product.

if - v.CFrame.LookVector:Dot(Camera.CFrame.LookVector) >= math.cos(math.rad(v.AngelOfAttack.Value)) then
1 Like

Ok! now its working, awesome, now i just need to add a way to detect if its within the part’s angle, and not the cameras angle. (angle follows the part, not the camera), you got any ideas to check if im within its boundries?

Can’t you just reverse the thing? By this I mean instead of:

partLookVector:Dot(cameraLookvector)

Just do:

cameraLookvector:Dot(partLookVector)

You’d just be checking if both of them are within their own angles. The first one would check if the player is looking at the light and the second one basically checks if the light is looking at the player.

Dunno, seems like the most intuitve solution but I might be missing something.

2 Likes

Did this, seems like the same issue is occuring, wherever you move, you can even be miles away from the part, it’ll still be thinking your in the lensflare spot, think you might’ve misunderstood.

The issue is uh, i need to detect if the camera is facing the part’s boundries, not your own.

1 Like

I just tried out what I told you earlier. Is this not what you are trying to achieve:

When the white frame is visible, that basically means there should be lense flare. Not sure if the video loaded, I never uploaded one before.
Edit: just found out I had to convert it to mp4

1 Like

uh. for me when i walk away from the part and keep looking at the direction i was looking, it keeps thinking thats the right way

You’re right I forgot about that!

1 Like

There’s a post that might be able to fix your problems, its a similar concept as yours.

Especially this section is very useful.

1 Like

I’m not exactly sure how to apply this…

1 Like

You would check if the player is looking at the light and also check if the camera is within the “FOV” of the light.

lookForward would be the LookVector of the light, lookToPoint would be the vector from the part to the camera (cameraposition - lightposition).Unit, and the FOV would be the AngleOfAttack, no?

1 Like

just realized how stupid i am. Theres a fricking / 2.
Hey while your typing, do you have any idea how to fade imagetransparency and size in, the deeper you get into the angle?!

The parts you layed out to portray 40 degrees are rotated 40° each meaning that the green angle is 80° in toal, if you rotated them 20° each I think it should align properly.

1 Like

The / 2 is supposed to be there since the angle is calculated from the center, meaning if you put 40 as the angle, it would actually be an angle of 80.

You’d probably use the values products returned by how much you are looking toward it and how much it is looking at you, sort of combine them, and calculate the transparency and size from there.

1 Like


Tested it out, the more you go down the center the more closer it gets to 0, the further you go, the more it starts to lean towards 0.6

What im tryna do is, when you get closer to the center the value becomes 6, the further you get away the value becomes 0.

For transparency just the center at 2, and edges at 0, for simplification.
Basically math oriented, if anyone could help that’d be nice.
image
Top line is a value that will multiply the size of the ui.

Bottom line is a value that will become the transparency, imagine like increments, i just need to find out how to convert that value of numbers into something like the opposite.

Bumping this, does anyone have a idea?

@VegetationBush Do you have a idea? I’ve saw you done some math related work and i pinged you because i dont know else to ping.

Whatever value you’re printing in the video earlier seems perfect for this. At its center the value should be exactly 0, the value at the corners depends on the angle. In the video its an 80 degree angle and around 0.6, I’m gonna assume its around 1 when you’re to the side of one of these lights.

To start off, you could do 1 - ThatValue, which would return 1 at the center, and around 0, when right beside it, at the angle you’ve set it, it would probably be around 0.3 at the edges or something. You can easily use this to calculate the strength of the lenseflare.

Incorperating distance from the light shouldn’t be to difficult, but its probably gonna be a bunch of trying out some stuff to get it to look right.

1 Like

I’m not really sure what your goal is as the intended result is quite confusing.

Are you:

  • increasing the size of the flare the more centered the light source is in the viewport?
  • decreasing the transparency as the player moves closer the the light source?

Increasing the size, increasing the transparency.

Well… do you know how to do math, cause i sure dont…