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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Write to an uniform in a surface shader

Discussion in 'Shaders' started by Barti, Jul 12, 2015.

  1. Barti

    Barti

    Joined:
    Dec 8, 2012
    Posts:
    5
    Hi!

    When I understood surface shaders right, then the lighting model is repeated for every light in the scene for every pixel.

    Is there a way to save a value that consists over this whole process?
    I need to save the attenuation from the first vertex light to mask the other lights.

    I tried to write it to an uniform variable but that does not work.

    Thank you for your help!
    Barti
     
  2. Sparrowfc

    Sparrowfc

    Joined:
    Jan 31, 2013
    Posts:
    100
    use custom Lighting in surfshader will do. check the documentation for details.
     
  3. Barti

    Barti

    Joined:
    Dec 8, 2012
    Posts:
    5
    I will try that but then I need to access the attenuation of all the lights in my lighting model. How can I do that, I did not find anything about that in the documentation.