Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Projector headlight cutoff simulation

Discussion in 'General Graphics' started by Ethwood, May 5, 2022.

  1. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    Hi, I'm trying to simulate sharp cut-offs akin to projector headlights found on most modern cars today. I'm working on a racing game and using realtime spot lights as headlights for cars, but by default they all generate a blurry gradually attenuated conical shape for brightness, when they fall on objects in front of the car's headlights.

    I tried using a simple cube placed in front of the car blocking the upper part of lights, that works in scene view. But as soon as I stop rendering the cube in game camera by culling it's layer, the lights no longer get blocked. Also, this method seems Super inefficient as this game will be on mobile.

    Searches on this specific topic brought about nothing. I'm on Built-In.

    I'm sure there must be an efficient way to write a custom script/shader where I stop rendering bright areas above a particular height, then use a cookie image to simulate that bluish cut-off point as well as the irregular shape. (As shown in image)

    I just don't know where/what to start though.

    What I want:
    upload_2022-5-5_12-15-54.jpeg
     
  2. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    The term you want to search for is "light cookies".
     
  3. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    That does solve the problem, but I apologize that I didn't specify one thing. I want the cut off line to have a blue tint to it as well as shown in the picture. The cookies only support grey scale textures. How do I add the bluish small part above the cutoff point?