Portals icon indicating copy to clipboard operation
Portals copied to clipboard

How could I implement a flashlight that works with the portals?

Open NicolasRisso opened this issue 1 year ago • 4 comments

The idea is basically to make the light that gets out of the flashlight pass through the portal, or simply make the cameras in the other side of the portal have their own flashlight to give the illusion of light passage (I particularly tried this one and didn't got a smooth result , cause probably by the portal camera stoping their movement if the player is looking the portal from the sideways or looking at it's corners).

NicolasRisso avatar May 17 '23 15:05 NicolasRisso

Hello! If you are using lights to make a flashlight, you could make 2 lights, one for the flashlight and one coming out the other portal, pointed in a certain direction based on the original direction. I'm not very good at math, but maybe we can map the position the light hits on the portal to the other portal, then imagine if the player was there and his rotation was his original rotation but with the difference of the rotation between the forward direction of the portals added, then the new light rotation and position is the position and rotation of the hypothetical player. But don't trust that math, I don't know what the correct math is.

kaitabuchi314 avatar Sep 06 '23 00:09 kaitabuchi314

Sorry for not reading your full issue!

kaitabuchi314 avatar Sep 10 '23 14:09 kaitabuchi314

Can you please provide an image (not a YouTube video)?

kaitabuchi314 avatar Sep 10 '23 14:09 kaitabuchi314

Sure thing! I tried adding the lights to the portal camera too, but it had 2 main problems:

  1. In the border of the portal, for some reason, the camera stoped moving accordingly with the player camera (image) (image2)
  2. Some parts of the map are really close, and, since my map is dark, sometimes the lights that the portal renders in the other side is visuable. I know that level design can fix that, but I think it's an relevant point too.

I think that the portalCam probably stop moving when you look to close to the edge, maybe some fancy code could fix that, but I still think that a shader would be nicer.

imagem_2023-09-20_142906193

NicolasRisso avatar Sep 20 '23 17:09 NicolasRisso