Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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?