Search Unity

Question Any way to achieve an effect of looking into a bright flashlight?

Discussion in 'High Definition Render Pipeline' started by dgoyette, Oct 28, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I'm struggling to think of an approach to simulate the effect of a bright, narrow beam shining in someone's eyes. For example, a flashlight or a laser pointer pointing straight at you. In general, the light would just look like a strongly emissive circle unless it's pointed directly at you, in which case you're suddenly blinded by the intense light.

    I've tried using volumetrics for this, but it doesn't give anything like the desired effect, since the volumetrics are visible even when the light isn't pointed at the camera. I've tried just having a very emissive object, combined with bloom, but that also doesn't care about direction. Perhaps if I strongly increase the emission based on how close it is to hitting the camera...

    Anyway, I wondered if anyone else had another approach to this that I haven't thought of? I'm using HDRP 7.5.1.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,
    Perhaps you could try to implement a custom post-processing effect, or render the effect to a texture and map it to a quad, or something similar. See a quick test I made in HDRP, I adapted it from something else I've been working on.

    Some ideas for the actual implementation:

    You could calculate the angle difference between the laser and the camera lens and then also factor in the direction of the laser beam, so that the dot could also fade away when the laser/light is pointing away from the camera. This would give you more control over the effect? You could use dot product to get both of the biases and then limit them to 0-1 range, so that you don't get negatives. And use those dots also to avoid from rendering behind the camera etc. The effect look could be adjusted by adding some controls that allow you to fade the flare towards the lens edges.

    You could just use textures or procedurally generated components to visualise the laser effect. Here I used procedurally generated streaks and then a dirt mask applied over the image to simulate impurities on the lens. Polar coordinates are useful for streak style effects, especially when using a texture. And the laser dot is easily rendered procedurally using distance to a screen space location (But of course you could use a texture for that, too.)



    Still image (in case the video is removed later):

    20201028_laser_img1.PNG
     
    Last edited: Oct 28, 2020
    adamgolden and dgoyette like this.
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I'd forgotten about dirt masks. That's a pretty cool looking effect. Thanks for the idea. I'll see if that works for me.