Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to get screen space light position?

Discussion in 'Shaders' started by FuzzyQuills, Jun 13, 2014.

  1. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Anyone know how to get screen space light pos?

    -FuzzyQuills
     
  2. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    By multiplying its position with the View Projection matrix (UNITY_MATRIX_VP)? Assuming you know the worldspace position of the light.
     
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Does that projection even exist in unity? might try this out...
     
  4. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    The documentation suggests it does. I've never tried to use the screen space position of a light though.
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Right, time to test this... BTW, I am attempting to use the screen space pos of a light for a fake god ray effect.
     
    RC-1290 likes this.